Submission #800608

# Submission time Handle Problem Language Result Execution time Memory
800608 2023-08-01T16:43:19 Z Dan4Life Monochrome Points (JOI20_monochrome) C++17
35 / 100
177 ms 5220 KB
#include <bits/stdc++.h>
using namespace std;
const int N = (int)4e3+10;
string s; int n, ans, tot, fen[N], st[N];
void upd(int x, int v){ for(; x<N; x+=x&-x) fen[x]+=v; }
int sum(int x){ int s=0; for(; x>0; x-=x&-x)s+=fen[x]; return s; }
int sum(int a, int b){ return (a<=b)*(sum(b)-sum(a-1)); }

int main()
{
    cin >> n >> s; vector<int> v[2];
    for(int i = 0; i < 2*n; i++) v[s[i]>'B'].push_back(i+1);
    for(int k = 0; k < n; k++){ tot=0;
        for(int i = 0; i < n; i++){
            int a = v[0][i], b = v[1][(i+k)%n];
            if(a>b) swap(a,b); st[a] = a; st[b]=a;
        }
        for(int i = 1; i <= 2*n; i++){
            if(st[i]==i) upd(st[i],1);
            else tot+=sum(st[i]+1,i), upd(st[i],-1);
        }
        ans = max(ans, tot);
    }
    cout << ans;
}

Compilation message

monochrome.cpp: In function 'int main()':
monochrome.cpp:16:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   16 |             if(a>b) swap(a,b); st[a] = a; st[b]=a;
      |             ^~
monochrome.cpp:16:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   16 |             if(a>b) swap(a,b); st[a] = a; st[b]=a;
      |                                ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 4 ms 212 KB Output is correct
15 Correct 4 ms 212 KB Output is correct
16 Correct 4 ms 320 KB Output is correct
17 Correct 5 ms 320 KB Output is correct
18 Correct 3 ms 316 KB Output is correct
19 Correct 3 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 3 ms 212 KB Output is correct
23 Correct 2 ms 316 KB Output is correct
24 Correct 3 ms 212 KB Output is correct
25 Correct 3 ms 212 KB Output is correct
26 Correct 3 ms 212 KB Output is correct
27 Correct 3 ms 212 KB Output is correct
28 Correct 3 ms 212 KB Output is correct
29 Correct 2 ms 212 KB Output is correct
30 Correct 3 ms 256 KB Output is correct
31 Correct 3 ms 212 KB Output is correct
32 Correct 3 ms 252 KB Output is correct
33 Correct 4 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 4 ms 212 KB Output is correct
15 Correct 4 ms 212 KB Output is correct
16 Correct 4 ms 320 KB Output is correct
17 Correct 5 ms 320 KB Output is correct
18 Correct 3 ms 316 KB Output is correct
19 Correct 3 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 3 ms 212 KB Output is correct
23 Correct 2 ms 316 KB Output is correct
24 Correct 3 ms 212 KB Output is correct
25 Correct 3 ms 212 KB Output is correct
26 Correct 3 ms 212 KB Output is correct
27 Correct 3 ms 212 KB Output is correct
28 Correct 3 ms 212 KB Output is correct
29 Correct 2 ms 212 KB Output is correct
30 Correct 3 ms 256 KB Output is correct
31 Correct 3 ms 212 KB Output is correct
32 Correct 3 ms 252 KB Output is correct
33 Correct 4 ms 316 KB Output is correct
34 Correct 177 ms 348 KB Output is correct
35 Correct 176 ms 340 KB Output is correct
36 Correct 167 ms 344 KB Output is correct
37 Correct 157 ms 352 KB Output is correct
38 Correct 102 ms 340 KB Output is correct
39 Correct 116 ms 340 KB Output is correct
40 Correct 107 ms 340 KB Output is correct
41 Correct 114 ms 344 KB Output is correct
42 Correct 165 ms 344 KB Output is correct
43 Correct 133 ms 340 KB Output is correct
44 Correct 125 ms 340 KB Output is correct
45 Correct 127 ms 340 KB Output is correct
46 Correct 133 ms 340 KB Output is correct
47 Correct 135 ms 340 KB Output is correct
48 Correct 130 ms 352 KB Output is correct
49 Correct 113 ms 340 KB Output is correct
50 Correct 115 ms 340 KB Output is correct
51 Correct 115 ms 340 KB Output is correct
52 Correct 125 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 4 ms 212 KB Output is correct
15 Correct 4 ms 212 KB Output is correct
16 Correct 4 ms 320 KB Output is correct
17 Correct 5 ms 320 KB Output is correct
18 Correct 3 ms 316 KB Output is correct
19 Correct 3 ms 212 KB Output is correct
20 Correct 3 ms 212 KB Output is correct
21 Correct 3 ms 212 KB Output is correct
22 Correct 3 ms 212 KB Output is correct
23 Correct 2 ms 316 KB Output is correct
24 Correct 3 ms 212 KB Output is correct
25 Correct 3 ms 212 KB Output is correct
26 Correct 3 ms 212 KB Output is correct
27 Correct 3 ms 212 KB Output is correct
28 Correct 3 ms 212 KB Output is correct
29 Correct 2 ms 212 KB Output is correct
30 Correct 3 ms 256 KB Output is correct
31 Correct 3 ms 212 KB Output is correct
32 Correct 3 ms 252 KB Output is correct
33 Correct 4 ms 316 KB Output is correct
34 Correct 177 ms 348 KB Output is correct
35 Correct 176 ms 340 KB Output is correct
36 Correct 167 ms 344 KB Output is correct
37 Correct 157 ms 352 KB Output is correct
38 Correct 102 ms 340 KB Output is correct
39 Correct 116 ms 340 KB Output is correct
40 Correct 107 ms 340 KB Output is correct
41 Correct 114 ms 344 KB Output is correct
42 Correct 165 ms 344 KB Output is correct
43 Correct 133 ms 340 KB Output is correct
44 Correct 125 ms 340 KB Output is correct
45 Correct 127 ms 340 KB Output is correct
46 Correct 133 ms 340 KB Output is correct
47 Correct 135 ms 340 KB Output is correct
48 Correct 130 ms 352 KB Output is correct
49 Correct 113 ms 340 KB Output is correct
50 Correct 115 ms 340 KB Output is correct
51 Correct 115 ms 340 KB Output is correct
52 Correct 125 ms 340 KB Output is correct
53 Runtime error 10 ms 5220 KB Execution killed with signal 11
54 Halted 0 ms 0 KB -