QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#618780#7894. Many Many Headssw7777WA 0ms3844kbC++171.6kb2024-10-07 10:12:082024-10-07 10:12:09

Judging History

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

  • [2024-10-07 10:12:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3844kb
  • [2024-10-07 10:12:08]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf 0x3f3f3f3f3f3f3f3f
#define pii pair<int, int>
#define endl '\n'
const int N=1e6+10;
const int N1=1e3+10;
const int mod=1e9+7;
void Atomatic_AC_machine(){
    string s;cin>>s;
    s=" "+s;
    int l=1,r=s.size()-1;
    string s1=s;
    while(l<r){
        // cout<<"1"<<s[l]<<" "<<s[r]<<endl;
        if(s[l]=='('||s[l]==')') s[l]='(',s[r]=')';
        else s[l]='[',s[r]=']';
        l++,r--;
    }
    //cout<<s<<endl;
    int ls=0,lb=0;
    stack<int> st;
    int lst=0;
    for(int i=1;i<s1.size();i++){
        if(s1[i]=='('||s1[i]==')'){
            if(ls&&(lst==1||!lb)){
                st.push(')');
                ls--;
            }else{
                st.push('(');
                ls++;
            }
            lst=1;
        }else{
            if(lb&&(lst==2||!ls)){
                st.push(']');
                lb--;
            }else{
                st.push('[');
                lb++;
            }
            lst=2;
        }
    }
    bool flag=0;
    if(ls==0&&lb==0){
        string tmp="";
        while(st.size()){
            tmp.push_back(st.top());
            st.pop();
        }
        tmp.push_back(' ');
        reverse(tmp.begin(),tmp.end());
        if(tmp!=s) flag=1;
        //cout<<tmp<<endl;
    }
    cout<<(flag?"No":"Yes")<<endl;
}   
signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    cin>>t;
    while(t--){
        Atomatic_AC_machine();
    }
    return 0;
}

详细

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: 3844kb

input:

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

output:

Yes
Yes

result:

wrong answer expected NO, found YES [2nd token]