# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
516350 | 2022-01-21T07:47:16 Z | qwerasdfzxcl | Monochrome Points (JOI20_monochrome) | C++14 | 1 ms | 204 KB |
#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); 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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Incorrect | 0 ms | 204 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Incorrect | 0 ms | 204 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Incorrect | 0 ms | 204 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Incorrect | 0 ms | 204 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |