# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1159257 | Der_Vlapos | Monochrome Points (JOI20_monochrome) | C++20 | 2095 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define f first
#define s second
#define all(v) v.begin(), v.end()
// #define int ll
const int mod1 = 1e9 + 7;
const int mod2 = 998244353;
int dp1[1003][1003];
int dp2[1003][1003];
struct test
{
void solve()
{
int n;
cin >> n;
vector<int> b, w;
for (int i = 0; i < 2 * n; ++i)
{
char x;
cin >> x;
if (x == 'B')
b.pb(i);
else
w.pb(i);
}
int res = 0;
for (int k = 0; k < n; ++k)
{
vector<pii> segs;
for (int i = 0; i < n; ++i)
segs.pb({min(b[i], w[(i + k) % n]), max(b[i], w[(i + k) % n])});
sort(all(segs));
int cnt = 0;
for (int i = 0; i < n; ++i)
for (int j = i + 1; j < n; ++j)
{
cnt += (segs[j].f < segs[i].s and segs[i].s < segs[j].s);
}
res = max(res, cnt);
}
cout << res << "\n";
}
};
main()
{
test t;
t.solve();
}
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... |