QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#657998#7894. Many Many Headschie4WA 0ms3544kbC++141.3kb2024-10-19 15:57:052024-10-19 15:57:08

Judging History

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

  • [2024-10-19 15:57:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3544kb
  • [2024-10-19 15:57:05]
  • 提交

answer

#include <algorithm>
#include <iostream>
#include <string>
int main() {
    int t, length, half;
    bool ans;
    std::string s, tmp_s, reversed_s;
    std::cin >> t;
    for (int i = 0; i < t; i++) {
        std::cin >> s;
        length = s.size();
        half = length >> 1;
        tmp_s = s;
        std::replace(tmp_s.begin(), tmp_s.end(), '(', 'r');
        std::replace(tmp_s.begin(), tmp_s.end(), ')', 'r');
        std::replace(tmp_s.begin(), tmp_s.end(), '[', 's');
        std::replace(tmp_s.begin(), tmp_s.end(), ']', 's');
        if (length % 2 == 1 || length <= 2) {
            std::cout << "Yes" << std::endl;
            continue;
        }
        reversed_s = tmp_s.substr(half, length);
        std::reverse(reversed_s.begin(), reversed_s.end());
        ans = tmp_s.substr(0, half) == reversed_s;
        if (ans) {
            ans = tmp_s.substr(0, half).find("ss") != std::string::npos ||
                  tmp_s.substr(0, half).find("rr") != std::string::npos;
        } else {
            ans = tmp_s.substr(0, half).find("ssss") != std::string::npos ||
                  tmp_s.substr(0, half).find("rrrr") != std::string::npos;
        }
        if (ans) {
            std::cout << "No" << std::endl;
        } else {
            std::cout << "Yes" << std::endl;
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

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

output:

Yes
Yes

result:

wrong answer expected NO, found YES [2nd token]