# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
516349 | qwerasdfzxcl | Monochrome Points (JOI20_monochrome) | C++14 | 2065 ms | 320 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |