Submission #1062344

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10623442024-08-17 03:37:18bachhoangxuanSuperpozicija (COCI22_superpozicija)C++17
110 / 110
21 ms5076 KiB
#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){
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...