답안 #537864

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
537864 2022-03-15T17:51:54 Z michao Monochrome Points (JOI20_monochrome) C++14
35 / 100
2000 ms 4328 KB
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int MAX=2e5+5;
vi b,w;
char s[MAX*2];
int ans=0;
int n;

int ile(int x,int y){
	if (x>y)swap(x,y);
	int between=y-x-1;
	return min(n*2-2-between,between);
}

int f(int shift){
	int sum=0;
	assert(sz(b)==sz(w) && sz(b)==n);
	for (int i=0;i<n;i++){
		int x=b[i];
		int y=w[(i+shift)%n];
		//if (shift==1)cout<<"TERAZ "<<x<<" "<<y<<" "<<ile(x,y)<<"\n";
		sum+=ile(x,y);
	}
	return sum/2;
}
int32_t main(){
  BOOST;
  cin>>n;
  for (int i=0;i<n*2;i++){
		cin>>s[i];
		if (s[i]=='B')b.pb(i);
		else w.pb(i);
  }
  
  for (int i=0;i<=n-1;i++){
		ans=max(ans,f(i));
  }
  cout<<ans;
  return 0; 
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 324 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 328 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 328 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 328 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 324 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 328 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 328 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 328 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 20 ms 340 KB Output is correct
35 Correct 20 ms 328 KB Output is correct
36 Correct 20 ms 392 KB Output is correct
37 Correct 21 ms 340 KB Output is correct
38 Correct 19 ms 392 KB Output is correct
39 Correct 19 ms 324 KB Output is correct
40 Correct 16 ms 460 KB Output is correct
41 Correct 15 ms 392 KB Output is correct
42 Correct 19 ms 392 KB Output is correct
43 Correct 19 ms 384 KB Output is correct
44 Correct 18 ms 388 KB Output is correct
45 Correct 17 ms 384 KB Output is correct
46 Correct 22 ms 340 KB Output is correct
47 Correct 20 ms 332 KB Output is correct
48 Correct 21 ms 396 KB Output is correct
49 Correct 19 ms 364 KB Output is correct
50 Correct 22 ms 340 KB Output is correct
51 Correct 22 ms 340 KB Output is correct
52 Correct 22 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 2 ms 324 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 328 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 328 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 328 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 20 ms 340 KB Output is correct
35 Correct 20 ms 328 KB Output is correct
36 Correct 20 ms 392 KB Output is correct
37 Correct 21 ms 340 KB Output is correct
38 Correct 19 ms 392 KB Output is correct
39 Correct 19 ms 324 KB Output is correct
40 Correct 16 ms 460 KB Output is correct
41 Correct 15 ms 392 KB Output is correct
42 Correct 19 ms 392 KB Output is correct
43 Correct 19 ms 384 KB Output is correct
44 Correct 18 ms 388 KB Output is correct
45 Correct 17 ms 384 KB Output is correct
46 Correct 22 ms 340 KB Output is correct
47 Correct 20 ms 332 KB Output is correct
48 Correct 21 ms 396 KB Output is correct
49 Correct 19 ms 364 KB Output is correct
50 Correct 22 ms 340 KB Output is correct
51 Correct 22 ms 340 KB Output is correct
52 Correct 22 ms 340 KB Output is correct
53 Execution timed out 2088 ms 4328 KB Time limit exceeded
54 Halted 0 ms 0 KB -