QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#612779#7894. Many Many Headswzxtsl#WA 0ms3544kbC++23845b2024-10-05 12:53:242024-10-05 12:53:36

Judging History

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

  • [2024-10-05 12:53:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3544kb
  • [2024-10-05 12:53:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define int long long
int n,m;
int getss(char c){
    if(c=='('||c==')')return 0;
    if(c=='['||c==']')return 1;
}

void solve(){
    cin>>n;
    string s;
    for(int i=1;i<=n;i++){
        cin>>s;
        if(s.length()%2==1){
            cout<<"No"<<endl;
            continue;
        }
        int tp=getss(s[0]);int fl=0;
        for(int j=1;j<s.length()/2;j++){
            if(tp==getss(s[j])^1) {tp=tp^1;continue;}
            else {
                cout<<"No"<<endl;
                fl=1;
                break;

            }

        }
        if(!fl)
        cout<<"Yes"<<endl;
    }
   
}
signed main(){
    fast;
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3544kb

input:

6
))
((()
[()]
()[()]()
([()])
([])([])

output:

Yes
No
Yes
No
Yes
No

result:

ok 6 token(s): yes count is 3, no count is 3

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3528kb

input:

2
(([([[([
]]))])]])]

output:

No
No

result:

wrong answer expected YES, found NO [1st token]