QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#664406#7894. Many Many HeadsdyfhpuWA 14ms3864kbC++171.6kb2024-10-21 20:28:542024-10-21 20:28:55

Judging History

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

  • [2024-10-21 20:28:55]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3864kb
  • [2024-10-21 20:28:54]
  • 提交

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]>=4) {
                cout<<"No"<<endl;
                return ;
            }
        }
        else if(s[i]=='['){
            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]>=4) {
                cout<<"No"<<endl;
                return ;
            }
            cnt2++;
        }
    //    cout<<i<<' '<<cnt<<endl;
    }
    cout<<"Yes"<<endl;
    return ;
}
int main()
{
    int t = 1;
    cin >> t;
    
    while (t--)
        solve();
    
    return 0;
}

详细

Test #1:

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

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

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: 14ms
memory: 3864kb

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]