# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
293120 | 2020-09-07T16:32:50 Z | Berted | Monochrome Points (JOI20_monochrome) | C++14 | 68 ms | 1944 KB |
#include <iostream> #include <vector> using namespace std; int n; string s; vector<int> C[2]; long long ans = 0; bool matchWith[100001]; long long solve(int x) { long long temp = 0; for (int i = 0; i < C[0].size(); i++) { temp += min(abs(C[1][(i + x) % C[1].size()] - C[0][i]), n - abs(C[1][(i + x) % C[1].size()] - C[0][i])); } return temp; } long long binser(int L, int R) { while (L < R) { int M = L + R >> 1; if (solve(M) < solve(M + 1)) {R = M;} else {L = M + 1;} } long long ret = 1e18; for (int i = max(0, L - 5); i < min(L + 5, (int)C[0].size()); i++) {ret = min(ret, solve(i));} return ret; } int main() { cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == s[i + n]) {C[s[i] == 'W'].push_back(i);} } ans = (long long)n * (n - 1) / 2; if (C[0].size()) { long long res = 1e18; res = min(binser(0, (int)C[0].size() / 2 - 1), binser((int)C[0].size() / 2, (int)C[0].size() - 2)); ans -= res; } cout << ans << "\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 256 KB | Output is correct |
14 | Correct | 1 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 256 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 1 ms | 256 KB | Output is correct |
20 | Correct | 1 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 256 KB | Output is correct |
22 | Correct | 0 ms | 256 KB | Output is correct |
23 | Correct | 0 ms | 256 KB | Output is correct |
24 | Correct | 0 ms | 256 KB | Output is correct |
25 | Correct | 0 ms | 256 KB | Output is correct |
26 | Correct | 0 ms | 256 KB | Output is correct |
27 | Correct | 0 ms | 256 KB | Output is correct |
28 | Correct | 1 ms | 256 KB | Output is correct |
29 | Correct | 1 ms | 308 KB | Output is correct |
30 | Correct | 0 ms | 256 KB | Output is correct |
31 | Correct | 0 ms | 256 KB | Output is correct |
32 | Correct | 1 ms | 256 KB | Output is correct |
33 | Correct | 1 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 256 KB | Output is correct |
14 | Correct | 1 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 256 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 1 ms | 256 KB | Output is correct |
20 | Correct | 1 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 256 KB | Output is correct |
22 | Correct | 0 ms | 256 KB | Output is correct |
23 | Correct | 0 ms | 256 KB | Output is correct |
24 | Correct | 0 ms | 256 KB | Output is correct |
25 | Correct | 0 ms | 256 KB | Output is correct |
26 | Correct | 0 ms | 256 KB | Output is correct |
27 | Correct | 0 ms | 256 KB | Output is correct |
28 | Correct | 1 ms | 256 KB | Output is correct |
29 | Correct | 1 ms | 308 KB | Output is correct |
30 | Correct | 0 ms | 256 KB | Output is correct |
31 | Correct | 0 ms | 256 KB | Output is correct |
32 | Correct | 1 ms | 256 KB | Output is correct |
33 | Correct | 1 ms | 256 KB | Output is correct |
34 | Correct | 1 ms | 384 KB | Output is correct |
35 | Correct | 1 ms | 384 KB | Output is correct |
36 | Correct | 1 ms | 384 KB | Output is correct |
37 | Correct | 1 ms | 256 KB | Output is correct |
38 | Correct | 1 ms | 256 KB | Output is correct |
39 | Correct | 1 ms | 384 KB | Output is correct |
40 | Correct | 1 ms | 384 KB | Output is correct |
41 | Correct | 1 ms | 256 KB | Output is correct |
42 | Correct | 1 ms | 384 KB | Output is correct |
43 | Correct | 1 ms | 384 KB | Output is correct |
44 | Correct | 1 ms | 384 KB | Output is correct |
45 | Correct | 1 ms | 256 KB | Output is correct |
46 | Correct | 1 ms | 384 KB | Output is correct |
47 | Correct | 1 ms | 256 KB | Output is correct |
48 | Correct | 1 ms | 384 KB | Output is correct |
49 | Correct | 1 ms | 384 KB | Output is correct |
50 | Correct | 1 ms | 384 KB | Output is correct |
51 | Correct | 1 ms | 384 KB | Output is correct |
52 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 0 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 1 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 256 KB | Output is correct |
14 | Correct | 1 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 256 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 1 ms | 256 KB | Output is correct |
20 | Correct | 1 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 256 KB | Output is correct |
22 | Correct | 0 ms | 256 KB | Output is correct |
23 | Correct | 0 ms | 256 KB | Output is correct |
24 | Correct | 0 ms | 256 KB | Output is correct |
25 | Correct | 0 ms | 256 KB | Output is correct |
26 | Correct | 0 ms | 256 KB | Output is correct |
27 | Correct | 0 ms | 256 KB | Output is correct |
28 | Correct | 1 ms | 256 KB | Output is correct |
29 | Correct | 1 ms | 308 KB | Output is correct |
30 | Correct | 0 ms | 256 KB | Output is correct |
31 | Correct | 0 ms | 256 KB | Output is correct |
32 | Correct | 1 ms | 256 KB | Output is correct |
33 | Correct | 1 ms | 256 KB | Output is correct |
34 | Correct | 1 ms | 384 KB | Output is correct |
35 | Correct | 1 ms | 384 KB | Output is correct |
36 | Correct | 1 ms | 384 KB | Output is correct |
37 | Correct | 1 ms | 256 KB | Output is correct |
38 | Correct | 1 ms | 256 KB | Output is correct |
39 | Correct | 1 ms | 384 KB | Output is correct |
40 | Correct | 1 ms | 384 KB | Output is correct |
41 | Correct | 1 ms | 256 KB | Output is correct |
42 | Correct | 1 ms | 384 KB | Output is correct |
43 | Correct | 1 ms | 384 KB | Output is correct |
44 | Correct | 1 ms | 384 KB | Output is correct |
45 | Correct | 1 ms | 256 KB | Output is correct |
46 | Correct | 1 ms | 384 KB | Output is correct |
47 | Correct | 1 ms | 256 KB | Output is correct |
48 | Correct | 1 ms | 384 KB | Output is correct |
49 | Correct | 1 ms | 384 KB | Output is correct |
50 | Correct | 1 ms | 384 KB | Output is correct |
51 | Correct | 1 ms | 384 KB | Output is correct |
52 | Correct | 1 ms | 384 KB | Output is correct |
53 | Correct | 42 ms | 1308 KB | Output is correct |
54 | Correct | 44 ms | 1436 KB | Output is correct |
55 | Correct | 42 ms | 1308 KB | Output is correct |
56 | Correct | 40 ms | 1308 KB | Output is correct |
57 | Correct | 19 ms | 912 KB | Output is correct |
58 | Correct | 52 ms | 1816 KB | Output is correct |
59 | Correct | 65 ms | 1908 KB | Output is correct |
60 | Correct | 55 ms | 1308 KB | Output is correct |
61 | Correct | 39 ms | 1172 KB | Output is correct |
62 | Correct | 46 ms | 1488 KB | Output is correct |
63 | Correct | 40 ms | 1308 KB | Output is correct |
64 | Correct | 34 ms | 1180 KB | Output is correct |
65 | Correct | 24 ms | 1056 KB | Output is correct |
66 | Correct | 22 ms | 912 KB | Output is correct |
67 | Correct | 24 ms | 916 KB | Output is correct |
68 | Correct | 22 ms | 912 KB | Output is correct |
69 | Correct | 47 ms | 1428 KB | Output is correct |
70 | Correct | 31 ms | 1052 KB | Output is correct |
71 | Correct | 20 ms | 912 KB | Output is correct |
72 | Correct | 20 ms | 912 KB | Output is correct |
73 | Correct | 68 ms | 1944 KB | Output is correct |