QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#311379#7894. Many Many HeadsconfesserWA 4ms3688kbC++171.1kb2024-01-22 11:48:402024-01-22 11:48:41

Judging History

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

  • [2024-01-22 11:48:41]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3688kb
  • [2024-01-22 11:48:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using pi=pair<int,int>;
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define G(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(a,b) memset(a,b,sizeof(a))
#define si(a) ((int)(a).size())
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define pb push_back

const int N=1e5+3;
char s[N];
int st[N];

void slv(){
	cin>>(s+1);
	int n=strlen(s+1);
	F(i,1,n-3){
		if((s[i]=='('||s[i]==')')&&
		(s[i+1]=='('||s[i+1]==')')&&
		(s[i+2]=='('||s[i+2]==')')){
			cout<<"No\n";
			return;
		}
		if((s[i]=='['||s[i]==']')&&
		(s[i+1]=='['||s[i+1]==']')&&
		(s[i+2]=='['||s[i+2]==']')){
			cout<<"No\n";
			return;
		}
	}
	int cnt=0;
	F(i,1,n-1){
		if((s[i]=='('||s[i]==')')&&(s[i+1]=='('||s[i+1]==')')){
			cnt++;
			i++;
			continue;
		}
		if((s[i]=='['||s[i]==']')&&(s[i+1]=='['||s[i+1]==']')){
			cnt++;
			i++;
			continue;
		}
	}
	if(cnt<=2) cout<<"Yes\n";
	else cout<<"No\n";
}

int main(){
	cin.tie(0)->ios::sync_with_stdio(0);
	int t;
	cin>>t;
	while(t--) slv();
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3568kb

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

input:

2
(([([[([
]]))])]])]

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #3:

score: 0
Accepted
time: 4ms
memory: 3620kb

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

result:

ok 15134 token(s): yes count is 132, no count is 15002

Test #4:

score: -100
Wrong Answer
time: 3ms
memory: 3648kb

input:

100000
][[][[
())))(
)())))
]]][[[
)[]))(
()[[)(
)())))
[[[][]
[][][]
))[]]]
]]]][[
][]]][
(][)))
((([](
][[]]]
)([)([
))()((
[)[[)[
((()))
)(][[]
][[[[[
()((((
][][]]
][)()(
]]]]][
(()(()
)([((]
[][[]]
]][]][
)((())
][[[[[
[)[[([
(([[)(
(((())
)((()(
))()()
()((((
[[][][
))[])(
(((()(
]]][[]
()[[]]...

output:

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

result:

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