답안 #683896

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
683896 2023-01-19T15:01:55 Z alvingogo Monochrome Points (JOI20_monochrome) C++14
35 / 100
2000 ms 2656 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define AquA cin.tie(0);ios_base::sync_with_stdio(0);
#define fs first
#define sc second
#define p_q priority_queue
#define int long long
using namespace std;

signed main(){
    AquA;
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans=1e14;
    vector<int> a,b;
    int pre=0,mx=0,k=0;
    for(int i=0;i<n;i++){
        if(s[i]=='B'){
            a.push_back(i);
            pre++;
        }
        if(s[i+n]=='W'){
            b.push_back(i);
            pre--;
        }
        if(pre<mx){
            mx=pre;
            k=i+1;
        }
    }
    int g=a.size();
    for(int i=0;i<g;i++){
        int xx=0;
        for(int j=0;j<g;j++){
            xx+=min(abs(b[j]-a[(i+j)%g]),n-abs(b[j]-a[(i+j)%g]));
        }
        ans=min(ans,xx);
    }
    if(g==0){
        ans=0;
    }
    cout << n*(n-1)/2-ans << "\n";
    return 0;
}

Compilation message

monochrome.cpp: In function 'int main()':
monochrome.cpp:18:20: warning: variable 'k' set but not used [-Wunused-but-set-variable]
   18 |     int pre=0,mx=0,k=0;
      |                    ^
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 324 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 316 KB Output is correct
26 Correct 0 ms 320 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 1 ms 320 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 324 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 316 KB Output is correct
26 Correct 0 ms 320 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 1 ms 320 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 5 ms 340 KB Output is correct
35 Correct 5 ms 340 KB Output is correct
36 Correct 5 ms 348 KB Output is correct
37 Correct 5 ms 432 KB Output is correct
38 Correct 7 ms 316 KB Output is correct
39 Correct 5 ms 324 KB Output is correct
40 Correct 4 ms 340 KB Output is correct
41 Correct 4 ms 316 KB Output is correct
42 Correct 6 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 4 ms 340 KB Output is correct
45 Correct 16 ms 392 KB Output is correct
46 Correct 17 ms 340 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 6 ms 340 KB Output is correct
49 Correct 3 ms 340 KB Output is correct
50 Correct 19 ms 340 KB Output is correct
51 Correct 0 ms 320 KB Output is correct
52 Correct 5 ms 352 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 324 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 316 KB Output is correct
26 Correct 0 ms 320 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 320 KB Output is correct
31 Correct 1 ms 320 KB Output is correct
32 Correct 0 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 5 ms 340 KB Output is correct
35 Correct 5 ms 340 KB Output is correct
36 Correct 5 ms 348 KB Output is correct
37 Correct 5 ms 432 KB Output is correct
38 Correct 7 ms 316 KB Output is correct
39 Correct 5 ms 324 KB Output is correct
40 Correct 4 ms 340 KB Output is correct
41 Correct 4 ms 316 KB Output is correct
42 Correct 6 ms 340 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 4 ms 340 KB Output is correct
45 Correct 16 ms 392 KB Output is correct
46 Correct 17 ms 340 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 6 ms 340 KB Output is correct
49 Correct 3 ms 340 KB Output is correct
50 Correct 19 ms 340 KB Output is correct
51 Correct 0 ms 320 KB Output is correct
52 Correct 5 ms 352 KB Output is correct
53 Execution timed out 2069 ms 2656 KB Time limit exceeded
54 Halted 0 ms 0 KB -