QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#623120#7894. Many Many HeadsL_tyWA 4ms3592kbC++171.2kb2024-10-09 10:15:192024-10-09 10:15:20

Judging History

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

  • [2024-10-09 10:15:20]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3592kb
  • [2024-10-09 10:15:19]
  • 提交

answer

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
const  int N = 1e5 + 10;
char s[N];
void solve(){
    cin >> s + 1;
    int n = strlen(s + 1);
    vector<int> v(n + 1);
    for (int i = 1;i<=n;i++){
        if(s[i]==')'||s[i]=='(')
            v[i] = 1;
        else
            v[i] = 2;
    }
    // cout << n << endl;
    int a = 0, b = 0, flag1 = 0, flag2 = 0, flag = 0;
    for (int i = 2;i<=n;i++){
       if(v[i]==v[i-1])
           flag++;
        else
            flag = 0;
        if(flag>=2){
            cout << "No" << endl;
            return;
        }
    }
    for (int i = 1;i<=n;i++){
        //cout << s[i] << " ";
        if(s[i]==')'||s[i]=='(')
           a++;
        else
            b++;
        if(a%2==0&&b%2==0){
            if(s[i]==')'||s[i]=='(')
                flag1++;
            else
                flag2++;
        }
            
       // cout << a << " " << b << endl;
    }
    if(flag1<=1&&flag2<=1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
signed main(){
     ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
     int t;
     cin>>t;
     while(t--){
         solve();
     }
}

詳細信息

Test #1:

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

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

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

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
No
No
No
No
No
No
No
Yes
No
Yes
No
No
No
No
No
Yes
No
No
No
No
Yes
No
No
No
No
No
Yes
No
Yes
No
No
No
No
No
No
No
No
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 [36th token]