QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#627229#7894. Many Many Headsadivse#WA 0ms3620kbC++202.4kb2024-10-10 15:15:242024-10-10 15:15:27

Judging History

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

  • [2024-10-10 15:15:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-10-10 15:15:24]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#define endl '\n'
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define rep2(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
template<typename... Args>
void bubu(Args... args) { cout << ":: "; ((cout << args << " "), ...); cout << endl; }
void bubu(vector<int> tem) { for (auto x : tem) cout << x << ' '; cout << endl; }
void kuaidu() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); }
inline int max(int a, int b) { if (a < b) return b; return a; }
inline int min(int a, int b) { if (a < b) return a; return b; }
using PII = pair<int, int>;
using i128 = __int128;

//=======================================================================
const int N = 1e5 + 10;
const int M = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 1e16;
int n, m, T;

//=======================================================================
int fan(char x) {
    // if (x == ' ') return 2;
    if (x == ')' || x == '(') return 1;
    return 0;
}
int st[N];
int top;
signed main() {
    kuaidu();
    cin >> T;
    while (T--) {
        string s; cin >> s;
        n = s.size();
        s = ' ' + s;
        // s = s + ' ';
        int l1 = 0, l0 = 0; int r1 = 0, r0 = 0;

        int fl = 1;
        rep(i, 1, n - 3) {
            int x1 = fan(s[i]), x2 = fan(s[i + 1]), x3 = fan(s[i + 2]), x4 = fan(s[i + 3]);
            if (x1 == x2 and x1 == x3 and x1 == x4) {
                fl = 0;
                break;
            }
        }

        if (fl == 0) {
            cout << "No" << endl;
            continue;
        }
        int ll = 0;
        rep(i, 1, n - 1) {
            if (fan(s[i]) == fan(s[i + 1]) and i + 2 <= n and fan(s[i]) != fan(s[i + 2])) {
                if (fan(s[i]) == 1) {
                    if (i % 2) l1++;
                    else r1++;
                }
                else {
                    if (i % 2) l0++;
                    else r0++;
                }
                i++;
            }
            else if (i + 2 <= n and fan(s[i]) == fan(s[i + 1]) and fan(s[i]) == fan(s[i + 2])) {
                ll++;
                i += 2;
            }
        }
        if (l1 + r1 + l0 + r0 >= 3 || l1 + r1 + l0 + r0 + ll >= 2) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

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

output:

No
No

result:

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