# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
898624 | AdamGS | Monochrome Points (JOI20_monochrome) | C++17 | 2060 ms | 544 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n;
string s;
cin >> n >> s;
ll b=0, w=n, p=0;
rep(i, 2*n) {
if(s[i]=='B') ++b; else --w;
if(b==w) {
p=i;
break;
}
}
ll ans=0;
for(int p=-1; p<2*n; ++p) {
vector<pair<int,int>>V;
int l=2*n-1;
bool ok=true;
for(int i=p; i>=0; --i) if(s[i]=='B') {
while(l>=0 && s[l]=='B') --l;
if(i>l) {
ok=false;
break;
}
V.pb({i, l});
--l;
}
if(!ok) continue;
l=0;
for(int i=p+1; i<2*n; ++i) if(s[i]=='B') {
while(l<2*n && s[l]=='B') ++l;
if(l>i) {
ok=false;
break;
}
V.pb({l, i});
++l;
}
if(!ok) continue;
ll sum=0;
rep(i, V.size()) rep(j, i) if((V[i].st<V[j].st && V[j].st<V[i].nd && V[i].nd<V[j].nd)
|| (V[j].st<V[i].st && V[i].st<V[j].nd && V[j].nd<V[i].nd)) {
++sum;
}
ans=max(ans, sum);
}
cout << ans << '\n';
}
컴파일 시 표준 에러 (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... |