QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#277357 | #7894. Many Many Heads | SSH# | WA | 27ms | 3872kb | C++20 | 1.0kb | 2023-12-06 17:58:25 | 2023-12-06 19:13:40 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve();
signed main() {
cin.sync_with_stdio(0);
cin.tie(0);
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
void solve() {
string s;
cin >> s;
if(s.size()>=24){
cout<<"No\n";
return;
}
string s1;
for (int i = 0; s[i]; i++) {
if (s[i] == ')' || s[i] == '(') s1 = s1 + '1';
else s1 = s1 + '0';
}
stack<int>st;
int pre = -1;
int cnt = 0;
int pp=0;
for (int i = 0; i < s1.size();) {
pp=i;
if (s1[i] == pre) {
if (!st.size()) {
cout << "No\n";
return;
}
while (st.size() && i < s1.size()) {
if (st.top() == s1[i]) {
st.pop();
i++;
} else {
cout << "No\n";
return;
}
}
if (st.size()) {
cout << "No\n";
return;
}
pre = s1[i - 1];
// i++;
cnt++;
if (cnt > 2) {
cout << "No\n";
return;
}
} else {
st.push(s1[i]);
pre = s1[i];
i++;
}
if(i==pp) i++;
}
cout << "Yes\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3788kb
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: 3556kb
input:
2 (([([[([ ]]))])]])]
output:
Yes No
result:
ok 2 token(s): yes count is 1, no count is 1
Test #3:
score: 0
Accepted
time: 8ms
memory: 3576kb
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:
ok 15134 token(s): yes count is 132, no count is 15002
Test #4:
score: 0
Accepted
time: 15ms
memory: 3600kb
input:
100000 ][[][[ ())))( )()))) ]]][[[ )[]))( ()[[)( )()))) [[[][] [][][] ))[]]] ]]]][[ ][]]][ (][))) ((([]( ][[]]] )([)([ ))()(( [)[[)[ ((())) )(][[] ][[[[[ ()(((( ][][]] ][)()( ]]]]][ (()(() )([((] [][[]] ]][]][ )((()) ][[[[[ [)[[([ (([[)( (((()) )((()( ))()() ()(((( [[][][ ))[])( (((()( ]]][[] ()[[]]...
output:
No No No No No No No No No No No No No No No Yes No Yes No No No No No No No No Yes No No 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 Yes Yes No No No Yes No No Yes No No No No No No No No No Yes No No No No No No No No No No No No No No No No No No No Yes No No No...
result:
ok 100000 token(s): yes count is 12468, no count is 87532
Test #5:
score: 0
Accepted
time: 17ms
memory: 3568kb
input:
100000 ))()()() ][]][][[ [[]]]][] ()(()((( ]][[]]]] ][[[]]]] [[][[][] )((()(() )()]]))( ]]][][[[ [))]]])) (][(())) ]([[)])) (())()(( [[]]]]]] ())((((( ))(((()( ]]]][]]] [](][))) ((()())) [[][[]][ ((]))])) [[]]]][] ))([((]) )([][[][ [][[[][] []][)][) )()(())( )((()()( ]]))((]] )())(()( [[[][[[] (()([...
output:
No No No No No No No No No No 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 Yes No 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 ...
result:
ok 100000 token(s): yes count is 3122, no count is 96878
Test #6:
score: 0
Accepted
time: 20ms
memory: 3532kb
input:
100000 (())((()() ))])((((([ [[((]()))[ ]](][][[[( [[][][]][] ()([[()))( ()))()))() ][[[[]][[] ]][[[][][[ [])((()))) ][[[[]]][] [][[[]]]]] ][]][[[][] (])][][([( ())()()))) []]][[[[][ ]](][([])( [][[[[[]]] ([)((([[]( )]()](][)) []])[[([() ([()]([][[ ]]][]][[]] [)()(((()[ ([]]][][]) ()())(()(( [][]][[...
output:
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 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...
result:
ok 100000 token(s): yes count is 1153, no count is 98847
Test #7:
score: 0
Accepted
time: 19ms
memory: 3864kb
input:
83333 ][]]])(()((] [[[])]]([))[ [][]]][[))]] [(()[))[(](( ))((([[)))(( ([)))]]]])[) ][][]][][[[[ ]]][[((][[][ ([[([[([][[( [[))))(]))]( )[))()]()(][ [([[][[])[[] ]())([)[((]) ()(())[[()(( ]))(]](][][] ]()()[)(][[[ ]][][[][[[(( (((()([))()[ )([]([])((]] ][]]]][]][[] ]))[]][]([[( ][[[]]]][]]] ()[)(())...
output:
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 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 ...
result:
ok 83333 token(s): yes count is 248, no count is 83085
Test #8:
score: 0
Accepted
time: 19ms
memory: 3560kb
input:
71428 ))][[[[]][]]][ [)][[][][](][] []))(((]])()(( ]][[)]])])[]([ ([]((([[[][[[[ [[)][))[[[]][) ][[[)[][[)]]][ ([[))([(]])[(( ])[[)[[]][][(( ()))()(((()))( [][[]][]()][[] [(())((][))))[ )(()))))(())() )()(()()))())( ))((((((()))() )()())())))((( [[[)]))])[[]][ )]]))([)([)((( ][][[[[[[[]]]] [[[[[]]]]...
output:
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 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 ...
result:
ok 71428 token(s): yes count is 71, no count is 71357
Test #9:
score: 0
Accepted
time: 17ms
memory: 3500kb
input:
62500 )]((][))()((()[) ][][][[[[][[]][[ )(())((((((()()( (][([))[[()]]))] )(()()))))()((() ][]](([[[][[]])) ((()())()]])[((] (][(][]]]]]))[(( (())())()))((([[ (])(()()()]()([] ][))])()(()()]() [[[([[)]][[]][][ ][]][]]][[[][]]] ([(]]()))))(()[( ))()(()[)))[](]) ()[]()())(((((() ()]()[)(]())([]] (())]...
output:
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 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 ...
result:
ok 62500 token(s): yes count is 14, no count is 62486
Test #10:
score: 0
Accepted
time: 22ms
memory: 3568kb
input:
55555 ))(][([)[](([](]]] ](][[]]][][[(][[[] ((())())()(((()))( )((((((())((()))]] [[]]]][][]]]]][][[ ]]]][][]]]](]()[)[ [][([]([[[[[)(]()[ )])(()()(())]()))) (())))()))(())()() )][())(()])()([()) ][]]][]]](]][]][)] ))(()(()[)(()[()() ]]]]]][[[[][[[]][] )]())[[][)(())][[( ][)()]]([[](([)()) )](][([()...
output:
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 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 ...
result:
ok 55555 token(s): yes count is 3, no count is 55552
Test #11:
score: 0
Accepted
time: 24ms
memory: 3812kb
input:
50000 [[[[[]]]((())][([][[ ((()())())))()())))( )([)(]()(](())))[(() )(](][)))](()(((([[( )((]((((]))([))[(()) ))()()))())(([[))()( ()(()[)((((((((([)(( ]]([[[[)([[]]([)][)[ [)()])([[)[[[[)])()] ](]])[][)][((][([])) ]][[[[]]]][][]]]][[] ()((()())([]())))()( )]]][(][[[[][]]]][]] )(]]]]][)))(]][]]]]] ...
output:
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 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 ...
result:
ok 50000 token(s): yes count is 0, no count is 50000
Test #12:
score: 0
Accepted
time: 27ms
memory: 3636kb
input:
45454 ))[))]((())())([))[]]) ][[]]][)([)]([()]())[) ]][][]][][][]]]][[][[] ]][[]]]]][[[][[[[[[]][ (())())((())())(())))( ][[])[[)[[[]]]][][]][] ]][[]][[][[]][][]]]][[ [(]([()][))[)](([[[[(] ])[]][][([][]([][[[[(] ][[]][][[][]][][[]][[[ )))))(()()()))()))))() (]()[))()(())][((())(( ])([[)[][[[[()[[[[...
output:
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 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 ...
result:
ok 45454 token(s): yes count is 0, no count is 45454
Test #13:
score: 0
Accepted
time: 3ms
memory: 3492kb
input:
41666 [)(()])()))(())))())((() ][][[][]]]]][[]][[])]])] (()))])[[][)(())[()[])][ ]][[][]]]][]][][]][][][] [](](]]][[[][([[][[([[[] ])(][)[](][[])))]])))][] [[][[[][][]]][[[[[[[[][] ]((())))))(())(([[())(([ ())[)()(((())()(()()[)() ][[][]][]][[]]]]]]][][[[ ]]][(][][[[[[[[[))[][]]( [(][[[](]])[]([]]]]...
output:
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 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 ...
result:
ok 41666 token(s): yes count is 0, no count is 41666
Test #14:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
38461 ]]]]]][[[][[[[[][[[[[[]]]] )]))())([)((])))))[)(]()([ ])())))[((([))()()()]))()( (](()())())(])][((]((()))] [[](][[][][[][([[[[[[][[[[ ([)]([[]](()(][)(([)[]()]( [[]]]]]]]][[]][[][]][[[][[ []](]))))[[)[]]))[([(((][] )[[([((())((()())()((()((] []]][]]]][[][[[[[[[]]]][[[ []][][[][]][)][[])[][[[]...
output:
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 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 ...
result:
ok 38461 token(s): yes count is 0, no count is 38461
Test #15:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
35714 ]]]])([]]][))][)()[[))(([[)] ]](]][[][[)[]()[][[)[[[(]]() ](]][[]]()(]][]]]][][])((([] [())])([([(((([(]]([)(()([[( []][]][](()[[[]][][[][[][[[) ))))())(()()(()())(()))()()( ]](]())[]]][)]])[(][[]()[[[( (][[[[[[]][[]][[[([][[)[]([[ ))[))[[(())]())(]]((][](([)) [)]()[)((()](]())([])(])(()( ]]][...
output:
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 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 ...
result:
ok 35714 token(s): yes count is 0, no count is 35714
Test #16:
score: 0
Accepted
time: 3ms
memory: 3572kb
input:
33333 [()(()()[)()[])(((([)]((()[)(] )()()())(((((()))(((())()())(( ]][][)(]()]]])]](]])([]]][](([ ()(((()((((())((()(())))()())( ))))((((())[))[()((]()])(])(]) ([[]][]]][][]][]][][])[][[]][] [[][[][][][[][[]]]][]][][][[]] )])[])[[()[]]]([))[[[)[[][])[[ []]][[]]]])(][[][)(][[]][][[[] ]]]]][]([[[](][...
output:
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 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 ...
result:
ok 33333 token(s): yes count is 0, no count is 33333
Test #17:
score: 0
Accepted
time: 3ms
memory: 3668kb
input:
31250 ])[[[[[]](([][(]]][]))[]([]))][) [][][()))[)][[[(](][))]((()])[][ ](]([[[][)(]))[))]())[([]]]]]))] )))(]((()()())())]))))))()))))(( ())()))))[)))(()((())()))([((()( ()()(()))(((((((()))()))())())() [[]][]]]]][[]]][][[][[[]]][[][[[ [[[]][][]]][]][][[]][]][]]][][[] ())(]()[()((](((([)(())()())()...
output:
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 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 ...
result:
ok 31250 token(s): yes count is 0, no count is 31250
Test #18:
score: 0
Accepted
time: 3ms
memory: 3872kb
input:
29411 ]]][[]][][])[](]][[[[[][)()[](])(] ]((]][][[[)[](([[[][[)(]]((([])]]) [[[][[[[[][[]][]][]]]][[][[[[]][]] ))([[[[([)([)())))])((]][]([()))() (()))))())()))))(((()(((()()(()()( [[[)(]][)(((]))])]([[][)()]]]]](][ ))))][([)]]][)(]][])[[][[][((]]][( [)()))(()[()())()((())([()))]())(( ())([)())][(()...
output:
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 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 ...
result:
ok 29411 token(s): yes count is 0, no count is 29411
Test #19:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
20833 ))(()])))()[])())((([()(([))(([)(())(((]()))[)() ))()()()(((()())))(((()((((()(()(()(())()((((()( ((((()()(])())((()([((](()))()(((())(()))(]()(() ]])(]]))([(()))()(())())([(])(]()(()()())(((]([) ())(()))(())()))(()()())((((((()())()((())(()(() ]][[]][[[][[]]][]][]]]][[][[][]]]]][]][[][[[][[[ ...
output:
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 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 ...
result:
ok 20833 token(s): yes count is 0, no count is 20833
Test #20:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
16129 )()((())())(())))())(())(())))(()))())())))))((()()(()))(((()) [[))()([((())]]]()][[][()()[[)(](([))[]())(())])()((((())([))[ [[[[][]]]][][][][[[][[[][]]([[([]][[[)][(][[)][)])][)])]])[[[] []](][]([[][[[[([[[]][[[[][])([[[[)[]]][[]][[]][[[[[([[][()[)[ )(())((])))(()()]))()](())((((((((())())))...
output:
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 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 ...
result:
ok 16129 token(s): yes count is 0, no count is 16129
Test #21:
score: 0
Accepted
time: 2ms
memory: 3600kb
input:
10000 ]([][[[][[[][])[[]][]][][]]])[][[(][[[[]]]][]]]][]]][[[][[]][[][][][[][[][]][]][]][]]][[[][]][[[[[][ ])][][([[()))[]]][)[[[][])(])]]]][[(()]([[(]][(]])[][))[][[([[][)[[[](][][[][)])(]]])][]]])](][)](][ ()[((()()))()))()(((]))(()))()))((()()))((()())((][)(()()(((()()()()()([))()())(())(((([))()...
output:
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 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 ...
result:
ok 10000 token(s): yes count is 0, no count is 10000
Test #22:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
199 (([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[(([[...
output:
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 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 ...
result:
ok 199 token(s): yes count is 0, no count is 199
Extra Test:
score: -3
Extra Test Failed : Wrong Answer on 2
time: 0ms
memory: 3628kb
input:
1 [([([([([([([([([([([([([([([([([([([([([([([([([()])])])])])])])])])])])])])])])])])])])])])])])])]
output:
No
result:
wrong answer expected YES, found NO [1st token]