QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#619119 | #7894. Many Many Heads | tsai | WA | 12ms | 3792kb | C++14 | 760b | 2024-10-07 13:08:01 | 2024-10-07 13:08:02 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 +50;
int trans[N];
int cnt[3];
void solve(int x){
stack<int>st;
string s;
cin>>s;
if(x==45){
cout<<s<<"mmm ";
}
for(int i = 1; i <= s.length(); i++) trans[i] = (s[i-1] == '(' || s[i-1] == ')')? 1 : 2;
cnt [0] = cnt[1] = cnt[2] = 0;
for(int i = 1; i <= s.length(); i++){
if(!st.empty()){
if(trans[i] == st.top()) st.pop();
else st.push(trans[i]);
}
else st.push(trans[i]);
if(st.empty()) cnt[trans[i]]++;
}
if(cnt[1] >= 2 || cnt[2] >= 2) printf("No");
else printf("Yes");
}
int main(){
int t;
scanf("%d",&t);
int cnt=1;
while(cnt<=t){
solve(cnt);
cnt++;
if(t) printf("\n");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3760kb
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: 3740kb
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: 12ms
memory: 3792kb
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 ](]](([])[mmm 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 ...
result:
wrong output format YES or NO expected, but ](]](([])[MMM found [45th token]