답안 #427945

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
427945 2021-06-15T05:47:16 Z cfalas Monochrome Points (JOI20_monochrome) C++14
0 / 100
1 ms 204 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;
	FORi(off,n/4-2, n/4+3){
		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;
}
# 결과 실행 시간 메모리 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 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 Incorrect 1 ms 204 KB Output isn't correct
12 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 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 Incorrect 1 ms 204 KB Output isn't correct
12 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 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 Incorrect 1 ms 204 KB Output isn't correct
12 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 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 Incorrect 1 ms 204 KB Output isn't correct
12 Halted 0 ms 0 KB -