QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#313980#7894. Many Many HeadsyinheeWA 3ms3820kbC++141.3kb2024-01-25 11:02:392024-01-25 11:02:39

Judging History

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

  • [2024-01-25 11:02:39]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3820kb
  • [2024-01-25 11:02:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_std{
#define mems(x,y) memset(x,y,sizeof x)
#define Mp make_pair
#define eb emplace_back
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define il inline
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define drep(i,a,b) for(int i=(a);i>=(b);i--)
#define go(i,u) for(int i=head[u];i;i=e[i].nxt)
	typedef long long ll;
	typedef pair<int,int> pii;
	template<typename T>inline T read(){
		T x=0,f=1;char c=gc();
		while(!isdigit(c)){if(c=='-')f=-1;c=gc();}
		while(isdigit(c))x=x*10+c-48,c=gc();
		return x*f;
	}
}
using namespace my_std;
const int N=1e5+7,M=-1,inf=0x3f3f3f3f,mod=0;
int n,m,top,a[N],st[N],f[N],c[N],fa[N];
char s[N];bool vis[N];
void Yorushika(){
	scanf("%s",s+1),n=strlen(s+1),m=top=0;
	rep(i,1,n)f[i]=c[i]=vis[i]=0;
	rep(i,1,n){
		if(s[i]=='('||s[i]==')')a[i]=0;
		else a[i]=1;
		if(top&&a[st[top]]==a[i])f[st[top--]]=i;
		else st[++top]=i;
	}
	int p=0;c[0]=2;
	bool fl[2]={0,0};
	rep(i,1,n){
		if(!f[i])p=fa[p];
		else{
			if((p&&vis[p])||a[i]==c[p])return puts("No"),void();
			if(!p&&fl[a[i]])return puts("No"),void();
			fl[a[i]]=vis[p]=1;
			c[++m]=a[i],fa[m]=p,p=m;
		}
	}
	puts("Yes");
}
signed main(){
	int t=1;
		scanf("%d",&t);
	while(t--)
		Yorushika();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

input:

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

output:

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

result:

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