Submission #800602

# Submission time Handle Problem Language Result Execution time Memory
800602 2023-08-01T16:38:14 Z Dan4Life Monochrome Points (JOI20_monochrome) C++17
35 / 100
2000 ms 6168 KB
#include <bits/stdc++.h>
using namespace std;
const int N = (int)4e5+10;
int n, fen[N], st[N];
string s;
 
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]; int ss = 0;
    for(int i = 0; i < 2*n; i++) v[s[i]=='B'].push_back(i+1);
    for(int k = 0; k < n; k++){
        int ans = 0;
        for(int i = 1; i <= 2*n; i++) st[i]=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 ans+=sum(st[i]+1,i), upd(st[i],-1);
        }
        ss = max(ans, ss);
    }
    cout << ss;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 7 ms 340 KB Output is correct
15 Correct 6 ms 340 KB Output is correct
16 Correct 6 ms 360 KB Output is correct
17 Correct 7 ms 340 KB Output is correct
18 Correct 4 ms 340 KB Output is correct
19 Correct 5 ms 340 KB Output is correct
20 Correct 5 ms 340 KB Output is correct
21 Correct 4 ms 360 KB Output is correct
22 Correct 5 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 4 ms 340 KB Output is correct
25 Correct 4 ms 352 KB Output is correct
26 Correct 4 ms 340 KB Output is correct
27 Correct 5 ms 360 KB Output is correct
28 Correct 5 ms 340 KB Output is correct
29 Correct 4 ms 340 KB Output is correct
30 Correct 4 ms 304 KB Output is correct
31 Correct 5 ms 340 KB Output is correct
32 Correct 5 ms 356 KB Output is correct
33 Correct 5 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 7 ms 340 KB Output is correct
15 Correct 6 ms 340 KB Output is correct
16 Correct 6 ms 360 KB Output is correct
17 Correct 7 ms 340 KB Output is correct
18 Correct 4 ms 340 KB Output is correct
19 Correct 5 ms 340 KB Output is correct
20 Correct 5 ms 340 KB Output is correct
21 Correct 4 ms 360 KB Output is correct
22 Correct 5 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 4 ms 340 KB Output is correct
25 Correct 4 ms 352 KB Output is correct
26 Correct 4 ms 340 KB Output is correct
27 Correct 5 ms 360 KB Output is correct
28 Correct 5 ms 340 KB Output is correct
29 Correct 4 ms 340 KB Output is correct
30 Correct 4 ms 304 KB Output is correct
31 Correct 5 ms 340 KB Output is correct
32 Correct 5 ms 356 KB Output is correct
33 Correct 5 ms 340 KB Output is correct
34 Correct 263 ms 340 KB Output is correct
35 Correct 253 ms 388 KB Output is correct
36 Correct 238 ms 340 KB Output is correct
37 Correct 232 ms 380 KB Output is correct
38 Correct 173 ms 380 KB Output is correct
39 Correct 197 ms 392 KB Output is correct
40 Correct 168 ms 340 KB Output is correct
41 Correct 167 ms 384 KB Output is correct
42 Correct 252 ms 340 KB Output is correct
43 Correct 215 ms 388 KB Output is correct
44 Correct 198 ms 380 KB Output is correct
45 Correct 198 ms 384 KB Output is correct
46 Correct 227 ms 384 KB Output is correct
47 Correct 238 ms 340 KB Output is correct
48 Correct 206 ms 392 KB Output is correct
49 Correct 162 ms 376 KB Output is correct
50 Correct 200 ms 384 KB Output is correct
51 Correct 211 ms 380 KB Output is correct
52 Correct 209 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 7 ms 340 KB Output is correct
15 Correct 6 ms 340 KB Output is correct
16 Correct 6 ms 360 KB Output is correct
17 Correct 7 ms 340 KB Output is correct
18 Correct 4 ms 340 KB Output is correct
19 Correct 5 ms 340 KB Output is correct
20 Correct 5 ms 340 KB Output is correct
21 Correct 4 ms 360 KB Output is correct
22 Correct 5 ms 340 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 4 ms 340 KB Output is correct
25 Correct 4 ms 352 KB Output is correct
26 Correct 4 ms 340 KB Output is correct
27 Correct 5 ms 360 KB Output is correct
28 Correct 5 ms 340 KB Output is correct
29 Correct 4 ms 340 KB Output is correct
30 Correct 4 ms 304 KB Output is correct
31 Correct 5 ms 340 KB Output is correct
32 Correct 5 ms 356 KB Output is correct
33 Correct 5 ms 340 KB Output is correct
34 Correct 263 ms 340 KB Output is correct
35 Correct 253 ms 388 KB Output is correct
36 Correct 238 ms 340 KB Output is correct
37 Correct 232 ms 380 KB Output is correct
38 Correct 173 ms 380 KB Output is correct
39 Correct 197 ms 392 KB Output is correct
40 Correct 168 ms 340 KB Output is correct
41 Correct 167 ms 384 KB Output is correct
42 Correct 252 ms 340 KB Output is correct
43 Correct 215 ms 388 KB Output is correct
44 Correct 198 ms 380 KB Output is correct
45 Correct 198 ms 384 KB Output is correct
46 Correct 227 ms 384 KB Output is correct
47 Correct 238 ms 340 KB Output is correct
48 Correct 206 ms 392 KB Output is correct
49 Correct 162 ms 376 KB Output is correct
50 Correct 200 ms 384 KB Output is correct
51 Correct 211 ms 380 KB Output is correct
52 Correct 209 ms 384 KB Output is correct
53 Execution timed out 2037 ms 6168 KB Time limit exceeded
54 Halted 0 ms 0 KB -