QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#363211#7894. Many Many HeadsOobugoOWA 8ms3744kbC++201.0kb2024-03-23 19:37:182024-03-23 19:37:19

Judging History

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

  • [2024-03-23 19:37:19]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:3744kb
  • [2024-03-23 19:37:18]
  • 提交

answer

#include <bits/stdc++.h>

#define x first
#define y second

typedef long long ll;

int get(char c) {
    if (c == '#')   return 0x3f3f3f3f;
    return c == '(' || c == ')';
}

void solve() {
    std::string s;
    std::cin >> s;
    char pre = '#';
    int num = 0;
    std::vector<char> st(1, '#');    
    for (auto x : s) {
        if (get(x) == get(st.back())) 
            st.pop_back();
        else
            st.push_back(x);
        if (st.size() == 1) {
            if (get(pre) == get(x)) {
                std::cout << "No\n";
                return;
            }
            pre = x;
            num++;
        }
    }
    if (st.size() == 1 && num <= 2) {
        std::cout << "Yes\n";
    } else {
        std::cout << "No\n";
    }
}

int main(){

#ifdef Onlion_Judge
    freopen("IO/input.in", "r", stdin);
    freopen("IO/output.out", "w", stdout);
    // freopen("E:\\save work\\data\\4.in", "w", stdout);
#endif

    int t = 1;
    std::cin >> t;
    while (t--) {
        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3520kb

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

input:

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

output:

Yes
No

result:

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

Test #3:

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

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
Yes
Yes
Yes
No
No
No
Yes
No
No
No
No
Yes
No
No
No
Yes
Yes
Yes
No
Yes
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
Yes
Yes
No
No
No
No
No
No...

result:

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