# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
962341 | 2024-04-13T10:54:08 Z | 0npata | Monochrome Points (JOI20_monochrome) | C++17 | 2000 ms | 11760 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define vec vector #define pi pair<int, int> #define fst first #define snd second #define pb push_back int n; string s; int mes(vec<pi> p) { int res = 0; int j = p[0].fst; int k = p[0].fst; int cntw = 1; int cntb = 0; for(int i = 0; i<n; i++) { while(k != p[i].fst) { cntw -= s[k]=='W'; cntb -= s[k] == 'B'; k+=1; k %= 2*n; } while(j != p[i].snd) { j += 1; j %= 2*n; cntw += s[j]=='W'; cntb += s[j] == 'B'; } int rw = cntw-1; int orb = n-cntb; res += min(rw, orb); } return res; } int32_t main() { cin >> n; cin >> s; vec<int> b(0); vec<int> w(0); for(int i = 0; i<s.size(); i++) { if(s[i] == 'W') { w.pb(i); } else { b.pb(i); } } int ans = 0; for(int i = 0; i<n; i++) { // construct possible pairings vec<pi> p; for(int j = 0; j<n; j++) { p.pb({w[j], b[(j+i)%n]}); } int res = mes(p); ans = max(res, ans); // cout << i << ": " << res << '\n'; } cout << ans << '\n'; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 4 ms | 464 KB | Output is correct |
15 | Correct | 4 ms | 440 KB | Output is correct |
16 | Correct | 4 ms | 348 KB | Output is correct |
17 | Correct | 4 ms | 344 KB | Output is correct |
18 | Correct | 3 ms | 348 KB | Output is correct |
19 | Correct | 3 ms | 432 KB | Output is correct |
20 | Correct | 3 ms | 348 KB | Output is correct |
21 | Correct | 3 ms | 348 KB | Output is correct |
22 | Correct | 3 ms | 468 KB | Output is correct |
23 | Correct | 2 ms | 348 KB | Output is correct |
24 | Correct | 2 ms | 348 KB | Output is correct |
25 | Correct | 2 ms | 348 KB | Output is correct |
26 | Correct | 3 ms | 472 KB | Output is correct |
27 | Correct | 3 ms | 344 KB | Output is correct |
28 | Correct | 3 ms | 348 KB | Output is correct |
29 | Correct | 2 ms | 348 KB | Output is correct |
30 | Correct | 3 ms | 348 KB | Output is correct |
31 | Correct | 3 ms | 464 KB | Output is correct |
32 | Correct | 3 ms | 348 KB | Output is correct |
33 | Correct | 3 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 4 ms | 464 KB | Output is correct |
15 | Correct | 4 ms | 440 KB | Output is correct |
16 | Correct | 4 ms | 348 KB | Output is correct |
17 | Correct | 4 ms | 344 KB | Output is correct |
18 | Correct | 3 ms | 348 KB | Output is correct |
19 | Correct | 3 ms | 432 KB | Output is correct |
20 | Correct | 3 ms | 348 KB | Output is correct |
21 | Correct | 3 ms | 348 KB | Output is correct |
22 | Correct | 3 ms | 468 KB | Output is correct |
23 | Correct | 2 ms | 348 KB | Output is correct |
24 | Correct | 2 ms | 348 KB | Output is correct |
25 | Correct | 2 ms | 348 KB | Output is correct |
26 | Correct | 3 ms | 472 KB | Output is correct |
27 | Correct | 3 ms | 344 KB | Output is correct |
28 | Correct | 3 ms | 348 KB | Output is correct |
29 | Correct | 2 ms | 348 KB | Output is correct |
30 | Correct | 3 ms | 348 KB | Output is correct |
31 | Correct | 3 ms | 464 KB | Output is correct |
32 | Correct | 3 ms | 348 KB | Output is correct |
33 | Correct | 3 ms | 348 KB | Output is correct |
34 | Correct | 170 ms | 564 KB | Output is correct |
35 | Correct | 173 ms | 348 KB | Output is correct |
36 | Correct | 166 ms | 556 KB | Output is correct |
37 | Correct | 153 ms | 548 KB | Output is correct |
38 | Correct | 108 ms | 556 KB | Output is correct |
39 | Correct | 119 ms | 556 KB | Output is correct |
40 | Correct | 108 ms | 544 KB | Output is correct |
41 | Correct | 103 ms | 548 KB | Output is correct |
42 | Correct | 154 ms | 348 KB | Output is correct |
43 | Correct | 122 ms | 348 KB | Output is correct |
44 | Correct | 113 ms | 552 KB | Output is correct |
45 | Correct | 111 ms | 348 KB | Output is correct |
46 | Correct | 119 ms | 344 KB | Output is correct |
47 | Correct | 134 ms | 544 KB | Output is correct |
48 | Correct | 130 ms | 556 KB | Output is correct |
49 | Correct | 106 ms | 548 KB | Output is correct |
50 | Correct | 119 ms | 548 KB | Output is correct |
51 | Correct | 119 ms | 344 KB | Output is correct |
52 | Correct | 127 ms | 560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 344 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 4 ms | 464 KB | Output is correct |
15 | Correct | 4 ms | 440 KB | Output is correct |
16 | Correct | 4 ms | 348 KB | Output is correct |
17 | Correct | 4 ms | 344 KB | Output is correct |
18 | Correct | 3 ms | 348 KB | Output is correct |
19 | Correct | 3 ms | 432 KB | Output is correct |
20 | Correct | 3 ms | 348 KB | Output is correct |
21 | Correct | 3 ms | 348 KB | Output is correct |
22 | Correct | 3 ms | 468 KB | Output is correct |
23 | Correct | 2 ms | 348 KB | Output is correct |
24 | Correct | 2 ms | 348 KB | Output is correct |
25 | Correct | 2 ms | 348 KB | Output is correct |
26 | Correct | 3 ms | 472 KB | Output is correct |
27 | Correct | 3 ms | 344 KB | Output is correct |
28 | Correct | 3 ms | 348 KB | Output is correct |
29 | Correct | 2 ms | 348 KB | Output is correct |
30 | Correct | 3 ms | 348 KB | Output is correct |
31 | Correct | 3 ms | 464 KB | Output is correct |
32 | Correct | 3 ms | 348 KB | Output is correct |
33 | Correct | 3 ms | 348 KB | Output is correct |
34 | Correct | 170 ms | 564 KB | Output is correct |
35 | Correct | 173 ms | 348 KB | Output is correct |
36 | Correct | 166 ms | 556 KB | Output is correct |
37 | Correct | 153 ms | 548 KB | Output is correct |
38 | Correct | 108 ms | 556 KB | Output is correct |
39 | Correct | 119 ms | 556 KB | Output is correct |
40 | Correct | 108 ms | 544 KB | Output is correct |
41 | Correct | 103 ms | 548 KB | Output is correct |
42 | Correct | 154 ms | 348 KB | Output is correct |
43 | Correct | 122 ms | 348 KB | Output is correct |
44 | Correct | 113 ms | 552 KB | Output is correct |
45 | Correct | 111 ms | 348 KB | Output is correct |
46 | Correct | 119 ms | 344 KB | Output is correct |
47 | Correct | 134 ms | 544 KB | Output is correct |
48 | Correct | 130 ms | 556 KB | Output is correct |
49 | Correct | 106 ms | 548 KB | Output is correct |
50 | Correct | 119 ms | 548 KB | Output is correct |
51 | Correct | 119 ms | 344 KB | Output is correct |
52 | Correct | 127 ms | 560 KB | Output is correct |
53 | Execution timed out | 2057 ms | 11760 KB | Time limit exceeded |
54 | Halted | 0 ms | 0 KB | - |