QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#613338#4212. BracketsKFCCompile Error//C++98836b2024-10-05 13:56:002024-10-05 13:57:42

Judging History

你现在查看的是最新测评结果

  • [2024-10-05 13:57:42]
  • 评测
  • [2024-10-05 13:56:00]
  • 提交

answer

// Hydro submission #6700d4a255b5e82bc0182886@1728107759602
#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;
}

详细

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);
      |         ~~~~~^~~~~~~~~~