# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
516349 | qwerasdfzxcl | Monochrome Points (JOI20_monochrome) | C++14 | 2065 ms | 320 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.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
char a[400400];
int B[200200], W[200200];
vector<pair<int, int>> E;
int calc(){
for (auto &p:E) if (p.first > p.second) swap(p.first, p.second);
sort(E.begin(), E.end());
int ret = 0;
for (int i=0;i<(int)E.size();i++){
//printf("%d %d\n", E[i].first, E[i].second);
for (int j=i+1;j<(int)E.size();j++) if (E[j].first < E[i].second && E[i].second < E[j].second) ret++;
}
//printf("\n");
return ret;
}
int main(){
int n;
scanf("%d", &n);
scanf("%s", a+1);
n *= 2;
int cb = 0, cw = 0;
for (int i=1;i<=n;i++){
if (a[i]=='B') B[++cb] = i;
else W[++cw] = i;
}
int ans = 0;
for (int z=1;z<=n/2;z++){
E.clear();
int pt = z;
for (int i=1;i<=n/2;i++){
E.emplace_back(B[i], W[pt]);
pt++;
if (pt>n/2) pt -= n/2;
}
ans = max(ans, calc());
}
printf("%d\n", ans);
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... |