QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#678211 | #7894. Many Many Heads | enar# | WA | 3ms | 3588kb | C++20 | 930b | 2024-10-26 14:19:29 | 2024-10-26 14:19:29 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
using namespace std;
void solve() {
string s;cin>>s;
int n=s.size();
s=' '+s;
vector<int>even(2),odd(2);
int k=0;
for(int i=1;i<=n;i++){
if(s[i]=='('||s[i]==')'){
k++;
if(i%2)odd[k%2]++;
else even[k%2]++;
}
}
if(even[0]*odd[1]>1||even[1]*odd[0]>1){
puts("No");
return;
}
even[0]=even[1]=odd[0]=odd[1]=0;
k=0;
for(int i=1;i<=n;i++){
if(s[i]=='['||s[i]==']'){
k++;
if(i%2)odd[k%2]++;
else even[k%2]++;
}
}
if(even[0]*odd[1]>1||even[1]*odd[0]>1){
puts("No");
return;
}
puts("Yes");
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T = 1;
std::cin >> T;
while(T--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3516kb
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: 3512kb
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: 3588kb
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]