QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#641492 | #7683. Hard Brackets Problem | ucup-team2526 | WA | 11ms | 3620kb | C++20 | 825b | 2024-10-14 20:46:24 | 2024-10-14 20:46:25 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define dbg(x...) \
do { \
std::cout << #x << " -> "; \
err(x); \
} while (0)
void err() {
std::cout << std::endl;
}
template<class T, class... Ts>
void err(T arg, Ts &... args) {
std::cout << fixed << setprecision(10) << arg << ' ';
err(args...);
}
void GENSHEN_START() {
string s;cin >> s;
string ans;
int l = 0,r = s.size() - 1;
for (;l <= r;) {
if (s[l] == '(') {
if (s[r] == ')') {
ans += s[l];
l++;
r--;
}
else {
cout << "impossible" << '\n';
return ;
}
}
else {
ans += ')';
l++;
}
}
cout << ans << '\n';
}
signed main()
{
ios::sync_with_stdio(false);cin.tie(nullptr);
int T = 1;
cin >> T;
while (T--) GENSHEN_START();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3616kb
input:
3 ((())) ( )))()
output:
((( impossible )))(
result:
ok 3 cases (3 test cases)
Test #2:
score: -100
Wrong Answer
time: 11ms
memory: 3620kb
input:
100000 ())(()()() ()())())) )()()()() ())()(())( ((())())) )(())()))( )()))()))) )))))(((() ()))((()(( ()((()())) (()())()) ())(()))() (())(()))) ))))(()(() ()))(())(( ()((())()) ()))()))() ()((())()) ()()))((() ()))(())) (()(()))) ())((())) ())()((()) (()(()))) ()(((()()) ))))())))( ((((()()() (()(...
output:
impossible ()())( impossible impossible impossible impossible )()))()) impossible impossible impossible impossible impossible (())(( impossible impossible impossible impossible impossible impossible ()))(( (()(( impossible impossible (()(( impossible impossible impossible impossible impossible impos...
result:
wrong answer the result string is incorrect (test case 2)