QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#656812#7683. Hard Brackets ProblemnidehgAC ✓259ms5400kbC++20413b2024-10-19 13:43:372024-10-19 13:43:48

Judging History

This is the latest submission verdict.

  • [2024-10-19 13:43:48]
  • Judged
  • Verdict: AC
  • Time: 259ms
  • Memory: 5400kb
  • [2024-10-19 13:43:37]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;

const int N = 1000010;

int t;

void solve(){
	string s;
	cin >> s;
	int cnt1 = 0, cnt2 = 0;
	for (int i = s.size() - 1; i >= 0; i -- ){
		if (s[i] == '('){
			cnt1 ++ ;
		}
		else cnt2 ++ ;
		if (cnt1 > cnt2){
			cout << "impossible\n";
			return;
		}
	}
	cout << s << '\n';
}

int main(){
	cin >> t;
	while (t -- ) solve();
	return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

((()))
impossible
)))()

result:

ok 3 cases (3 test cases)

Test #2:

score: 0
Accepted
time: 44ms
memory: 3604kb

input:

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

output:

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

result:

ok 100000 cases (100000 test cases)

Test #3:

score: 0
Accepted
time: 87ms
memory: 3596kb

input:

200000
(()))
()))(
)()))
(())
)((((
)(())
)(())
()))(
((()(
()(()
))())
)((((
()())
(())
()(()
(()()
)(())
()))
(()()
()())
(())
()()(
(()((
)())
(()()
(())
))(((
(())
())()
())()
(()))
(((((
)())
(()))
()(()
)()()
(()))
()())
(()))
)(())
(())(
))))(
())((
))(((
))))(
()()
()())
(())
(())
(())
)(())...

output:

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

result:

ok 200000 cases (200000 test cases)

Test #4:

score: 0
Accepted
time: 83ms
memory: 3604kb

input:

250000
()()
(())
())
)(((
(()(
(())
)()
(())
(())
))()
)(()
)())
)())
(())
)())
()))
())
(()(
))))
()((
()()
)())
())
())
())
(())
))()
(())
(()(
)))(
()))
())
)))(
)(()
()))
()()
(())
((()
(())
))((
))((
(())
()))
(()(
(())
((()
)(()
(())
((((
())
))()
())
()()
)()(
)()
(())
))()
()))
())
)()
)())
...

output:

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

result:

ok 250000 cases (250000 test cases)

Test #5:

score: 0
Accepted
time: 28ms
memory: 3540kb

input:

50000
)))()((((()(((())(()
)(())()())((())))()(
(((((()))()(((()((()
)()(()())(()())(()()
()(())()()()((())))
)((())))((((())(((((
((())(()()))()(()())
()))())(()))(()())((
))(((())(())()))())
((((()())()))()(((((
((())()))))(((()))))
()()(())((()(()))))
()())())))()()(()))
()))(())()())()(())
()()(...

output:

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

result:

ok 50000 cases (50000 test cases)

Test #6:

score: 0
Accepted
time: 53ms
memory: 3604kb

input:

83333
((()((())(()
(())(()()))
()(()(())))
((((())))))
)())(((())))
()()())()())
()()((())))
(()(()(((())
()((()()()()
(()()()())))
(()()()(((()
)))))()()())
)((()()())))
))(((()))))
()())(()))()
)()))))()())
)(()((())))(
(()())(()))
())()((())))
(()()()(()))
)())()()(())
((())()))(()
(()(()(((())
)...

output:

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

result:

ok 83333 cases (83333 test cases)

Test #7:

score: 0
Accepted
time: 83ms
memory: 3832kb

input:

250000
)))
)(((
()()
((()
((()
())
())(
))((
)())
()()
()()
())
((()
())
()()
(())
(())
()()
()))
())
)())
()()
)()
())
)()(
(())
)()
)(((
))()
(())
)()
)())
)()
)()
))((
()()
(())
()((
))((
)(((
()))
)())
)())
)())
)())
)(((
())
)))
(())
(())
())(
())
(())
(())
()()
())(
()()
())
))()
(())
(())
)()...

output:

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

result:

ok 250000 cases (250000 test cases)

Test #8:

score: 0
Accepted
time: 19ms
memory: 3768kb

input:

50000
(())((()()(())(((()(
()()()((((()())())))
(())(()()()((())))()
(())(()))(()(()()))
()((((()((())))))))
)))())))()()())()))(
()(()))(((())()(((((
()()())())(((()())))
(())(())))(()((())))
()(()(())()()()()(((
()()()((()(()()))))
)(())))()(())()())()
)((((((()())())((())
)()())(()((()(()))))
(()...

output:

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

result:

ok 50000 cases (50000 test cases)

Test #9:

score: 0
Accepted
time: 35ms
memory: 3544kb

input:

83333
((()(())))()
()))()()))()
()))()))())(
())(())))())
)()))))(((((
)(()(()())((
(()))(())())
)()()()(()()
((()())((())
)())()()(()(
()(())()())
)(()(())())
()(())(()))
))()(()(())(
()((()())))
)()(((())))
)())()())))
(((()()())))
()())()())()
()())(())()
)()((()())((
(()()((((())
(())))()()))
((...

output:

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

result:

ok 83333 cases (83333 test cases)

Test #10:

score: 0
Accepted
time: 83ms
memory: 3540kb

input:

250000
)())
()))
())(
(())
()()
())
))((
())
)()
())
()((
()))
(())
)(((
())
(())
))()
)())
(()(
)()
((((
()))
)))(
(()(
()()
))))
)())
()()
((()
)(((
()()
(())
)(()
()()
)()
)))(
())
())(
())
)))(
))()
())
)())
))((
())
()))
((()
)()(
)()
()))
())
)())
(())
(()(
()()
()))
()))
)))(
()))
)()
())
())...

output:

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

result:

ok 250000 cases (250000 test cases)

Test #11:

score: 0
Accepted
time: 38ms
memory: 3612kb

input:

50000
(())(()(()(())))())
())()()))(())()()())
())()())((()(()))))
()(()()))(()((())))
()))))()))((()((()))
()(())())())(()))())
((()((()((())))())))
())()))()()()())))))
(((()()))))))()(())
))(()((())((((()((((
()((()()(((()()()())
(()())(()(()))())))
()()))))(()(()()()))
())()())(((()(()))))
()(((...

output:

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

result:

ok 50000 cases (50000 test cases)

Test #12:

score: 0
Accepted
time: 63ms
memory: 3596kb

input:

83333
())()))))(()
(()((()(()))
((((((()())(
())(((((()))
((())((())))
)())())))))(
()(((())((()
()(((()))))
(()))((()))
)(())())((((
)()()()(())
)(()))(())))
)(((()())))
)(())(()()))
(())))(()))(
(((((()))))(
))((()()())(
(((()))())()
(((()()((())
())))))(((((
()((((()))))
)()(()))(())
(()))(()()))...

output:

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

result:

ok 83333 cases (83333 test cases)

Test #13:

score: 0
Accepted
time: 71ms
memory: 3604kb

input:

250000
(())
((((
(())
())
()()
(())
(())
())
))()
(())
))()
(())
()))
))))
(())
()))
()))
())
)()(
)))
)())
(())
(())
))()
(())
())
()))
))()
))((
)()
()()
)(((
(())
()()
)()
)(()
())
)())
((()
))()
)(((
()))
())
())
)())
()))
)())
(())
))()
))))
)())
())
))()
)()(
))))
((((
())
(())
)()
)())
())
()...

output:

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

result:

ok 250000 cases (250000 test cases)

Test #14:

score: 0
Accepted
time: 43ms
memory: 3548kb

input:

50000
))(())())())()(()(()
)((())((()()))(())))
()(()(()))()(()()))
((()())()())(()(()))
)()()(())())()(())()
(()(()(((())))()()))
((()))()()(()(()((()
()()()()(())(((())))
)))))((((()()()()(((
((())((()()(())))))
(((((()()()(()))))))
())())))())())()(())
((())((((((())))))))
((())()())())()()())
()...

output:

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

result:

ok 50000 cases (50000 test cases)

Test #15:

score: 0
Accepted
time: 35ms
memory: 3600kb

input:

83333
)))((())(()(
()((()))())
(()))()(()((
))((()()(()(
(()))()()))
)))()()(()((
)(()))()()((
())((()))))
(())))()())
)(()()))(()(
()(()()))()
()))())())((
((()(()())))
(((())()()()
()(())(()())
))())((()))
())((()()(()
))(()((())))
((((()()))))
(()((())())(
)()())(())()
))(()())()))
(()(())(()()
(...

output:

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

result:

ok 83333 cases (83333 test cases)

Test #16:

score: 0
Accepted
time: 12ms
memory: 5180kb

input:

1
(()()((((())))(((((((())(()())())()(()((()(((()(()))))())((())((())((()))()())(()))()))((())()())))()())()(()((())(((()()(((())(((()))(((()())((()(((()())()())(()(()(())()()())())(((((((()((((()))()())())((((()(()())()())))((()((((()(((((()((((())()(()(()((((()()(((())())())))(())))))))))((((()(()...

output:

impossible

result:

ok 1 cases (1 test case)

Test #17:

score: 0
Accepted
time: 10ms
memory: 4704kb

input:

2
())())()()(((()))()(((()())(())))))((()((()()()()()())(()((((()))()()((())()()((()))()())(())))(()(())(()()())(())))()())((((()()(()))((())()(())))))(((()(((((()(())()()((())))))(()(()())))))((())))))())())()()(()(()()))(((()))(()())))(())()))()())()()())()((()((()())())))())())((()((()())())(((()...

output:

())())()()(((()))()(((()())(())))))((()((()()()()()())(()((((()))()()((())()()((()))()())(())))(()(())(()()())(())))()())((((()()(()))((())()(())))))(((()(((((()(())()()((())))))(()(()())))))((())))))())())()()(()(()()))(((()))(()())))(())()))()())()()())()((()((()())())))())())((()((()())())(((()))...

result:

ok 2 cases (2 test cases)

Test #18:

score: 0
Accepted
time: 17ms
memory: 5264kb

input:

1
()(()(()))()()()((()())(())())())()(())(()()(()))(())()()()((()(()(())(()()(()((((()()))))))())((()))))((())((((()))(((((()(()))(((())((()))()()((()(()((()((()()()))(())))(())())()()))))((((()(())))))((()(()((()()())())())(()())(()()))()((((()))())()(((()(())))()()((((()))))()))()()))))((())((()((...

output:

()(()(()))()()()((()())(())())())()(())(()()(()))(())()()()((()(()(())(()()(()((((()()))))))())((()))))((())((((()))(((((()(()))(((())((()))()()((()(()((()((()()()))(())))(())())()()))))((((()(())))))((()(()((()()())())())(()())(()()))()((((()))())()(((()(())))()()((((()))))()))()()))))((())((()(()(...

result:

ok 1 cases (1 test case)

Test #19:

score: 0
Accepted
time: 17ms
memory: 5272kb

input:

1
()((()(((()))(())()())((()((()))((()()((()())(())())())(()()()()())(())(()((()(((())()((()((((((((())(()))))(((()()(()))(((()()())(()()(())))((((())()(()((()(())))()((())((((())())(()()()(()())((())(((()(((()))((()((()(()))))))())((())))((()))(((())))))))())(((((()(((())))(()())()()(())()(())(()()...

output:

()((()(((()))(())()())((()((()))((()()((()())(())())())(()()()()())(())(()((()(((())()((()((((((((())(()))))(((()()(()))(((()()())(()()(())))((((())()(()((()(())))()((())((((())())(()()()(()())((())(((()(((()))((()((()(()))))))())((())))((()))(((())))))))())(((((()(((())))(()())()()(())()(())(()())(...

result:

ok 1 cases (1 test case)

Test #20:

score: 0
Accepted
time: 13ms
memory: 5260kb

input:

1
)()((((())()))(())()))()(()))()())()(((()()(()(())))(()(((()))(((()()()))())))(())())()))(()((()))())()()()((((()))())))())((()())(()())))(((()(())()((()())(()((((())))(())))(()(())())(())(()()))(()((((()(())((())()()(((())()))(((()))(()(())(()()()()()()(())(((()()()(()(()(()))(()()))(((()((()()((...

output:

)()((((())()))(())()))()(()))()())()(((()()(()(())))(()(((()))(((()()()))())))(())())()))(()((()))())()()()((((()))())))())((()())(()())))(((()(())()((()())(()((((())))(())))(()(())())(())(()()))(()((((()(())((())()()(((())()))(((()))(()(())(()()()()()()(())(((()()()(()(()(()))(()()))(((()((()()(())...

result:

ok 1 cases (1 test case)

Test #21:

score: 0
Accepted
time: 16ms
memory: 5352kb

input:

1
())((()())()(((((()(((())()))((((()()))))))()())())(()())(())))())()((((()((()))))(()))))(((()(())((()()(()()(()))))()())))()))()(((())(()))))()()()(((((((())))(((()()))(())(()()))()))())))(((()((()())()()(((()()(((((((((())(()(())))(())()((()))))()((((())()(((()))))(()(())())(((()()(((((()(((()((...

output:

())((()())()(((((()(((())()))((((()()))))))()())())(()())(())))())()((((()((()))))(()))))(((()(())((()()(()()(()))))()())))()))()(((())(()))))()()()(((((((())))(((()()))(())(()()))()))())))(((()((()())()()(((()()(((((((((())(()(())))(())()((()))))()((((())()(((()))))(()(())())(((()()(((((()(((()(())...

result:

ok 1 cases (1 test case)

Test #22:

score: 0
Accepted
time: 16ms
memory: 5228kb

input:

1
(()))())(())((()(()())())))())(()((((())))())())(()((()(()(()((((()))()())()))(((()())()))((())))))))()())()))((()))()()()))())))()(())())(()(()()()(()((()))))((())))((((())()((())))())())()))()()))))()())(()))()(())(((()))))()))(()(()((()(()(((((()(())))(())(()))()()())))))()()))(((()())(())))(()...

output:

(()))())(())((()(()())())))())(()((((())))())())(()((()(()(()((((()))()())()))(((()())()))((())))))))()())()))((()))()()()))())))()(())())(()(()()()(()((()))))((())))((((())()((())))())())()))()()))))()())(()))()(())(((()))))()))(()(()((()(()(((((()(())))(())(()))()()())))))()()))(((()())(())))(()))...

result:

ok 1 cases (1 test case)

Test #23:

score: 0
Accepted
time: 16ms
memory: 5252kb

input:

1
()((()(()(()))())(())(()())((()))()()))(())(()))()((((()(()))))((())))())())()((()(()(()())(())())))(((((()(()(((()))()()))(()()((()))))((())()))))(()())(((())))))(((())((()))((((())()))))()()()))()()()()(())()((()))(()()(()()((())(((()(()()()))))())((((())(((()(((((()()()()))))()))))()((()))))))(...

output:

()((()(()(()))())(())(()())((()))()()))(())(()))()((((()(()))))((())))())())()((()(()(()())(())())))(((((()(()(((()))()()))(()()((()))))((())()))))(()())(((())))))(((())((()))((((())()))))()()()))()()()()(())()((()))(()()(()()((())(((()(()()()))))())((((())(((()(((((()()()()))))()))))()((()))))))(()...

result:

ok 1 cases (1 test case)

Test #24:

score: 0
Accepted
time: 17ms
memory: 5180kb

input:

1
(((()((())((((()(((((()())())))())(((())()(()(()())()((())())))()(()(()())())()()())((()))()())))()(((())()))(())(()((()))))()()(())((()((()(()))))())))))(()(((((((()())))((((())))))(((())())(()))(()(()))((((((()((()()()(()())())())(()(()())))())(((()()()((())))(()()()()()((())())))(())))()()(())(...

output:

(((()((())((((()(((((()())())))())(((())()(()(()())()((())())))()(()(()())())()()())((()))()())))()(((())()))(())(()((()))))()()(())((()((()(()))))())))))(()(((((((()())))((((())))))(((())())(()))(()(()))((((((()((()()()(()())())())(()(()())))())(((()()()((())))(()()()()()((())())))(())))()()(())())...

result:

ok 1 cases (1 test case)

Test #25:

score: 0
Accepted
time: 13ms
memory: 5272kb

input:

1
)))()())(()()()))(((((((((())(()(())()()()))(((()))()))()((())(()(())))())))(((()(())(()))(()(()(()))(())))((()))(()()())()((((())((())))()())))))(()())())))()()(((())()))())(()))((((())((((((())(()((((((()(()(()((()(((())()(()))()(()(((()))()(()(()()((((((()()))())())()))()(()(())))(()()))()(((((...

output:

)))()())(()()()))(((((((((())(()(())()()()))(((()))()))()((())(()(())))())))(((()(())(()))(()(()(()))(())))((()))(()()())()((((())((())))()())))))(()())())))()()(((())()))())(()))((((())((((((())(()((((((()(()(()((()(((())()(()))()(()(((()))()(()(()()((((((()()))())())()))()(()(())))(()()))()((((()(...

result:

ok 1 cases (1 test case)

Test #26:

score: 0
Accepted
time: 12ms
memory: 5352kb

input:

1
)((((())()(()))(())))))())())()(()))(((()))(()())))(((()((((()(()))))(((()))((((()((()(())))))())()(((((()()))(()((()(()((()()()(())))()))(((()()))()()((((()()(((()(()))())(((()())(()(())((()(()((())()))())())(((((((()))()))())(((()(())))()())(())()())(()))((((())(())))((())((())(((())))()()(()())...

output:

impossible

result:

ok 1 cases (1 test case)

Test #27:

score: 0
Accepted
time: 9ms
memory: 5256kb

input:

1
((())(())(())))((())))()()()((())))((((()()(((()()))))()()()()(((())((()((()))(((((())(())(()())))))))((((()))))())()))((()(((((())))))(()())())))(()(()))(((()((())((()()())(()()((()()()))((((((((()))))(()(()))()((()()())(((())(((())())()))()(((()((((()((())()(()((()(()((((())))(((()))())((((())()...

output:

impossible

result:

ok 1 cases (1 test case)

Test #28:

score: 0
Accepted
time: 12ms
memory: 5228kb

input:

1
)()()((())))))()()())))(()))()(()(())()))))())()(()(()()(((())()))))(())((())()))))))((()()()))()(()(()))))()()()(()()))))())())))))))(((()(())()()))))((()()(((((()(((())())(()(())(())))(()))()()))())((((((((((())(()(()))(()()()()(())(())(()(((()(()))()((()(()))((((())(()()()((()(())))((())((())((...

output:

impossible

result:

ok 1 cases (1 test case)

Test #29:

score: 0
Accepted
time: 12ms
memory: 5276kb

input:

1
(()))(()(()())())(((())()())((())))(())))))))((())()))))())()()))()()))))))())())((()))))))()()()))()())(())))()()(((())())(((())))(()()()(((()((()())))(()))())))))()))(())(())(()))(()()())))()))(((()))(()())))()(((()(((()()))(())()()))()(()()())()()(((((()()()))())))()((())()))(()((()()()()((((((...

output:

impossible

result:

ok 1 cases (1 test case)

Test #30:

score: 0
Accepted
time: 17ms
memory: 5192kb

input:

1
(((()))(()((())()(())()()())()(())()()()()))()(()()))(())(())(())((())(((())(()()))())()))(()((((((())()))(((()))))))()(((()()(())))()()(())))()))()(()())()((()((((()()())()((((((())((((((((())(()()()(()))(((()(()(((((())((()))(((((()(()(((()()(()(())()()((((())))(()))(())())))(())))((((()))()))()...

output:

(((()))(()((())()(())()()())()(())()()()()))()(()()))(())(())(())((())(((())(()()))())()))(()((((((())()))(((()))))))()(((()()(())))()()(())))()))()(()())()((()((((()()())()((((((())((((((((())(()()()(()))(((()(()(((((())((()))(((((()(()(((()()(()(())()()((((())))(()))(())())))(())))((((()))()))()((...

result:

ok 1 cases (1 test case)

Test #31:

score: 0
Accepted
time: 12ms
memory: 5240kb

input:

1
))()))((())()((()))(()))(())())(()()(())()((((())())()()()()()))))(((()(()(((()(((()(((()())((())(()(())))(()()))((()()((()))()))(()))()))((())())))())(())))()((()())()()((((()()())())))((())()((((()()()())((((((((())))))()()()(()())(())()(()((()()(()())(()(()(())((())((())()(()))())(((()(())(((((...

output:

impossible

result:

ok 1 cases (1 test case)

Test #32:

score: 0
Accepted
time: 6ms
memory: 5232kb

input:

1
)))()()()()((())())))))))))))()(()))()()())((((((()))((())))((())(((())(()())()))))()()))()))((()((()(())(())(())())(((((()())))))(((()(()())()((())))))()(((()((()(((()()((())))))((()(()((())()))()))()(((())))))())(())((((((((()()())()))))(()(()((()()())(())))))())((((()()(())(((())))((()())())(()...

output:

impossible

result:

ok 1 cases (1 test case)

Test #33:

score: 0
Accepted
time: 12ms
memory: 5348kb

input:

1
((((())))))(()()((((()(())()))))(((()()())()())))(())(())())()(()))(()()()(((()((()))))))(()())))(()((((((((()(((())(()))())))(()())))()(((()))))()()(((()()()((()(()()()((()()((()))()())))()((())()()))()(((((()))((()((())(((()((()()(()))(()))())()()(())((((())())()))()()()())))()(()())))(()()))(((...

output:

impossible

result:

ok 1 cases (1 test case)

Test #34:

score: 0
Accepted
time: 12ms
memory: 5220kb

input:

1
)(()))))))))()(())(((((())))()))())))())))()()(((()((())(()))(())(()())()())(()((())((((())())))())(((()()()()))())())()()((()(((()(()(((())(()((()()()()((()()()())))((()()()(((())))))))))))())()())))((()()())))))(((()()())()))(()))()))())))))))))()(()(()((())))()(()())(()))()()))())((()(()()()(((...

output:

impossible

result:

ok 1 cases (1 test case)

Test #35:

score: 0
Accepted
time: 8ms
memory: 5276kb

input:

1
))(((()(()((()(((()((())()((((()()))((()(((()(())(((())))((()))))()(())))(((((()())))(())())(()())()(((((()(())()))(((((()(())())))())))(((((()())())()(()())))))())(()))(((((((()((((((((((())))((())(())((()))))()((((())()(())((((()((((()))))))(())(())(()))))()()(())))()((()))(())())())(())())))))(...

output:

impossible

result:

ok 1 cases (1 test case)

Test #36:

score: 0
Accepted
time: 16ms
memory: 5180kb

input:

1
(()()))()(())())()(()))(())()())(()((())))())(()))())()(((()))()()()())()(((()(()(((()))()))((())(()()(((())(())()))()()))((()()))((()((((((((()()(())()(((()))(()()(((()))(((((()()))((((()((()((())((()))))))(((((()(()()())()))))))(()())(((((()()((()))(())(((()((()()(())()()())))())()((()()((((()()...

output:

(()()))()(())())()(()))(())()())(()((())))())(()))())()(((()))()()()())()(((()(()(((()))()))((())(()()(((())(())()))()()))((()()))((()((((((((()()(())()(((()))(()()(((()))(((((()()))((((()((()((())((()))))))(((((()(()()())()))))))(()())(((((()()((()))(())(((()((()()(())()()())))())()((()()((((()()))...

result:

ok 1 cases (1 test case)

Test #37:

score: 0
Accepted
time: 9ms
memory: 5252kb

input:

1
()))))((((()()()()((())((())((()()((()(((((()()()(((())())))())())()(()))((())((((((())((())()())())()())()()((((()(((())()()))(((()))((((()(()))))(()()()()((())))))(())()(((()))))())())())((()()))())())()((()()()(()()()()(((()()))())(()())(()()(())))(()))))())())(((()))(((())))()()(())))()(((()))...

output:

impossible

result:

ok 1 cases (1 test case)

Test #38:

score: 0
Accepted
time: 17ms
memory: 5268kb

input:

1
)()())())((()((()(())(())(())())(((((()())))))(((()(()())()((())))))()(((()((()(((()()((())))))((()(()((())()))()))()(((())))))())(())((((((((()()())()))))(()(()((()()())(())))))())((((()()(())(((())))((()())())(()(()(()((())()((((())()()()))((()))())()((()())())())(()))(()(()())))(()(()((())))))(...

output:

)()())())((()((()(())(())(())())(((((()())))))(((()(()())()((())))))()(((()((()(((()()((())))))((()(()((())()))()))()(((())))))())(())((((((((()()())()))))(()(()((()()())(())))))())((((()()(())(((())))((()())())(()(()(()((())()((((())()()()))((()))())()((()())())())(()))(()(()())))(()(()((())))))(()...

result:

ok 1 cases (1 test case)

Test #39:

score: 0
Accepted
time: 12ms
memory: 5356kb

input:

1
(())(((()))))((()()()(()(((((((()()(()((())())(())))))())()((())(())()))(()(()()()(()))(()(())()()(()())))))()())))((()((())()()())())())()))())())()()(())((()))()()(()))))()(())(()()()()()()())()(((()((())())(())))())()(()(())())()()(()()(((())(()(((((())()))(()()())()()())(()(())(()())))()())))(...

output:

(())(((()))))((()()()(()(((((((()()(()((())())(())))))())()((())(())()))(()(()()()(()))(()(())()()(()())))))()())))((()((())()()())())())()))())())()()(())((()))()()(()))))()(())(()()()()()()())()(((()((())())(())))())()(()(())())()()(()()(((())(()(((((())()))(()()())()()())(()(())(()())))()())))(()...

result:

ok 1 cases (1 test case)

Test #40:

score: 0
Accepted
time: 16ms
memory: 5196kb

input:

1
)))))(()((((()))())))()()((())(()()())(()())()))))()(((())))((()()))(((()()(((((()()(()())()(())(((()))))()(()))(())))(()())((()(())())))(()(()(((()((()))(((((())(())(()(()(()())))())(()))()((((()))()())))()())(()()((()()(()()))))))(())(()()(())(())())()()(()))()))))()()()((()(())()))()((())))())(...

output:

)))))(()((((()))())))()()((())(()()())(()())()))))()(((())))((()()))(((()()(((((()()(()())()(())(((()))))()(()))(())))(()())((()(())())))(()(()(((()((()))(((((())(())(()(()(()())))())(()))()((((()))()())))()())(()()((()()(()()))))))(())(()()(())(())())()()(()))()))))()()()((()(())()))()((())))())()(...

result:

ok 1 cases (1 test case)

Test #41:

score: 0
Accepted
time: 16ms
memory: 5352kb

input:

1
)))(()()(())))())()((((((((()()()(())())()())))((())())()((()))))))(((())()(((()))(((())()(()()())()()))))((()(()(())()()()((())())(()()((())))))))((()(((()((())())())(()()))))))((())()))()(((()))()))(())))(()(((()((((((((()))((())))())())())))()((())))()(((()))()((()())())((()())()))()(()())()())...

output:

)))(()()(())))())()((((((((()()()(())())()())))((())())()((()))))))(((())()(((()))(((())()(()()())()()))))((()(()(())()()()((())())(()()((())))))))((()(((()((())())())(()()))))))((())()))()(((()))()))(())))(()(((()((((((((()))((())))())())())))()((())))()(((()))()((()())())((()())()))()(()())()()))(...

result:

ok 1 cases (1 test case)

Test #42:

score: 0
Accepted
time: 16ms
memory: 5220kb

input:

1
)))())(())()())))()()()((()))(()))()(((()()()(()))(()()())())(((()(())))()))()((((((((()()()(())())()())))((())())()((()))))))(((())()(((()))(((())()(()()())()()))))((()(()(())()()()((())())(()()((())))))))((()(((()((())())())(()())))))))((())()))()(((()))())(())))(()(((()((((((((()))((())))())())...

output:

)))())(())()())))()()()((()))(()))()(((()()()(()))(()()())())(((()(())))()))()((((((((()()()(())())()())))((())())()((()))))))(((())()(((()))(((())()(()()())()()))))((()(()(())()()()((())())(()()((())))))))((()(((()((())())())(()())))))))((())()))()(((()))())(())))(()(((()((((((((()))((())))())())()...

result:

ok 1 cases (1 test case)

Test #43:

score: 0
Accepted
time: 17ms
memory: 5264kb

input:

1
)((()()))()()(()))())())()((())(()(())(())(()))))()((()()(()())))()(()((()))())()))()()(())(())((((()((()()()))))))()())()()()()()())(()())()((((()((()(())))()())())())))()())()()())(()((())))()(()())(((((((())))(((())((()())()((()))(()())(()((()()())(())(()((())))((()()()())(()))()))()))))(((((((...

output:

)((()()))()()(()))())())()((())(()(())(())(()))))()((()()(()())))()(()((()))())()))()()(())(())((((()((()()()))))))()())()()()()()())(()())()((((()((()(())))()())())())))()())()()())(()((())))()(()())(((((((())))(((())((()())()((()))(()())(()((()()())(())(()((())))((()()()())(()))()))()))))((((((()(...

result:

ok 1 cases (1 test case)

Test #44:

score: 0
Accepted
time: 16ms
memory: 5200kb

input:

1
)))()(((()()(()))(((())())()()(()()(())))))))(()))((()()))(()))()()))((()))())()((()())())())(()))(()(()())))(()(()((())))))(()))()))))()()())(()()))(()((((()))))))())()(()(((()())(()(((()))(()))())))(((((())((((()())((()(((())(()(()))()()())()())))()()(((())())))))))))(((()()()()()()()()(()()))((...

output:

)))()(((()()(()))(((())())()()(()()(())))))))(()))((()()))(()))()()))((()))())()((()())())())(()))(()(()())))(()(()((())))))(()))()))))()()())(()()))(()((((()))))))())()(()(((()())(()(((()))(()))())))(((((())((((()())((()(((())(()(()))()()())()())))()()(((())())))))))))(((()()()()()()()()(()()))(())...

result:

ok 1 cases (1 test case)

Test #45:

score: 0
Accepted
time: 16ms
memory: 5256kb

input:

1
)))())()))))()))(()))()))()((())(())))(()((((()())(((()()(()))()))()))((()((())))(((()()))()))(()))))(()(((((((()))())(()((((())()))(()((())(((()(((()(((()))))(())((()(()()))(()))(((())(()()))((()())((((((()(()())())))))((()))())((((((()(())(()()(()()(()()((((((((())())())(()(()())((((())))())))()...

output:

impossible

result:

ok 1 cases (1 test case)

Test #46:

score: 0
Accepted
time: 13ms
memory: 5260kb

input:

1
(((())))(((()()()()(()))()())()))(()((()()()()())()())))((()())(((()()())(()))(()))()()((()()(())()(())))())(())(()(()()(((()()(())((((()((()))()())()((())(())(()((((())((((())(((((())()((()(())))(()()(()()()))()((((()((())((())())))((()((()(((()())))))((()())((((())()()())((((()())))())()((()))((...

output:

(((())))(((()()()()(()))()())()))(()((()()()()())()())))((()())(((()()())(()))(()))()()((()()(())()(())))())(())(()(()()(((()()(())((((()((()))()())()((())(())(()((((())((((())(((((())()((()(())))(()()(()()()))()((((()((())((())())))((()((()(((()())))))((()())((((())()()())((((()())))())()((()))(()(...

result:

ok 1 cases (1 test case)

Test #47:

score: 0
Accepted
time: 16ms
memory: 5360kb

input:

1
))((((()))())))(((())()()((()))(((()((())())()((())((((((((()))()()(((())(()((((())()))(()(((())()((())(())(()))(()))()(()()())(())))((())(()()))())))))(()))()(((()())))(()))()())))()()((()(((()))))((()((((())(())(())()())))(()())(((()()(()(())()()()))))()())())))(()((()(()(()())))()))(())))))))((...

output:

))((((()))())))(((())()()((()))(((()((())())()((())((((((((()))()()(((())(()((((())()))(()(((())()((())(())(()))(()))()(()()())(())))((())(()()))())))))(()))()(((()())))(()))()())))()()((()(((()))))((()((((())(())(())()())))(()())(((()()(()(())()()()))))()())())))(()((()(()(()())))()))(())))))))((()...

result:

ok 1 cases (1 test case)

Test #48:

score: 0
Accepted
time: 12ms
memory: 5356kb

input:

1
)))()()(()))()))(()(())())(()())((((())()))(())()(()))))((((((())))((()(())()((((()())(()())())()()(()(())(()(((()))))(()()((())((((((()))(((((()()))()())()))))((())()())((((()))))())())())()))()()()))())))(((()))((()()((((())))((()()()(())((()()()())()())()()()()(((())(()))())(()))()(()(()())())(...

output:

)))()()(()))()))(()(())())(()())((((())()))(())()(()))))((((((())))((()(())()((((()())(()())())()()(()(())(()(((()))))(()()((())((((((()))(((((()()))()())()))))((())()())((((()))))())())())()))()()()))())))(((()))((()()((((())))((()()()(())((()()()())()())()()()()(((())(()))())(()))()(()(()())())(((...

result:

ok 1 cases (1 test case)

Test #49:

score: 0
Accepted
time: 13ms
memory: 5220kb

input:

1
()(((((((((((((((((((((((((((()((((((((((((((((((((((((((((((((((((((((((()())(()((((((((((()((((((((((((((((((()(()()()((((((((((((()(()((()((((((((((()(((((((((((((((())((((((((((((((((((((((((((((((((((((((((((((((())((((((((((()((((((()(((((((((((((((((((((((((()(()(()(((((((((((()((((((((((((...

output:

()(((((((((((((((((((((((((((()((((((((((((((((((((((((((((((((((((((((((()())(()((((((((((()((((((((((((((((((()(()()()((((((((((((()(()((()((((((((((()(((((((((((((((())((((((((((((((((((((((((((((((((((((((((((((((())((((((((((()((((((()(((((((((((((((((((((((((()(()(()(((((((((((()((((((((((((((...

result:

ok 1 cases (1 test case)

Test #50:

score: 0
Accepted
time: 15ms
memory: 5236kb

input:

1
()()()(()))(()()(())(((((((()(())(((()))))(((()(((())))()((((((()(((((()(((((()((())((((((((((()(((()))()(((()((()(((()))(()((((((((()((((((()((((()((()(((((())((((()())((())(((()(()()((((()()))(())((())(()())()()((((((((((((((((((((((()(()))(()((((()((())((()((((((((((((()()(((((((((((()(()((()((...

output:

()()()(()))(()()(())(((((((()(())(((()))))(((()(((())))()((((((()(((((()(((((()((())((((((((((()(((()))()(((()((()(((()))(()((((((((()((((((()((((()((()(((((())((((()())((())(((()(()()((((()()))(())((())(()())()()((((((((((((((((((((((()(()))(()((((()((())((()((((((((((((()()(((((((((((()(()((()(())...

result:

ok 1 cases (1 test case)

Test #51:

score: 0
Accepted
time: 16ms
memory: 5400kb

input:

1
)())())()(()))()))())()(()((())())))()))(())))))((())))()()))()((((()(()))))))))()))()))())(()))()())))()()())(()())()))))))))()(())(()))()()))())))))()()))()(()))))())()))()))()(()())(()))(()))()))()))(())()())))))()))()()())())))()((())()))))())()))))))())))()()())(()))())))()))))))))()()((())()...

output:

)())())()(()))()))())()(()((())())))()))(())))))((())))()()))()((((()(()))))))))()))()))())(()))()())))()()())(()())()))))))))()(())(()))()()))())))))()()))()(()))))())()))()))()(()())(()))(()))()))()))(())()())))))()))()()())())))()((())()))))())()))))))())))()()())(()))())))()))))))))()()((())()()...

result:

ok 1 cases (1 test case)

Test #52:

score: 0
Accepted
time: 14ms
memory: 5252kb

input:

1
))))))())())())()()))))))))))))))))))))))()))))))))))))))))))()))))))))))))))))()))))))))())))))))))()))))))))))((())))())()(()))()))))()))))))())))()))))())))))))()())()()()))))()))()))))())()))))))))))))(())))))(()))))())))())()()))))()))))))))))))()))))))())))))))))))()))))(())))))))))())))))))...

output:

))))))())())())()()))))))))))))))))))))))()))))))))))))))))))()))))))))))))))))()))))))))())))))))))()))))))))))((())))())()(()))()))))()))))))())))()))))())))))))()())()()()))))()))()))))())()))))))))))))(())))))(()))))())))())()()))))()))))))))))))()))))))())))))))))))()))))(())))))))))())))))))))...

result:

ok 1 cases (1 test case)

Test #53:

score: 0
Accepted
time: 10ms
memory: 5220kb

input:

1
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((()((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

result:

ok 1 cases (1 test case)

Test #54:

score: 0
Accepted
time: 13ms
memory: 5356kb

input:

1
)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))()))))))))))))))))))))())))))))))))))))))))))))))))))))))...

output:

)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))()))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))()))))))))))))))))))))())))))))))))))))))))))))))))))))))))...

result:

ok 1 cases (1 test case)

Test #55:

score: 0
Accepted
time: 31ms
memory: 3540kb

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
impossible
impossible
impossible
impossible
imp...

result:

ok 100000 cases (100000 test cases)

Test #56:

score: 0
Accepted
time: 36ms
memory: 3640kb

input:

50000
(((())()(())))(())))
)((())()(())))(())))
()(())()(())))(())))
))(())()(())))(())))
(()())()(())))(())))
)()())()(())))(())))
())())()(())))(())))
)))())()(())))(())))
((()))()(())))(())))
)(()))()(())))(())))
()()))()(())))(())))
))()))()(())))(())))
(())))()(())))(())))
)())))()(())))(())))
...

output:

(((())()(())))(())))
)((())()(())))(())))
()(())()(())))(())))
))(())()(())))(())))
(()())()(())))(())))
)()())()(())))(())))
())())()(())))(())))
)))())()(())))(())))
((()))()(())))(())))
)(()))()(())))(())))
()()))()(())))(())))
))()))()(())))(())))
(())))()(())))(())))
)())))()(())))(())))
()))))...

result:

ok 50000 cases (50000 test cases)

Test #57:

score: 0
Accepted
time: 36ms
memory: 3840kb

input:

66666
())()(()))())))
)))()(()))())))
((())(()))())))
)(())(()))())))
()())(()))())))
))())(()))())))
(()))(()))())))
)()))(()))())))
())))(()))())))
)))))(()))())))
((((()()))())))
)(((()()))())))
()((()()))())))
))((()()))())))
(()(()()))())))
)()(()()))())))
())(()()))())))
)))(()()))())))
((()()...

output:

())()(()))())))
)))()(()))())))
((())(()))())))
)(())(()))())))
()())(()))())))
))())(()))())))
(()))(()))())))
)()))(()))())))
())))(()))())))
)))))(()))())))
((((()()))())))
)(((()()))())))
()((()()))())))
))((()()))())))
(()(()()))())))
)()(()()))())))
())(()()))())))
)))(()()))())))
((()()()))()...

result:

ok 66666 cases (66666 test cases)

Test #58:

score: 0
Accepted
time: 83ms
memory: 3828kb

input:

200000
(((((
)((((
()(((
))(((
(()((
)()((
())((
)))((
((()(
)(()(
()()(
))()(
(())(
)())(
()))(
))))(
(((()
)((()
()(()
))(()
(()()
)()()
())()
)))()
((())
)(())
()())
))())
(()))
)()))
())))
)))))
(((((
)((((
()(((
))(((
(()((
)()((
())((
)))((
((()(
)(()(
()()(
))()(
(())(
)())(
()))(
))))(
(((()...

output:

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

result:

ok 200000 cases (200000 test cases)

Test #59:

score: 0
Accepted
time: 259ms
memory: 3580kb

input:

1000000
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
...

output:

)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
...

result:

ok 1000000 cases (1000000 test cases)

Extra Test:

score: 0
Extra Test Passed