QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#663952 | #7894. Many Many Heads | zyq_313# | WA | 0ms | 3636kb | C++14 | 1022b | 2024-10-21 18:34:43 | 2024-10-21 18:34:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
const int N = 110;
int a[N];
int st[N];
void solve()
{
string s;cin>>s;
s=" "+s;
map<int,int> mp1,mp2;
int cnt=0;
for(int i=1;i<s.size();i++) {
if(s[i]==')') s[i]='(';
if(s[i]==']') s[i]='[';
if(s[i]=='(') {
if(s[i]!=s[i-1]) {
//cout<<i<<' '<<s[i]<<' '<<s[i-1]<<endl;
if(mp1[cnt-1]==1&&mp2[cnt]%2!=1)
{
cnt--;
mp1[cnt]++;
}
else {
cnt++;
mp1[cnt]++;
}
}
else {
mp1[cnt]++;
}
if(mp1[cnt]>2) {
cout<<"No"<<endl;
return ;
}
}
else {
if(s[i]!=s[i-1]){
if(mp2[cnt-1]==1&&mp1[cnt]%2!=1){
cnt--;
mp2[cnt]++;
}
else {
cnt++;
mp2[cnt]++;
}
}
else mp2[cnt]++;
if(mp2[cnt]>2) {
cout<<"No"<<endl;
return ;
}
}
// cout<<cnt<<endl;
}
cout<<"Yes"<<endl;
return ;
}
int main()
{
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
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: -100
Wrong Answer
time: 0ms
memory: 3636kb
input:
2 (([([[([ ]]))])]])]
output:
Yes Yes
result:
wrong answer expected NO, found YES [2nd token]