제출 #1326096

#제출 시각아이디문제언어결과실행 시간메모리
1326096joacruMonochrome Points (JOI20_monochrome)C++20
4 / 100
2094 ms420 KiB
#include <iostream>
#include <algorithm>
#include <vector>

#define forn(i,n) for(int i=0;i<(int)n;++i)
#define fori(i,a,n) for(int i=a;i<(int)n;++i)

#define DBG(a) cerr<<#a<<" = "<<a<<endl
#define DBGA(a) cerr<<#a<<" = "<<a<<", ";
#define DBG2(a,b) do{DBGA(a)DBG(b);}while(0)
#define DBG3(a,b,c) do{DBGA(a)DBGA(b)DBG(c);}while(0)
#define DBG4(a,b,c,d) do{DBGA(a)DBGA(b)DBGA(c)DBG(d);}while(0)
#define SZ(v) (int)v.size()
#define ALL(v) v.begin(),v.end()

using namespace std;

template<typename T>
ostream &operator<<(ostream &os, vector<T> &v){
	os<<"[";
	forn(i,SZ(v)){
		if(i) os<<", ";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	#ifdef LOCAL
	freopen("input.in", "r", stdin);
	#endif
	
	int n, ans = 0;
	string s;
	cin>>n>>s;
	
	vector<int> a, b, ps(n);
	forn(i,2*n){
		if(s[i] == 'W') a.push_back(i);
		else b.push_back(i);
	}
	forn(i,n){
		ps[i] = i;
	}
	
	do{
		int cnt = 0;
		vector<pair<int,int>> rs;
		forn(i,n){
			int x = a[i], y = b[ps[i]];
			if(x > y) swap(x, y);
			for(auto [u, v] : rs){
			int check = 0;
				if(u > x && u < y) check |= 1;
				else check |= 2;
				if(v > x && v < y) check |= 1;
				else check |= 2;
				if(check == 3) ++cnt;
				//~ DBG(cnt);
			}
			rs.push_back({x, y});
			//~ DBG2(x, y);
		}
		//~ DBG(ans);
		//~ DBG("=============");
		ans = max(ans, cnt);
	} while(next_permutation(ALL(ps)));
	
	cout<<ans<<"\n";
	
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...