QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#663952#7894. Many Many Headszyq_313#WA 0ms3636kbC++141022b2024-10-21 18:34:432024-10-21 18:34:44

Judging History

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

  • [2024-10-21 18:34:44]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2024-10-21 18:34:43]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> PII;
const int N = 110;
int a[N];
int st[N];
void solve()
{
	string s;cin>>s;
	s=" "+s;
	map<int,int> mp1,mp2;
	int cnt=0;
	
	for(int i=1;i<s.size();i++) {
		if(s[i]==')') s[i]='(';
		if(s[i]==']') s[i]='[';
		if(s[i]=='(') {
			if(s[i]!=s[i-1]) {
				//cout<<i<<' '<<s[i]<<' '<<s[i-1]<<endl;
				if(mp1[cnt-1]==1&&mp2[cnt]%2!=1)
				{
				cnt--;
				mp1[cnt]++;
				}
				else {
				cnt++;
				mp1[cnt]++;
			} 
			}
			else {
				mp1[cnt]++;
			}
			if(mp1[cnt]>2) {
				cout<<"No"<<endl;
				return ;
			}
		}
		else {
			if(s[i]!=s[i-1]){
				if(mp2[cnt-1]==1&&mp1[cnt]%2!=1){
				cnt--;
				mp2[cnt]++;
				}
				else {
				cnt++;
				mp2[cnt]++;
				}
			}
			else mp2[cnt]++;
			if(mp2[cnt]>2) {
				cout<<"No"<<endl;
				return ;
			}
		}		
	//	cout<<cnt<<endl;
	}
	cout<<"Yes"<<endl;
	return ;
}
int main()
{
	int t = 1;
	cin >> t;
	
	while (t--)
		solve();
	
	return 0;
}

详细

Test #1:

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

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: -100
Wrong Answer
time: 0ms
memory: 3636kb

input:

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

output:

Yes
Yes

result:

wrong answer expected NO, found YES [2nd token]