# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
516345 | 2022-01-21T07:15:59 Z | qwerasdfzxcl | Monochrome Points (JOI20_monochrome) | C++14 | 2000 ms | 300 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); 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; } vector<int> P; P.push_back(0); for (int i=1;i<=n/2;i++) P.push_back(i); int ans = 0; do{ E.clear(); for (int i=1;i<=n/2;i++) E.emplace_back(B[i], W[P[i]]); ans = max(ans, calc()); }while(next_permutation(P.begin()+1, P.end())); printf("%d\n", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 300 KB | Output is correct |
9 | Correct | 7 ms | 300 KB | Output is correct |
10 | Correct | 6 ms | 300 KB | Output is correct |
11 | Correct | 4 ms | 204 KB | Output is correct |
12 | Correct | 6 ms | 204 KB | Output is correct |
13 | Correct | 7 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 300 KB | Output is correct |
9 | Correct | 7 ms | 300 KB | Output is correct |
10 | Correct | 6 ms | 300 KB | Output is correct |
11 | Correct | 4 ms | 204 KB | Output is correct |
12 | Correct | 6 ms | 204 KB | Output is correct |
13 | Correct | 7 ms | 204 KB | Output is correct |
14 | Execution timed out | 2071 ms | 204 KB | Time limit exceeded |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 300 KB | Output is correct |
9 | Correct | 7 ms | 300 KB | Output is correct |
10 | Correct | 6 ms | 300 KB | Output is correct |
11 | Correct | 4 ms | 204 KB | Output is correct |
12 | Correct | 6 ms | 204 KB | Output is correct |
13 | Correct | 7 ms | 204 KB | Output is correct |
14 | Execution timed out | 2071 ms | 204 KB | Time limit exceeded |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 300 KB | Output is correct |
9 | Correct | 7 ms | 300 KB | Output is correct |
10 | Correct | 6 ms | 300 KB | Output is correct |
11 | Correct | 4 ms | 204 KB | Output is correct |
12 | Correct | 6 ms | 204 KB | Output is correct |
13 | Correct | 7 ms | 204 KB | Output is correct |
14 | Execution timed out | 2071 ms | 204 KB | Time limit exceeded |
15 | Halted | 0 ms | 0 KB | - |