# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
293886 | BThero | Monochrome Points (JOI20_monochrome) | C++17 | 1099 ms | 512 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 300 + 5;
const int INF = (int)1e9;
char s[2 * MAXN];
int n, ans;
void solve() {
scanf("%d", &n);
scanf("%s", s);
for (int i = 0; i < 2 * n; ++i) {
vector<char> vec;
for (int j = 0; j < n; ++j) {
vec.pb(s[j]);
}
int cur = 0;
for (int j = n; j < 2 * n; ++j) {
auto it = find(all(vec), ('B' ^ 'W' ^ s[j]));
cur += (vec.end() - it - 1);
vec.erase(it);
}
ans = max(ans, cur);
rotate(s, s + 1, s + 2 * n);
}
printf("%d\n", ans);
}
int main() {
int tt = 1;
while (tt--) {
solve();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |