QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#396614#7894. Many Many Headsucup-team3294WA 4ms3656kbC++232.0kb2024-04-22 22:18:262024-04-22 22:18:26

Judging History

你现在查看的是最新测评结果

  • [2024-04-22 22:18:26]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3656kb
  • [2024-04-22 22:18:26]
  • 提交

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;
	s=" "+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: 3596kb

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: 3580kb

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: 4ms
memory: 3656kb

input:

15134
][
)(
)([[
[)([
)][)
]])(
([]([]
]]))][
[([](]
()[))]
][(]](
([()[)
()[]((
[)([)(
]]([[)]]
)[()])]]
))[](([]
](([((]]
))[)][)[
[)])([(]
[()[]))[
)][(]()]
[[((]()]
((]])[[)
])(](]])
)]]()[](
([)[])])
[[)[()](
([[)[[()
[[)([]))
[)[[)[()
))[(([)(
()][)[](]]
[()]([[([[
)[]))][)][
)]([]([(][
[])])(...

output:

Yes
Yes
Yes
Yes
Yes
Yes
No
No
Yes
No
No
Yes
No
No
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
Yes
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
Yes
No
No
No
No
No
No
No
No
No
No
No
No...

result:

wrong answer expected YES, found NO [7th token]