# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
292580 | 2020-09-07T10:06:10 Z | model_code | Monochrome Points (JOI20_monochrome) | C++17 | 42 ms | 4840 KB |
#include <bits/stdc++.h> #define SIZE 400005 using namespace std; typedef pair <int,int> P; typedef long long int ll; char str[SIZE]; ll rt[SIZE]; int n; void add(int l,int r,int k) { if(l>r) return; while(l<0) l+=n,r+=n; while(1) { if(l/n!=r/n) { rt[l%n]+=k; rt[n]-=k; l=(l/n+1)*n; } else { rt[l%n]+=k; rt[r%n+1]-=k; break; } } } int main() { scanf("%d",&n); scanf("%s",&str); vector <int> vb,vw; for(int i=0;i<2*n;i++) { if(str[i]=='B') vb.push_back(i); else vw.push_back(i); } for(int i=0;i<n;i++) vw.push_back(vw[i]+2*n); int s=0,t=0; for(int i=0;i<n;i++) { while(t<vw.size()&&vw[t]<=vb[i]+n) t++; while(s<vw.size()&&vw[s]<vb[i]) s++; add(s-i,t-i-1,-vb[i]-1); add(t-i,s+n-i-1,2*n+vb[i]-1); } s=t=0; int r=0; for(int i=0;i<2*n;i++) { while(t<vb.size()&&vb[t]<vw[i]) t++; while(s<vb.size()&&vb[s]<vw[i]-n) s++; while(r<vb.size()&&vb[r]<vw[i]-2*n) r++; add(i-t+1,i-s,vw[i]); add(i-s+1,i-r,-vw[i]); } for(int i=1;i<n;i++) rt[i]+=rt[i-1]; ll ret=0; for(int i=0;i<n;i++) ret=max(ret,rt[i]); printf("%lld\n",ret/2); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 0 ms | 384 KB | Output is correct |
25 | Correct | 0 ms | 384 KB | Output is correct |
26 | Correct | 0 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 0 ms | 384 KB | Output is correct |
29 | Correct | 0 ms | 384 KB | Output is correct |
30 | Correct | 0 ms | 384 KB | Output is correct |
31 | Correct | 0 ms | 384 KB | Output is correct |
32 | Correct | 1 ms | 512 KB | Output is correct |
33 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 0 ms | 384 KB | Output is correct |
25 | Correct | 0 ms | 384 KB | Output is correct |
26 | Correct | 0 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 0 ms | 384 KB | Output is correct |
29 | Correct | 0 ms | 384 KB | Output is correct |
30 | Correct | 0 ms | 384 KB | Output is correct |
31 | Correct | 0 ms | 384 KB | Output is correct |
32 | Correct | 1 ms | 512 KB | Output is correct |
33 | Correct | 1 ms | 384 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 | 384 KB | Output is correct |
38 | Correct | 1 ms | 384 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 | 384 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 | 384 KB | Output is correct |
46 | Correct | 1 ms | 384 KB | Output is correct |
47 | Correct | 1 ms | 384 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 1 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Correct | 1 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 0 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 0 ms | 384 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 0 ms | 384 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 0 ms | 384 KB | Output is correct |
25 | Correct | 0 ms | 384 KB | Output is correct |
26 | Correct | 0 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 0 ms | 384 KB | Output is correct |
29 | Correct | 0 ms | 384 KB | Output is correct |
30 | Correct | 0 ms | 384 KB | Output is correct |
31 | Correct | 0 ms | 384 KB | Output is correct |
32 | Correct | 1 ms | 512 KB | Output is correct |
33 | Correct | 1 ms | 384 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 | 384 KB | Output is correct |
38 | Correct | 1 ms | 384 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 | 384 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 | 384 KB | Output is correct |
46 | Correct | 1 ms | 384 KB | Output is correct |
47 | Correct | 1 ms | 384 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 | 4708 KB | Output is correct |
54 | Correct | 42 ms | 4808 KB | Output is correct |
55 | Correct | 39 ms | 4572 KB | Output is correct |
56 | Correct | 39 ms | 4628 KB | Output is correct |
57 | Correct | 29 ms | 4584 KB | Output is correct |
58 | Correct | 31 ms | 4716 KB | Output is correct |
59 | Correct | 29 ms | 4704 KB | Output is correct |
60 | Correct | 29 ms | 4620 KB | Output is correct |
61 | Correct | 29 ms | 4624 KB | Output is correct |
62 | Correct | 30 ms | 4620 KB | Output is correct |
63 | Correct | 32 ms | 4704 KB | Output is correct |
64 | Correct | 27 ms | 4592 KB | Output is correct |
65 | Correct | 29 ms | 4368 KB | Output is correct |
66 | Correct | 30 ms | 4592 KB | Output is correct |
67 | Correct | 30 ms | 4584 KB | Output is correct |
68 | Correct | 28 ms | 4336 KB | Output is correct |
69 | Correct | 29 ms | 4712 KB | Output is correct |
70 | Correct | 27 ms | 4332 KB | Output is correct |
71 | Correct | 27 ms | 4720 KB | Output is correct |
72 | Correct | 27 ms | 4720 KB | Output is correct |
73 | Correct | 27 ms | 4840 KB | Output is correct |