#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mp make_pair
#define se second
#define fi first
using namespace std;
bool intersect(int l1, int r1, int l2, int r2)
{
if(l1 > r1)
{
swap(l1, r1);
}
if(l2 > r2)
{
swap(l2, r2);
}
if(l1 > l2)
{
swap(l1, l2);
swap(r1, r2);
}
if(r1 > l2 && r1 < r2)
return true;
return false;
}
int main()
{
int n;
cin>>n;
string S;
cin>>S;
vector <int> W, B;
for(int i = 0; i<2*n; i++)
{
if(S.at(i) == 'W')
W.push_back(i);
else
B.push_back(i);
}
int l1, l2, r1, r2, ct = 0, mi = 0;
for(int k = 0; k<n; k++)
{
ct = 0;
for(int i = 0; i<n; i++)
{
for(int j = 0; j<i; j++)
{
l1 = B[i];
l2 = B[j];
r1 = W[(i+k)%n];
r2 = W[(j+k)%n];
if(intersect(l1, r1, l2, r2))
ct++;
}
}
mi = max(ct, mi);
}
cout<<mi<<endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
72 ms |
276 KB |
Output is correct |
15 |
Correct |
75 ms |
204 KB |
Output is correct |
16 |
Correct |
76 ms |
280 KB |
Output is correct |
17 |
Correct |
69 ms |
280 KB |
Output is correct |
18 |
Correct |
54 ms |
280 KB |
Output is correct |
19 |
Correct |
57 ms |
296 KB |
Output is correct |
20 |
Correct |
58 ms |
300 KB |
Output is correct |
21 |
Correct |
50 ms |
284 KB |
Output is correct |
22 |
Correct |
53 ms |
276 KB |
Output is correct |
23 |
Correct |
20 ms |
292 KB |
Output is correct |
24 |
Correct |
53 ms |
296 KB |
Output is correct |
25 |
Correct |
45 ms |
204 KB |
Output is correct |
26 |
Correct |
52 ms |
204 KB |
Output is correct |
27 |
Correct |
59 ms |
276 KB |
Output is correct |
28 |
Correct |
69 ms |
204 KB |
Output is correct |
29 |
Correct |
56 ms |
292 KB |
Output is correct |
30 |
Correct |
51 ms |
204 KB |
Output is correct |
31 |
Correct |
74 ms |
204 KB |
Output is correct |
32 |
Correct |
79 ms |
292 KB |
Output is correct |
33 |
Correct |
76 ms |
280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
72 ms |
276 KB |
Output is correct |
15 |
Correct |
75 ms |
204 KB |
Output is correct |
16 |
Correct |
76 ms |
280 KB |
Output is correct |
17 |
Correct |
69 ms |
280 KB |
Output is correct |
18 |
Correct |
54 ms |
280 KB |
Output is correct |
19 |
Correct |
57 ms |
296 KB |
Output is correct |
20 |
Correct |
58 ms |
300 KB |
Output is correct |
21 |
Correct |
50 ms |
284 KB |
Output is correct |
22 |
Correct |
53 ms |
276 KB |
Output is correct |
23 |
Correct |
20 ms |
292 KB |
Output is correct |
24 |
Correct |
53 ms |
296 KB |
Output is correct |
25 |
Correct |
45 ms |
204 KB |
Output is correct |
26 |
Correct |
52 ms |
204 KB |
Output is correct |
27 |
Correct |
59 ms |
276 KB |
Output is correct |
28 |
Correct |
69 ms |
204 KB |
Output is correct |
29 |
Correct |
56 ms |
292 KB |
Output is correct |
30 |
Correct |
51 ms |
204 KB |
Output is correct |
31 |
Correct |
74 ms |
204 KB |
Output is correct |
32 |
Correct |
79 ms |
292 KB |
Output is correct |
33 |
Correct |
76 ms |
280 KB |
Output is correct |
34 |
Execution timed out |
2065 ms |
204 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
72 ms |
276 KB |
Output is correct |
15 |
Correct |
75 ms |
204 KB |
Output is correct |
16 |
Correct |
76 ms |
280 KB |
Output is correct |
17 |
Correct |
69 ms |
280 KB |
Output is correct |
18 |
Correct |
54 ms |
280 KB |
Output is correct |
19 |
Correct |
57 ms |
296 KB |
Output is correct |
20 |
Correct |
58 ms |
300 KB |
Output is correct |
21 |
Correct |
50 ms |
284 KB |
Output is correct |
22 |
Correct |
53 ms |
276 KB |
Output is correct |
23 |
Correct |
20 ms |
292 KB |
Output is correct |
24 |
Correct |
53 ms |
296 KB |
Output is correct |
25 |
Correct |
45 ms |
204 KB |
Output is correct |
26 |
Correct |
52 ms |
204 KB |
Output is correct |
27 |
Correct |
59 ms |
276 KB |
Output is correct |
28 |
Correct |
69 ms |
204 KB |
Output is correct |
29 |
Correct |
56 ms |
292 KB |
Output is correct |
30 |
Correct |
51 ms |
204 KB |
Output is correct |
31 |
Correct |
74 ms |
204 KB |
Output is correct |
32 |
Correct |
79 ms |
292 KB |
Output is correct |
33 |
Correct |
76 ms |
280 KB |
Output is correct |
34 |
Execution timed out |
2065 ms |
204 KB |
Time limit exceeded |
35 |
Halted |
0 ms |
0 KB |
- |