QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#396618#7894. Many Many Headsucup-team3294WA 7ms3884kbC++232.2kb2024-04-22 22:24:452024-04-22 22:24:45

Judging History

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

  • [2024-04-22 22:24:45]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3884kb
  • [2024-04-22 22:24:45]
  • 提交

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();
	s=" "+s;
	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++;
			}
		}
	}
	vector<int> a(n+1);
	string y;
	for(int i=1;i<=n;i++){
		if(s[i]=='('||s[i]==')') a[i]=1;
		else a[i]=2;
		y+=to_string(a[i]);
	}
	if(s1>=2){
		if(y=="211211"||y=="112112"){
			int yt=5201314;
		}else{
			puts("No");
			return;
		}
	}
	if(s2>=2){
		if(y=="122122"||y=="221221"){
			int yt=5201314;
		}else{
			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: 3880kb

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

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

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
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
N...

result:

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