QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#627162#7894. Many Many Headsadivse#WA 8ms3852kbC++202.2kb2024-10-10 15:01:422024-10-10 15:01:43

Judging History

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

  • [2024-10-10 15:01:43]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3852kb
  • [2024-10-10 15:01:42]
  • 提交

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;
            
        }
        rep(i, 1, n - 1) {
            if (fan(s[i]) == fan(s[i + 1])) {
                if (fan(s[i]) == 1) {
                    if (i % 2) l1++;
                    else r1++;
                }
                else {
                    if (i % 2) l0++;
                    else r0++;
                }
                i++;
            }
        }
        if (l1 + r1 + l0 + r0 >= 3) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    return 0;
}

詳細信息

Test #1:

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

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: 0
Accepted
time: 0ms
memory: 3552kb

input:

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

output:

Yes
No

result:

ok 2 token(s): yes count is 1, no count is 1

Test #3:

score: 0
Accepted
time: 3ms
memory: 3852kb

input:

15134
][
)(
)([[
[)([
)][)
]])(
([]([]
]]))][
[([](]
()[))]
][(]](
([()[)
()[]((
[)([)(
]]([[)]]
)[()])]]
))[](([]
](([((]]
))[)][)[
[)])([(]
[()[]))[
)][(]()]
[[((]()]
((]])[[)
])(](]])
)]]()[](
([)[])])
[[)[()](
([[)[[()
[[)([]))
[)[[)[()
))[(([)(
()][)[](]]
[()]([[([[
)[]))][)][
)]([]([(][
[])])(...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
No
Yes
No
Yes
No
No
Yes
Yes
No
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes
No
No
No
No
Yes
No
No
No
No
No
No
Yes
No
No
Yes
Yes
No
No
No
Yes
No
No
No
No
Yes
No
No
No
Yes
Yes
No
No
Yes
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No...

result:

ok 15134 token(s): yes count is 132, no count is 15002

Test #4:

score: -100
Wrong Answer
time: 8ms
memory: 3616kb

input:

100000
][[][[
())))(
)())))
]]][[[
)[]))(
()[[)(
)())))
[[[][]
[][][]
))[]]]
]]]][[
][]]][
(][)))
((([](
][[]]]
)([)([
))()((
[)[[)[
((()))
)(][[]
][[[[[
()((((
][][]]
][)()(
]]]]][
(()(()
)([((]
[][[]]
]][]][
)((())
][[[[[
[)[[([
(([[)(
(((())
)((()(
))()()
()((((
[[][][
))[])(
(((()(
]]][[]
()[[]]...

output:

No
No
No
No
Yes
No
No
No
No
No
No
No
Yes
Yes
No
Yes
No
Yes
No
No
No
No
No
No
No
No
Yes
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
Yes
No
No
No
Yes
No
No
No
No
Yes
Yes
No
No
No
Yes
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
...

result:

wrong answer expected NO, found YES [5th token]