QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#396608 | #7894. Many Many Heads | ucup-team3294 | WA | 0ms | 3620kb | C++23 | 2.0kb | 2024-04-22 22:08:15 | 2024-04-22 22:08:15 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define ULL unsigned long long
#define PII pair<int,int>
#define PLI pair<long long,int>
#define esp 1e-6
#define x first
#define y second
#define ls(u) (u<<1)
#define rs(u) (u<<1|1)
using namespace std;
#define dbg(x...) \
do { \
cout << #x << " -> "; \
err(x); \
} while (0)
void err() {
cout<<endl<<endl;
}
template<class T, class... Ts>
void err(T arg, Ts ... args) {
cout<<fixed<<setprecision(10)<<arg<< ' ';
err(args...);
}
const int MAXN=1e6+10,mod=1e9+7;
mt19937_64 rnd(random_device {}());
//uniform_int_distribution<LL> dist(0,LLONG_MAX);
int qmi(int a,int b) {
int k=1;
while(b) {
if(b&1) {
k=1LL*a*k%mod;
}
b/=2;
a=1LL*a*a%mod;
}
return k;
}
int read() {
int x=0,f=1;
char c=getchar();
while(c<'0'||c>'9') {
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
return x*f;
}
void write(int x) {
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10+'0');
}
int GG=0;
const int N=1e5+10;
void init() {
}
void solve() {
string s;
cin>>s;
int n=s.size();
for(int i=1;i<=n-2;i++){
if(s[i]=='('||s[i]==')'){
if(s[i+1]=='('||s[i+1]==')'){
if(s[i+2]=='('||s[i+2]==')'){
puts("No");
return;
}
}
}
if(s[i]=='['||s[i]==']'){
if(s[i+1]=='['||s[i+1]==']'){
if(s[i+2]=='['||s[i+2]==']'){
puts("No");
return;
}
}
}
}
int s1=0,s2=0;
for(int i=1;i<n;i++){
if(s[i]=='('||s[i]==')'){
if(s[i+1]=='('||s[i+1]==')'){
s1++;
i++;
}
}
if(s[i]=='['||s[i]==']'){
if(s[i+1]=='['||s[i+1]==']'){
s2++;
i++;
}
}
}
if(s1>=2){
if(s!=" [()]()"||s!=" ()[()]"){
puts("No");
return;
}
}
if(s2>=2){
if(s!=" ([])[]"||s!=" []([])"){
puts("No");
return;
}
}
puts("Yes");
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int T=1;
cin>>T;
init();
while(T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
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: 3620kb
input:
2 (([([[([ ]]))])]])]
output:
Yes Yes
result:
wrong answer expected NO, found YES [2nd token]