#include "bits/stdc++.h"
using namespace std;
#define ar array
signed main(){
ios::sync_with_stdio(0); cin.tie(0);
int n; cin>>n;
string s; cin>>s;
ar<vector<int>, 2> p;
for(int i=0;i<2*n;i++){
p[s[i] == 'B'].push_back(i);
}
int rr = 0;
for(int k=0;k<n;k++){
vector<ar<int, 2>> a(n);
int res = 0;
for(int i=0;i<n;i++){
int j = (i + k) % n;
a[i] = {p[0][i], p[1][j]};
if(a[i][0] > a[i][1]) swap(a[i][0], a[i][1]);
}
auto check = [&](ar<int, 2> a, ar<int, 2> b){
if(a[0] < b[0] && b[1] < a[1]) return;
if(b[0] < a[0] && a[1] < b[1]) return;
res += (max(a[0], b[0]) < min(a[1], b[1]));
};
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
check(a[i], a[j]);
}
}
rr = max(rr, res);
}
cout<<rr<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
21 ms |
328 KB |
Output is correct |
15 |
Correct |
22 ms |
320 KB |
Output is correct |
16 |
Correct |
22 ms |
324 KB |
Output is correct |
17 |
Correct |
20 ms |
324 KB |
Output is correct |
18 |
Correct |
14 ms |
204 KB |
Output is correct |
19 |
Correct |
16 ms |
204 KB |
Output is correct |
20 |
Correct |
17 ms |
308 KB |
Output is correct |
21 |
Correct |
15 ms |
204 KB |
Output is correct |
22 |
Correct |
17 ms |
204 KB |
Output is correct |
23 |
Correct |
6 ms |
316 KB |
Output is correct |
24 |
Correct |
13 ms |
204 KB |
Output is correct |
25 |
Correct |
14 ms |
316 KB |
Output is correct |
26 |
Correct |
15 ms |
204 KB |
Output is correct |
27 |
Correct |
16 ms |
204 KB |
Output is correct |
28 |
Correct |
19 ms |
320 KB |
Output is correct |
29 |
Correct |
14 ms |
204 KB |
Output is correct |
30 |
Correct |
14 ms |
316 KB |
Output is correct |
31 |
Correct |
18 ms |
320 KB |
Output is correct |
32 |
Correct |
20 ms |
308 KB |
Output is correct |
33 |
Correct |
22 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
21 ms |
328 KB |
Output is correct |
15 |
Correct |
22 ms |
320 KB |
Output is correct |
16 |
Correct |
22 ms |
324 KB |
Output is correct |
17 |
Correct |
20 ms |
324 KB |
Output is correct |
18 |
Correct |
14 ms |
204 KB |
Output is correct |
19 |
Correct |
16 ms |
204 KB |
Output is correct |
20 |
Correct |
17 ms |
308 KB |
Output is correct |
21 |
Correct |
15 ms |
204 KB |
Output is correct |
22 |
Correct |
17 ms |
204 KB |
Output is correct |
23 |
Correct |
6 ms |
316 KB |
Output is correct |
24 |
Correct |
13 ms |
204 KB |
Output is correct |
25 |
Correct |
14 ms |
316 KB |
Output is correct |
26 |
Correct |
15 ms |
204 KB |
Output is correct |
27 |
Correct |
16 ms |
204 KB |
Output is correct |
28 |
Correct |
19 ms |
320 KB |
Output is correct |
29 |
Correct |
14 ms |
204 KB |
Output is correct |
30 |
Correct |
14 ms |
316 KB |
Output is correct |
31 |
Correct |
18 ms |
320 KB |
Output is correct |
32 |
Correct |
20 ms |
308 KB |
Output is correct |
33 |
Correct |
22 ms |
204 KB |
Output is correct |
34 |
Execution timed out |
2015 ms |
352 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
308 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
308 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
21 ms |
328 KB |
Output is correct |
15 |
Correct |
22 ms |
320 KB |
Output is correct |
16 |
Correct |
22 ms |
324 KB |
Output is correct |
17 |
Correct |
20 ms |
324 KB |
Output is correct |
18 |
Correct |
14 ms |
204 KB |
Output is correct |
19 |
Correct |
16 ms |
204 KB |
Output is correct |
20 |
Correct |
17 ms |
308 KB |
Output is correct |
21 |
Correct |
15 ms |
204 KB |
Output is correct |
22 |
Correct |
17 ms |
204 KB |
Output is correct |
23 |
Correct |
6 ms |
316 KB |
Output is correct |
24 |
Correct |
13 ms |
204 KB |
Output is correct |
25 |
Correct |
14 ms |
316 KB |
Output is correct |
26 |
Correct |
15 ms |
204 KB |
Output is correct |
27 |
Correct |
16 ms |
204 KB |
Output is correct |
28 |
Correct |
19 ms |
320 KB |
Output is correct |
29 |
Correct |
14 ms |
204 KB |
Output is correct |
30 |
Correct |
14 ms |
316 KB |
Output is correct |
31 |
Correct |
18 ms |
320 KB |
Output is correct |
32 |
Correct |
20 ms |
308 KB |
Output is correct |
33 |
Correct |
22 ms |
204 KB |
Output is correct |
34 |
Execution timed out |
2015 ms |
352 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |