QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#664486#7894. Many Many HeadsdyfhpuWA 20ms3628kbC++171.7kb2024-10-21 20:52:392024-10-21 20:52:43

Judging History

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

  • [2024-10-21 20:52:43]
  • 评测
  • 测评结果:WA
  • 用时:20ms
  • 内存:3628kb
  • [2024-10-21 20:52:39]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> PII;
const int N = 110;
int a[N];
int st[N];
void solve()
{
    string s;cin>>s;
    s=" "+s;
    int  cnt1=0,cnt2=0;
    map<int,int> mp1,mp2;
    mp1[0]=0;mp2[0]=0;
    int cnt=1;
    for(int i=1;i<s.size();i++) {
        if(s[i]==')') s[i]='(';
        if(s[i]==']') s[i]='[';
        if(s[i]=='(') {
            if(s[i]!=s[i-1]&&(cnt1%2!=0||cnt2%2!=0)) {
                if(mp1[cnt-1]%2==1&&mp2[cnt]%2!=1)
                {
                cnt--;
                mp1[cnt]++;
                }
                else {
                cnt++;
                mp1[cnt]++;
            } 
            }
            else {
                mp1[cnt]++;
            }
            cnt1++;
        //    cout<<i<<' '<<cnt<<' '<<mp1[cnt]<<endl;
            if(mp1[cnt]>2) {
                cout<<"No"<<endl;
                return ;
            }
        }
        else {
            if(s[i]!=s[i-1]&&(cnt1%2!=0||cnt2%2!=0)){
                if(mp2[cnt-1]%2==1&&mp1[cnt]%2!=1){
                cnt--;
                mp2[cnt]++;
                }
                else {
                cnt++;
                mp2[cnt]++;
                }
            }
            else mp2[cnt]++;
            if(mp2[cnt]>2) {
                cout<<"No"<<endl;
                return ;
            }
            cnt2++;
        }
    //    cout<<i<<' '<<cnt<<endl;
    }
    if(cnt1%2!=0||cnt2%2!=0) {
    	cout<<"No"<<endl;
    	return ;
	} 
    cout<<"Yes"<<endl;
    return ;
}
int main()
{
    int t = 1;
    cin >> t;
    
    while (t--)
        solve();
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3564kb

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

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: 20ms
memory: 3628kb

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
No
Yes
Yes
No
No
No
Yes
No
No
No
No
Yes
No
No
No
Yes
Yes
No
No
Yes
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No...

result:

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