QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#664479#7683. Hard Brackets Problemi0streamAC ✓235ms5456kbC++14336b2024-10-21 20:51:282024-10-21 20:51:29

Judging History

This is the latest submission verdict.

  • [2024-10-21 20:51:29]
  • Judged
  • Verdict: AC
  • Time: 235ms
  • Memory: 5456kb
  • [2024-10-21 20:51:28]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

int T;
string s;

int main(){
	scanf("%d",&T);
	while (T--){
		cin>>s;
		int c=0,j=s.size()-1,succ=1;
		for (int i=s.size()-1;i>=0;i--){
			if (s[i]==')') c++;
			else c--;
			if (c<0) succ=0;
		}
		if (!succ) puts("impossible");
		else cout<<s<<endl;
	}
	return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok 3 cases (3 test cases)

Test #2:

score: 0
Accepted
time: 59ms
memory: 3684kb

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: 75ms
memory: 3816kb

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: 64ms
memory: 3676kb

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: 24ms
memory: 3600kb

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: 31ms
memory: 3676kb

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: 88ms
memory: 3796kb

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: 27ms
memory: 3804kb

input:

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

output:

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

result:

ok 50000 cases (50000 test cases)

Test #9:

score: 0
Accepted
time: 23ms
memory: 3620kb

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: 87ms
memory: 3628kb

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: 51ms
memory: 3820kb

input:

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

output:

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

result:

ok 50000 cases (50000 test cases)

Test #12:

score: 0
Accepted
time: 27ms
memory: 3660kb

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: 76ms
memory: 3816kb

input:

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

output:

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

result:

ok 250000 cases (250000 test cases)

Test #14:

score: 0
Accepted
time: 23ms
memory: 3812kb

input:

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

output:

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

result:

ok 50000 cases (50000 test cases)

Test #15:

score: 0
Accepted
time: 55ms
memory: 3676kb

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: 16ms
memory: 5448kb

input:

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

output:

impossible

result:

ok 1 cases (1 test case)

Test #17:

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

input:

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

output:

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

result:

ok 2 cases (2 test cases)

Test #18:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #19:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #20:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #21:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #22:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #23:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #24:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #25:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #26:

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

input:

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

output:

impossible

result:

ok 1 cases (1 test case)

Test #27:

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

input:

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

output:

impossible

result:

ok 1 cases (1 test case)

Test #28:

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

input:

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

output:

impossible

result:

ok 1 cases (1 test case)

Test #29:

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

input:

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

output:

impossible

result:

ok 1 cases (1 test case)

Test #30:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #31:

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

input:

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

output:

impossible

result:

ok 1 cases (1 test case)

Test #32:

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

input:

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

output:

impossible

result:

ok 1 cases (1 test case)

Test #33:

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

input:

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

output:

impossible

result:

ok 1 cases (1 test case)

Test #34:

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

input:

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

output:

impossible

result:

ok 1 cases (1 test case)

Test #35:

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

input:

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

output:

impossible

result:

ok 1 cases (1 test case)

Test #36:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #37:

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

input:

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

output:

impossible

result:

ok 1 cases (1 test case)

Test #38:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #39:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #40:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #41:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #42:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #43:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #44:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #45:

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

input:

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

output:

impossible

result:

ok 1 cases (1 test case)

Test #46:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #47:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #48:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #49:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #50:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #51:

score: 0
Accepted
time: 11ms
memory: 5280kb

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: 12ms
memory: 5284kb

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #54:

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

input:

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

output:

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

result:

ok 1 cases (1 test case)

Test #55:

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

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: 23ms
memory: 3664kb

input:

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

output:

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

result:

ok 50000 cases (50000 test cases)

Test #57:

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

input:

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

output:

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

result:

ok 66666 cases (66666 test cases)

Test #58:

score: 0
Accepted
time: 52ms
memory: 3724kb

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: 235ms
memory: 3816kb

input:

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

output:

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

result:

ok 1000000 cases (1000000 test cases)

Extra Test:

score: 0
Extra Test Passed