QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#317317#7894. Many Many HeadswullaaaCompile Error//C++14693b2024-01-28 20:29:062024-01-28 20:29:07

Judging History

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

  • [2024-01-28 20:29:07]
  • 评测
  • [2024-01-28 20:29:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,stk[N],top,cnt;
char s[N];
int main(){
    int T; scanf("%d",&T);
    while(T--){
        scanf("%s",s+1),n=strlen(s+1),cnt=top=0;
        bool flag=false,f=false; int las=-1;
        for(int i=1;i<=n;++i){
            int t=(s[i]=='('||s[i]==')');
            if(top&&stk[top]==t) flag=true,--top;
            else if(!top){
                if(t==las){ f=true; break; 
                las=t,flag=false,++cnt,stk[++top]=t;
            }else if(flag){ f=true; break; }
            else stk[++top]=t;
            if(cnt>2){ f=true; break; }
        }
        puts(f?"No":"Yes");
    }

    return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:25:2: error: expected ‘}’ at end of input
   25 | }
      |  ^
answer.code:6:11: note: to match this ‘{’
    6 | int main(){
      |           ^
answer.code:7:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |     int T; scanf("%d",&T);
      |            ~~~~~^~~~~~~~~
answer.code:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%s",s+1),n=strlen(s+1),cnt=top=0;
      |         ~~~~~^~~~~~~~~~