QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#688107#7894. Many Many HeadsVarealWA 3ms5724kbC++172.0kb2024-10-29 23:23:542024-10-29 23:23:55

Judging History

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

  • [2024-10-29 23:23:55]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:5724kb
  • [2024-10-29 23:23:54]
  • 提交

answer

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <queue>
#include <bitset>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <cassert>
#include <random>
#include <chrono>
#include <ctime>
#include <cstdlib>
#define pii pair<int,int> 
#define mp make_pair
#define pb emplace_back
#define debug() cout<<"qwq"<<endl
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned long long ull;
const int DMAX = 1000000 + 5;
const double INF = 1e9;
const int MOD = 998244353;
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
template<class T> inline void read(T &x){
	T f=1; x=0; char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-') f=-1; 
		ch=getchar();
	}
	while(ch<='9' && ch>='0'){ x=x*10+ch-'0';ch=getchar(); }
	x*=f;
}
int T, n;
char s[DMAX];
int a[DMAX];
vector<int> v0, v1;
void solve(){
	scanf("%s", s + 1);
	v0.clear(), v1.clear();
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++){
		if(s[i] == '(' || s[i] == ')'){
			a[i] = 1;
			v0.pb(i);
		}
		else a[i] = 0, v1.pb(i);
	}
	for(int i = 1; i <= n - 2; i++){
		if(a[i] == a[i + 1] && a[i + 1] == a[i + 2]){
			puts("No");
			return ;
		}
	}
	int cnt0 = 0, cnt1 = 0;
	int las = -1;
	int len = v0.size();
	for(int i = 0; i < len; i += 2){
		if(v0[i] + 1 == v0[i + 1]) cnt0 ++;
	}
	len = v1.size();
	for(int i = 0; i < len; i += 2){
		if(v1[i] + 1 == v1[i + 1]) cnt1 ++;
	}
	// cout<<cnt1<<" "<<cnt0<<endl;
	if(cnt1 + cnt0 <= 1){
		puts("Yes");
		return ;
	}
	string str = "";
	for(int i = 1; i <= n; i++){
		if(s[i] == '(' || s[i] == ')'){
			str += "1";
		}
		else str += "0";
	}
	if(str == "011011" || str == "100100" || str == "110110" || str == "001001"){
		puts("Yes");
		return ;
	}
	else puts("No");
	return ;
}
int main(){
    read(T);
	while(T--){
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3804kb

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

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

input:

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

output:

Yes
Yes
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
Yes
Yes
No
No
No
No
No
No
Yes
Yes
No
No
Yes
No
No
No
No
Yes
No
No
No
No
No
Yes
Yes
No
Yes
Yes
Yes
Yes
No
No
Yes
No
No
No
No
Yes
No
No
Yes
Yes
Yes
Yes
No
Yes
Yes
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
...

result:

wrong answer expected YES, found NO [3rd token]