# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
293818 | BThero | Monochrome Points (JOI20_monochrome) | C++17 | 2025 ms | 384 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 = 600 + 5;
char s[MAXN];
int n;
void solve() {
scanf("%d", &n);
scanf("%s", s + 1);
vector<int> A, B;
for (int i = 1; i <= 2 * n; ++i) {
if (s[i] == 'B') {
A.pb(i);
}
else {
B.pb(i);
}
}
int ans = 0;
do {
int cur = 0;
for (int i = 0; i < n; ++i) {
int lc = A[i], rc = B[i];
if (lc > rc) {
swap(lc, rc);
}
for (int j = i + 1; j < n; ++j) {
int ln = A[j], rn = B[j];
if (ln > rn) {
swap(ln, rn);
}
if (ln < lc && lc < rn && rn < rc) {
++cur;
}
else if (lc < ln && ln < rc && rc < rn) {
++cur;
}
}
}
ans = max(ans, cur);
}
while (next_permutation(all(B)));
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... |