# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
534749 | RaresFelix | Monochrome Points (JOI20_monochrome) | C++17 | 45 ms | 3400 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define MN 407171
using namespace std;
int n;
vector<int> P1, P2;
char C[MN];
using ll = long long;
ll re(int k) {
ll r = 0;
for(int i = 0; i < n; ++i) {
int p1 = P1[i], p2 = P2[(i + k) % n];
r += min(abs(p1 - p2) - 1, 2 * n - (abs(p1 - p2) + 1));
}
return r;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
cin >> n >> (C + 1);
int bp = -1, ndif = INT_MAX;
for(int i = 1; i <= 2 * n; ++i)
(C[i] != C[1] ? P2 : P1).push_back(i);
int st = 0, dr = 2 * n - 1, mij;
while(st < dr) {
mij = (st + dr + 1) >> 1;
if(re(mij) < re(mij + 1)) st = mij;
else dr = mij - 1;
}
ll rez = max({re(st), re((st - 1 + 2 * n) % (2 * n)), re((st + 1) % (2 * n))});
cout << rez / 2 << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |