QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#408214 | #7894. Many Many Heads | an_da | WA | 1ms | 3752kb | C++14 | 1.5kb | 2024-05-09 20:59:58 | 2024-05-09 20:59:58 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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]