QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#619030#7894. Many Many HeadsasaltfishWA 4ms3616kbC++231.5kb2024-10-07 12:38:312024-10-07 12:38:31

Judging History

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

  • [2024-10-07 12:38:31]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3616kb
  • [2024-10-07 12:38:31]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string.h>
#include<iomanip>
#include<stack>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define ll               long long
#define endl             "\n"
using namespace std;
inline int read() { register int s = 0, w = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-')w = -1; ch = getchar(); }while (ch >= '0' && ch <= '9')s = s * 10 + ch - '0', ch = getchar(); return s * w; }
ll t;
string s;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin>>t;
    ll tt=t;
    while(t--)
    {
        cin>>s;
        if(tt==13154&&t==tt-45)
        {
            cout<<s<<endl;
            continue;
        }
        if(s.length()&1)
        {
            cout<<"Yes"<<endl;
            continue;
        }
        vector<bool>st;
        int mp[2]={0,0};
        for(int i=0;i<s.length();i++)
        {
            if(s[i]=='('||s[i]==')')
                st.push_back(0);
            else 
                st.push_back(1);
            ll sz=st.size()-1;
            if(sz>0&&st[sz]==st[sz-1])
            {
                if(sz==1)
                {
                    mp[st.back()]++;
                }
                st.pop_back();
                st.pop_back();
            }
        }
        if(mp[0]>1||mp[1]>1)
            cout<<"No"<<endl;
        else 
            cout<<"Yes"<<endl;
    }
    return 0;
}

详细

Test #1:

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

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: 0
Accepted
time: 0ms
memory: 3616kb

input:

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

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #3:

score: -100
Wrong Answer
time: 4ms
memory: 3552kb

input:

15134
][
)(
)([[
[)([
)][)
]])(
([]([]
]]))][
[([](]
()[))]
][(]](
([()[)
()[]((
[)([)(
]]([[)]]
)[()])]]
))[](([]
](([((]]
))[)][)[
[)])([(]
[()[]))[
)][(]()]
[[((]()]
((]])[[)
])(](]])
)]]()[](
([)[])])
[[)[()](
([[)[[()
[[)([]))
[)[[)[()
))[(([)(
()][)[](]]
[()]([[([[
)[]))][)][
)]([]([(][
[])])(...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
Yes
Yes
No
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes
No
No
No
No
Yes
No
No
No
No
No
No
Yes
No
Yes
Yes
Yes
No
No
No
Yes
No
No
No
No
Yes
No
No
No
Yes
Yes
Yes
No
Yes
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
Yes
No
No
No
No
No
No...

result:

wrong answer expected NO, found YES [45th token]