QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#656646#7683. Hard Brackets Problemtest_algthWA 19ms3628kbC++14740b2024-10-19 13:29:302024-10-19 13:29:30

Judging History

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

  • [2024-10-19 13:29:30]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:3628kb
  • [2024-10-19 13:29:30]
  • 提交

answer

#include <bits/stdc++.h>

const int MAXN = 1.01E6;
char A[MAXN];

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);

  int testCase = 1;
  std::cin >> testCase;
  while (testCase--) {
    std::cin >> A;
    bool ok = true;
    std::vector <char> Ans;

    int now = 0, N = strlen(A);
    for (int i = 0; i < N; ++i) {
      char a = A[i];
      if (a == '(')
        Ans.push_back('('), ++now;
      else {
        if (!now) Ans.push_back(')');
        else --now;
      }
    }

    if (now == 0) {
      for (char a : Ans)
        std::cout << a;
      std::cout << '\n';
    } else {
      std::cout << "impossible" << '\n';
    }
  }

  return 0;
}

詳細信息

Test #1:

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

input:

3
((()))
(
)))()

output:

(((
impossible
)))(

result:

ok 3 cases (3 test cases)

Test #2:

score: -100
Wrong Answer
time: 19ms
memory: 3628kb

input:

100000
())(()()()
()())()))
)()()()()
())()(())(
((())()))
)(())()))(
)()))())))
)))))(((()
()))((()((
()((()()))
(()())())
())(()))()
(())(())))
))))(()(()
()))(())((
()((())())
()))()))()
()((())())
()()))((()
()))(()))
(()(())))
())((()))
())()((())
(()(())))
()(((()())
))))())))(
((((()()()
(()(...

output:

impossible
(()())
)((((
impossible
(((()
impossible
)())()))
impossible
impossible
(((((
(((()
()(()(
(((())
impossible
impossible
(((((
())())(
(((((
impossible
())(()
(((()
()(((
impossible
(((()
impossible
impossible
impossible
impossible
impossible
()(()(
impossible
impossible
impossible
)))(()(...

result:

wrong answer the result string is incorrect (test case 2)