# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1062344 | bachhoangxuan | Superpozicija (COCI22_superpozicija) | C++17 | 21 ms | 5076 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+5;
int n,d[maxn],nxt[maxn],f[maxn],val[maxn];
char c[maxn];
void solve(){
cin >> n;
for(int i=1;i<=2*n;i++){
cin >> c[i];
nxt[i]=val[i]=f[i]=0;
}
for(int i=1;i<=n;i++){
int a,b;cin >> a >> b;
if(c[a]==c[b]){
if(c[a]=='(') d[i]=0,val[a]++;
else d[i]=1,val[b]--;
}
else{
nxt[a]=b,f[a]=i;
if(c[a]=='(') d[i]=1,val[b]--;
else d[i]=0,val[a]--;
}
}
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
int cnt=0;
for(int i=1;i<=2*n;i++){
if(f[i]) pq.push({nxt[i],f[i]});
cnt+=val[i];
if(cnt<0){
# | 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... |