QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#314268#7894. Many Many HeadswdwWA 3ms3788kbC++141.7kb2024-01-25 15:08:582024-01-25 15:08:58

Judging History

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

  • [2024-01-25 15:08:58]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3788kb
  • [2024-01-25 15:08:58]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define int long long
const int N=1205+5;
const double eps=1e-10;
const int mod=1e9;
#define endl '\n'
void solve() {
    string s;
    cin>>s;
    int f=0;
    int f2=0;
    for(int i=0;i<s.size();i++){
        if(s[i]==')'||s[i]=='('){
            f2=0;
            f++;
            if(f==3){
                cout<<"No"<<endl;
                return;
            }
        }else if(s[i]=='['||s[i]==']'){
            f=0;
            f2++;
            if(f2==3){
                cout<<"No"<<endl;
                return;
            }
        }
    }
    vector<int>a(s.size()+5);
    int x=1;
    int f1=0;
    for(int i=0;i<s.size();i++){
        if(s[i]==')'||s[i]=='('){
            a[x]++;
            if(a[x]==3){
                cout<<"No"<<endl;
                return;
            }
        }else{
            if(f1==0){
                f1=1;
                x++;
            }else{
                f1=0;
                x--;
            }
        }
    }
    int f3=0;
    int x2=1;
    vector<int>a2(s.size()+5);
    for(int i=0;i<s.size();i++){
        if(s[i]=='['||s[i]==']'){
            a2[x2]++;
            if(a2[x2]==3){
                cout<<"No"<<endl;
                return;
            }
        }else{
            if(f3==0){
                f3=1;
                x2++;
            }else{
                f3=0;
                x2--;
            }
        }
    }
    cout<<"Yes"<<endl;

}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    // cout<<fixed<<setprecision(2);
    int T=1;
    cin>>T;
    while(T--) solve();
    return 0;
}

详细

Test #1:

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

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

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: 3ms
memory: 3788kb

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

result:

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