QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#613314 | #4212. Brackets | KFC | Compile Error | / | / | C++98 | 836b | 2024-10-05 13:54:50 | 2024-10-05 13:55:17 |
Judging History
answer
// Hydro submission #6700d4a255b5e82bc0182886@1728107689634
#include<bits/stdc++.h>
using namespace std;
int n,a[2000001],pos[2000001],nxt[2000001];
char ans[2000002];
int main(){
scanf("%d",&n);
for(int i=1;i<=n*2;i++){
scanf("%d",a+i);
nxt[pos[a[i]]]=i,pos[a[i]]=i;
ans[i]=')';
}
set<int> S;
for(int i=1;i<=n;i++)S.insert(i*2-1);
for(int i=1;i<=n*2;i++){
if(!nxt[i])continue;
auto it=S.lower_bound(nxt[i]);
if(it==S.end())continue;
S.erase(it),it=S.lower_bound(i);
if(it==S.end())continue;
S.erase(it),ans[i]=ans[nxt[i]]='(';
}
int cnt=0;
for(int i=1;i<=n*2;i++)
if(ans[i]=='(')cnt++;
else if(cnt)cnt--;
else return puts("("),0;
printf("%s\n",ans+1);
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:19:14: error: ‘it’ does not name a type; did you mean ‘int’? 19 | auto it=S.lower_bound(nxt[i]); | ^~ | int answer.code:20:12: error: ‘it’ was not declared in this scope; did you mean ‘i’? 20 | if(it==S.end())continue; | ^~ | i answer.code:21:17: error: ‘it’ was not declared in this scope; did you mean ‘i’? 21 | S.erase(it),it=S.lower_bound(i); | ^~ | i answer.code:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d",&n); | ~~~~~^~~~~~~~~ answer.code:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | scanf("%d",a+i); | ~~~~~^~~~~~~~~~