Submission #1283952

#TimeUsernameProblemLanguageResultExecution timeMemory
1283952am_aadvikMonochrome Points (JOI20_monochrome)C++20
25 / 100
2096 ms580 KiB
#include <iostream>
#include<vector>
#include<algorithm>
#define int long long
using namespace std;

int32_t main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	string s; cin >> s;
	vector<int> w, b;
	for (int i = 0; i < (n + n); ++i)
		if (s[i] == 'W')
			w.push_back(i);
		else
			b.push_back(i);
	int mx = 0;
	for (int k = 0; k < n; ++k) {
		int ans = 0;
		vector<pair<int, int>> res;
		for (int i = 0; i < n; ++i)
			res.push_back({ w[i], b[(i + k) % n] });
		for (auto x : res)
			for (auto y : res)
				if (x != y) {
					int l1 = x.first, r1 = x.second;
					int l2 = y.first, r2 = y.second;
					vector<pair<int, int>> a;
					a.push_back({ l1, 0 }), a.push_back({ r1, 0 });
					a.push_back({ l2, 1 }), a.push_back({ r2, 1 });
					sort(a.begin(), a.end());
					bool ok = 1;
					for (int i = 1; i < 4; ++i)
						ok &= (a[i].second != a[i - 1].second);
					ans += ok;
				}
		mx = max(ans / 2, mx);
	}
	cout << mx;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...