Submission #427944

# Submission time Handle Problem Language Result Execution time Memory
427944 2021-06-15T05:46:29 Z cfalas Monochrome Points (JOI20_monochrome) C++14
25 / 100
2000 ms 460 KB
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define INF 10000000
#define MOD 1000000007
#define MID ((l+r)/2)
#define HASHMOD 2305843009213693951
#define ll long long
#define ull unsigned long long
#define F first
#define S second
typedef pair<ll, ll> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef map<int, int> mii;

#define EPS 1e-6
#define FOR(i,n) for(int i=0;i<((int)(n));i++)
#define FORi(i,a,b) for(int i=((int)(a));i<((int)(b));i++)
#define FOA(v, a) for(auto v : a)

int t, n;
vi a, b;

int dist(int a, int b){
	return min(abs(a-b), abs(a-b+n));
}

int main(){
	cin>>n;
	string s;
	cin>>s;
	n*=2;
	set<int> w, b;
	FOR(i,n){
		if(s[i]=='W') w.insert(i);
		else b.insert(i);
	}

	vi c(n);
	/*
	FOR(i,n){
		if(s[i]=='B'){
			int opp = (i+n/2)%n;

			auto l1_it = w.lower_bound(opp);
			if(l1_it==w.end()) l1_it = w.begin();
			int d1 = *l1_it;

			auto l2_it = (w.upper_bound(opp));
			if(l2_it==w.begin()) l2_it = w.end();
			int d2 = *(--l2_it);

			int ans=d2;
			if(dist(d1,opp) > dist(opp,d2)){
				ans = d2;
			}
			else{
				ans = d1;
			}
			cout<<i<<" "<<d1<<" "<<d2<<" "<<ans<<endl;
			w.erase(ans);
			assert(ans!=i);
			c[i] = ans;
			c[ans] = i;
		}
	}*/
	int bans=0;
	FOR(off,n/2){
		auto it = b.begin();
		FOR(i,off) it++;
		FOA(v,w){
			c[v] = *it;
			c[*it] = v;
			//cout<<v<<" "<<*it<<endl;
			it++;
			if(it==b.end()) it = b.begin();
		}
		int ans=0;
		FOR(i,n){
			if(s[i]=='B')
			FORi(j,min(i,c[i])+1, max(i,c[i])){
				if(c[j]>max(i,c[i]) || c[j]<min(i,c[i])) ans++;
			}
		}
		bans = max(bans, ans);
	}
	cout<<bans/2<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 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 1 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 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 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 1 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 1 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 37 ms 204 KB Output is correct
15 Correct 38 ms 324 KB Output is correct
16 Correct 37 ms 204 KB Output is correct
17 Correct 36 ms 204 KB Output is correct
18 Correct 18 ms 324 KB Output is correct
19 Correct 22 ms 328 KB Output is correct
20 Correct 25 ms 204 KB Output is correct
21 Correct 22 ms 204 KB Output is correct
22 Correct 26 ms 292 KB Output is correct
23 Correct 12 ms 204 KB Output is correct
24 Correct 25 ms 324 KB Output is correct
25 Correct 18 ms 328 KB Output is correct
26 Correct 27 ms 204 KB Output is correct
27 Correct 34 ms 304 KB Output is correct
28 Correct 40 ms 304 KB Output is correct
29 Correct 22 ms 292 KB Output is correct
30 Correct 19 ms 204 KB Output is correct
31 Correct 33 ms 324 KB Output is correct
32 Correct 34 ms 292 KB Output is correct
33 Correct 29 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 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 1 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 1 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 37 ms 204 KB Output is correct
15 Correct 38 ms 324 KB Output is correct
16 Correct 37 ms 204 KB Output is correct
17 Correct 36 ms 204 KB Output is correct
18 Correct 18 ms 324 KB Output is correct
19 Correct 22 ms 328 KB Output is correct
20 Correct 25 ms 204 KB Output is correct
21 Correct 22 ms 204 KB Output is correct
22 Correct 26 ms 292 KB Output is correct
23 Correct 12 ms 204 KB Output is correct
24 Correct 25 ms 324 KB Output is correct
25 Correct 18 ms 328 KB Output is correct
26 Correct 27 ms 204 KB Output is correct
27 Correct 34 ms 304 KB Output is correct
28 Correct 40 ms 304 KB Output is correct
29 Correct 22 ms 292 KB Output is correct
30 Correct 19 ms 204 KB Output is correct
31 Correct 33 ms 324 KB Output is correct
32 Correct 34 ms 292 KB Output is correct
33 Correct 29 ms 324 KB Output is correct
34 Execution timed out 2062 ms 460 KB Time limit exceeded
35 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 300 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 1 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 1 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 37 ms 204 KB Output is correct
15 Correct 38 ms 324 KB Output is correct
16 Correct 37 ms 204 KB Output is correct
17 Correct 36 ms 204 KB Output is correct
18 Correct 18 ms 324 KB Output is correct
19 Correct 22 ms 328 KB Output is correct
20 Correct 25 ms 204 KB Output is correct
21 Correct 22 ms 204 KB Output is correct
22 Correct 26 ms 292 KB Output is correct
23 Correct 12 ms 204 KB Output is correct
24 Correct 25 ms 324 KB Output is correct
25 Correct 18 ms 328 KB Output is correct
26 Correct 27 ms 204 KB Output is correct
27 Correct 34 ms 304 KB Output is correct
28 Correct 40 ms 304 KB Output is correct
29 Correct 22 ms 292 KB Output is correct
30 Correct 19 ms 204 KB Output is correct
31 Correct 33 ms 324 KB Output is correct
32 Correct 34 ms 292 KB Output is correct
33 Correct 29 ms 324 KB Output is correct
34 Execution timed out 2062 ms 460 KB Time limit exceeded
35 Halted 0 ms 0 KB -