AtCoder Beginner Contest 255

## [A - You should output ARC, though this is ABC.](https://atcoder.jp/contests/abc255/tasks/abc255_a)

O(1)

```C++:C++
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define repx(i,x,n) for(int i=x; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main() {
    int R, C;
    cin >> R >> C;
    int A[2][2];
    rep(i, 2) rep(j, 2) cin >> A[i][j];
    cout << A[R-1][C-1] << endl;

    return 0;
} 
```

## [B - Light It Up](https://atcoder.jp/contests/abc255/tasks/abc255_b)

O(NK)
三角形の公式の問題です。
明かりを持っている人に０を代入します。
全ての明かりと点との距離を計算して、最小値を保持します。

```C++:C++
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define repx(i,x,n) for(int i=x; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }
 
int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N), X(N), Y(N);
    rep(i, K) cin >> A[i];
    rep(i, N) cin >> X[i] >> Y[i];
 
    vector<double> D(N, 1e9+7);
    rep(i, K){
        int index = A[i]-1;
        double x1 = X[index];
        double y1 = Y[index];
        rep(j, N){
            if(j==index){
                D[j] = 0;
                continue;
            }
            double x2 = X[j];
            double y2 = Y[j];
            double d = sqrt( (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1) );
            D[j] = min(d, D[j]);
        }
    }
    double ans=0;
    rep(i, N) ans = max(ans, D[i]);
    cout << fixed_setprecision(6) << ans << endl;
 
    return 0;
}
```

## [C - ±1 Operation 1](https://atcoder.jp/contests/abc255/tasks/abc255_c)

O(1)

```C++:C++
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define repx(i,x,n) for(int i=x; i<(n); ++i)
#define fixed_setprecision(n) fixed << setprecision((n))
#define execution_time(ti) printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
#define pai 3.1415926535897932384
#define NUM_MAX 2e18
#define NUM_MIN -1e9
 
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main() {
    ll X, A, D, N;
    cin >> X >> A >> D >> N;
    N = N - 1;

    if(X==A){
        cout << 0 << endl;
    }else{
        ll d = X - A;
        if(d>0 && D>0){
            ll r = d % D;
            ll p = d / D;
            if(p>N) r += (p - N) * D;
            else if(p+1<=N) r = min(r,D-r);
            cout << r << endl;
        }else if(d<0 && D<0){
            d = -d;
            D = -D;
            ll r = d % D;
            ll p = d / D;
            if(p>N) r += (p - N) * D;
            else if(p+1<=N) r = min(r,D-r);
            cout << r << endl;            
        }else{
            if(d<0){
                cout << -d << endl;
            }else{
                cout << d << endl;
            }
        }
    }

    return 0;
} 
```

## []()

```C++:C++
```