QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#277159#7894. Many Many HeadsSSH#WA 0ms3596kbC++201.0kb2023-12-06 15:53:082023-12-06 15:53:09

Judging History

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

  • [2023-12-06 15:53:09]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3596kb
  • [2023-12-06 15:53:08]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve();
signed main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	int T = 1;
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

void solve() {
	string s;
	cin >> s;
	string s1;
	for (int i = 0; s[i]; i++) {
		if (s[i] == ')' || s[i] == '(') s1 = s1 + '1';
		else s1 = s1 + '0';
	}
	int pre = -1;
	for (int i = 1; i < s1.size(); i++) {
		if (s1[i] == s1[i - 1]) {
			pre = i - 1;
			break;
		}
	}
	int d=pre+1;
//	cout<<d<<"\n";
	if (d*2 > s1.size()) {
		cout << "No\n";
		return;
	}
	string ss = s1.substr(pre + 1, d);
	string ss1 = s1.substr(0, d);
	reverse(ss.begin(), ss.end());
//	cout<<ss<<" "<<ss1<<"\n";
	if (ss == ss1) {
		int len = s1.size() - d*2;
		if(len==0) {
			cout<<"Yes\n";
			return;
		}
		ss = s1.substr(d*2, len / 2);
		ss1 = s1.substr(2 * pre + 2 + len / 2 + 1, len / 2);
		reverse(ss.begin(), ss.end());
		if (ss == ss1) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	} else {
		cout << "No\n";
	}

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

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

output:

No
No

result:

wrong answer expected YES, found NO [1st token]