QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#408214#7894. Many Many Headsan_daWA 1ms3752kbC++141.5kb2024-05-09 20:59:582024-05-09 20:59:58

Judging History

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

  • [2024-05-09 20:59:58]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3752kb
  • [2024-05-09 20:59:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using arr = array<int, 3>;
using vi = vector<int>;
using vl = vector<ll>;
constexpr int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr int N = 1e5 + 5, M = N;
constexpr int mod = 1e9 + 7;
constexpr ld eps = 1e-8;
template <class T> void Min(T &a, const T b) { if (a > b) a = b; }
template <class T> void Max(T &a, const T b) { if (a < b) a = b; }
template <class T> void Add(T &a, const T b) { a += b; if(a >= mod) a -= mod; }
template <class T> void Sub(T &a, const T b) { a -= b; if(a < 0) a += mod; }


bool solve() {
	string s;
	cin >> s;
	int cnt = 0;

	map<char, int> mp;
	mp['('] = mp[')'] = 0;
	mp['['] = mp[']'] = 1;
	for (int i = 2; i < int(s.size()); ++i) {
		if (mp[s[i]] == mp[s[i - 1]] && mp[s[i]] == mp[s[i - 2]]) return false;
	}
	for (int i = 1; i < int(s.size()); ++i) {
		if (mp[s[i]] == mp[s[i - 1]]) cnt++;
	}

	if (cnt > 2) {
		return true;
	}
	// if (cnt1 >= 2 || cnt2 >= 2) {
	// 	if (s == "([])[]" || s == "[()]()" || s == "()[()]" || s == "[]([])") {
	// 		return true;
	// 	} else {
	// 		return false;
	// 	}
	// }
	return false;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	cin >> t;
	while(t--) {
		if (solve()) {
			cout << "Yes\n";
		} else {
			cout << "No\n";
		}
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3752kb

input:

6
))
((()
[()]
()[()]()
([()])
([])([])

output:

No
No
No
Yes
No
Yes

result:

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