QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#355128#5108. Prehistoric Programsucup-team052#WA 227ms68216kbC++231.1kb2024-03-16 13:41:462024-03-16 13:41:47

Judging History

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

  • [2024-03-16 13:41:47]
  • 评测
  • 测评结果:WA
  • 用时:227ms
  • 内存:68216kb
  • [2024-03-16 13:41:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define N 1000005
string s[N];
int mn[N],sum[N],id[N],vis[N];
int n;
signed main()
{
#ifdef xay5421
	freopen("a.in","r",stdin);
#endif
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;i++)
	{
		int l=s[i].length();
		int cur=0;
		for(int j=0;j<l;j++)
		{
			if(s[i][j]=='(') cur++;
			else cur--;
			mn[i]=min(mn[i],cur);
		}
		sum[i]=cur;
		id[i]=i;
	}
// 	for(int i=1;i<=n;i++) printf("%d %d\n",mn[i],sum[i]);
	sort(id+1,id+n+1,[&](int x,int y){return mn[x]>mn[y];});
	vector<int> ans;
	int cur=0;
	for(int i=1;i<=n;i++)
	{
		int u=id[i];
		if(mn[u]+cur>=0&&sum[u]>=0)
		{
			vis[u]=1,ans.push_back(u);
			cur+=sum[u];
		}
	}
	sort(id+1,id+n+1,[&](int x,int y){return -sum[x]-mn[x]>-sum[y]-mn[y];});
	for(int i=1;i<=n;i++)
	{
		int u=id[i];
		if(!vis[u]&&mn[u]+cur>=0)
		{
			cur+=sum[u];
			ans.push_back(u);
			vis[u]=1;
		}
	}
	if((int)ans.size()!=n||cur!=0) printf("impossible\n");
	else
	{
		for(int i:ans) printf("%d\n",i);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 40620kb

input:

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

output:

26700
26740
26738
26737
26729
26727
26724
26723
26716
26715
26714
26713
26711
26709
26703
26744
26698
26696
26695
26693
26692
26689
26685
26682
26679
26677
26674
26672
26671
26670
26779
26819
26817
26815
26813
26810
26809
26806
26803
26802
26800
26792
26787
26784
26783
26668
26778
26777
26776
26773
...

result:

ok good plan

Test #2:

score: 0
Accepted
time: 0ms
memory: 40264kb

input:

1000
(
))(()))
((((())())))((())(()))(
)(
)
)))
))((()(((((((())()(())()())))(()(())()())))))))((()((()())()())(())))()((()())
)((()()()(())(()))()(())()))(()))))())))))))))))))()))(()()(())(()))())()()))))(())()()()((())(()))(())))))))(()()())()))()())))()()))))))(
)))(((
(
)))()()())))
(
(((())(((...

output:

715
296
687
689
291
290
287
286
282
280
707
711
297
271
719
268
267
265
725
731
732
738
258
316
650
652
329
653
327
655
324
659
662
663
666
257
667
668
313
673
309
680
681
301
685
686
790
779
217
216
215
214
213
212
209
208
206
788
778
198
197
793
798
799
190
189
188
801
803
757
253
252
746
747
748
...

result:

ok good plan

Test #3:

score: 0
Accepted
time: 3ms
memory: 40384kb

input:

2
()
()

output:

1
2

result:

ok good plan

Test #4:

score: 0
Accepted
time: 0ms
memory: 40772kb

input:

2
((
))

output:

1
2

result:

ok good plan

Test #5:

score: 0
Accepted
time: 0ms
memory: 40732kb

input:

2
)(
()

output:

impossible

result:

ok impossible

Test #6:

score: 0
Accepted
time: 0ms
memory: 40808kb

input:

3
()
(
)

output:

1
2
3

result:

ok good plan

Test #7:

score: 0
Accepted
time: 3ms
memory: 39344kb

input:

3
)(
(
)

output:

2
1
3

result:

ok good plan

Test #8:

score: 0
Accepted
time: 3ms
memory: 39792kb

input:

5
))(
(()
)(
(
)

output:

2
4
3
1
5

result:

ok good plan

Test #9:

score: 0
Accepted
time: 3ms
memory: 39408kb

input:

3
((
))())
(

output:

1
3
2

result:

ok good plan

Test #10:

score: 0
Accepted
time: 4ms
memory: 39872kb

input:

6
)
()
()()()
((
)
)

output:

impossible

result:

ok impossible

Test #11:

score: 0
Accepted
time: 4ms
memory: 39340kb

input:

500
(
)
)
(
)(
(
(
)
))(
(
(
(
(
)
)
(
(
)
(
(
)
(
()(()
(
)())
(
(
)
(
)()((
(
)
(
)
)
(
(
(
)
(
(
)
)
)(
(
(
)
)
(
)
(
(
(
)
(
(
())))
(
(
(
)
(
)
)
(
(
)
)
(
(
(
(
(
()
(
(
(
(
(
((
)
(
(
)
(
(
(
)
())
(
(
(
)
(
(
(
)
)
(
)
)
(
)
(
(
(
(
)
(
)
)
)
)
(
)
)))()(
(
)
)
(
)
)(
)
(
)
)
))
(
(
(
(
(
(
...

output:

194
204
203
404
405
406
199
198
196
205
409
192
191
410
411
412
413
186
399
228
227
226
392
393
395
219
398
414
214
401
211
210
209
208
207
149
160
159
158
157
156
431
153
152
429
434
435
436
437
438
143
439
141
420
184
415
182
416
180
178
177
176
388
172
171
424
166
426
427
428
353
304
345
348
349
...

result:

ok good plan

Test #12:

score: 0
Accepted
time: 0ms
memory: 39948kb

input:

50
)
)
((((()())())))(())(())
()(((()))
(((()))(()
()(((
))
)
)()))(()(()())(((((()
(
)
)
)((
)()((
())()))
(())))()
(((
))))(()
()(())(()))())()
)
)
(
(
(
(
((())()())())))(((())
()(
(()(())()((()
()(((()())))())()(
)
)((()
(
)
((
)
()(
(
(
)
)))((())
)
()))()(((()(()
((
((()))(())(()())(()())())()...

output:

34
27
25
24
23
22
28
17
32
36
37
10
38
43
6
5
4
3
31
29
46
14
13
42
9
45
44
50
49
18
15
40
48
19
16
7
26
47
41
8
11
12
20
21
1
30
33
39
2
35

result:

ok good plan

Test #13:

score: 0
Accepted
time: 0ms
memory: 40556kb

input:

50
)
(
)()(
())(
()()(((((())(
)(())(()((())(()(()))(())())))))(())()))()())))))()(()()))(())))(()(((())(())()((())())()())(())())))()((()(()(())((()()))))()((((())()())((()))))((()()(())))))(()(())(()(()((())(()(())((()())))())(()))()())))()()((((()()((()()))((())())))()(())((()()((()((())())(()(()...

output:

2
47
46
41
40
33
28
26
18
16
15
13
11
8
5
37
4
42
44
3
10
19
29
21
6
31
36
12
17
39
23
49
50
48
1
24
45
14
32
9
38
35
34
43
20
22
25
27
7
30

result:

ok good plan

Test #14:

score: 0
Accepted
time: 3ms
memory: 40548kb

input:

150
))(()))(())(())))()))())()()()(())(((())))()))))()
)))()(()()(()((())())))(()(()(())((())))(((()(((())()()())))()())(((((((()))((())((())(())())(()))()(()()()()((((()))(()())))()(()((()(()(((((()((()())()))((((()))()))(()(((()()(((()(((()(((())(())())(()((()))))))()())((()(())())))((()()(()(((()...

output:

111
32
136
35
37
38
40
130
48
49
52
53
120
60
149
69
106
73
105
104
79
103
84
100
87
98
92
94
14
143
12
20
142
11
17
7
6
4
24
141
140
15
148
28
10
70
62
5
89
91
93
96
51
133
23
129
135
27
117
137
16
61
102
147
77
29
125
122
2
3
9
25
115
56
47
43
41
18
86
134
150
59
85
30
45
19
55
72
71
127
81
116
50...

result:

ok good plan

Test #15:

score: 0
Accepted
time: 0ms
memory: 41092kb

input:

150
)))(
(()
(())((())))(()))()(()
((((()(((()))()(((((())()(()()((((()))((((()(())()(()))(()(())())(())(())))(((()))(())()))()((())((()(()(())())))))()(((()(()()())()))))()))(()(()()()(()(())()))))()))(((((())(()())((()()((((()))))(())())(())(())((()()(())))((((())((((()))()))()))))))))()())))))
(
...

output:

87
36
37
42
44
46
49
51
52
56
58
61
64
66
70
86
2
89
94
98
100
104
118
121
127
128
129
141
142
148
149
150
10
26
5
19
15
8
4
32
14
16
117
75
113
112
80
107
84
18
145
29
102
50
55
23
114
34
136
82
74
76
63
39
53
88
90
144
85
21
140
13
7
41
62
45
122
81
96
40
79
111
12
125
97
123
116
22
115
108
138
12...

result:

ok good plan

Test #16:

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

input:

150
)()((
)
)))())))
)()())((()(()())((())()))(()))(())((((((((()()(())())(()(((()))())()((()((())())))))))()((()))))((()(((()(((((()))()))((()((()()))(())))))()))))()())()()())(())(())(()))())((((((()()()))()((((()))))))((())()))()(()((()(())(())(())()())(())
()()
)
(())()))(())(()((())()()())())((...

output:

118
68
67
30
65
106
123
122
36
108
60
27
110
117
115
45
58
48
50
111
52
55
84
93
81
8
92
140
97
99
136
98
131
75
130
129
74
5
89
149
56
57
63
1
88
70
100
11
9
19
127
24
26
31
124
42
46
91
146
128
101
120
119
114
35
15
14
82
37
133
107
43
32
90
12
78
44
112
61
7
64
109
125
134
72
85
71
77
95
116
20
1...

result:

ok good plan

Test #17:

score: 0
Accepted
time: 0ms
memory: 40760kb

input:

750
(()()((()((((())()((()))()()))()))(()()(()))(()(())()))((((((
)))))))
)
((()()()(())((()(()())(())(((()((((()))(()(())((())(()())(())())))())))()(())()))((()(()((((()(()))(()())()((()()()))))(())())(())())())()((()(
)
)
(
)()(((()(())))()))))(((((((()))()()()(()())))(()())(()((
(
)
)(()))
((())(...

output:

228
246
243
541
238
547
549
231
230
229
530
227
554
225
224
555
556
220
218
563
512
500
276
502
274
504
269
265
264
263
214
516
518
259
258
522
255
526
252
250
594
186
185
184
591
182
181
180
592
593
590
176
175
172
169
601
166
164
163
162
574
213
212
569
208
570
571
572
204
573
281
197
581
195
584
...

result:

ok good plan

Test #18:

score: 0
Accepted
time: 0ms
memory: 40596kb

input:

100
)
)
)
(
)
(
))))()
)
(
(
(
(
)
)
)
)
(
(
(
(
())
(
)
)
)((
)
(
(
(
)
(
(
)
)
)
)
()((
(
)
)
)
)(((
((((
(
)
(
)
((
)
(
(
)
(
())(()))
)
)
(
)
(
(
(
(
)))()()
)
(
(
(
(
)
(
)
)
)
(
)
)
)
)
(
)
(
(
)
(
)
(
(
(
)
)
(
)
)
(
)((((
)
)
()((()()(()))))
)
(

output:

66
32
37
38
43
44
46
48
50
53
57
59
60
61
62
65
51
67
68
70
74
79
81
82
84
86
87
88
91
94
100
28
10
9
11
22
6
20
19
4
27
18
17
29
31
12
95
42
25
7
63
54
34
77
33
69
2
99
98
97
96
3
93
92
90
89
5
85
16
83
80
71
72
73
78
1
13
14
15
64
21
58
56
55
23
52
35
24
49
47
26
45
41
40
39
30
36
76
75
8

result:

ok good plan

Test #19:

score: 0
Accepted
time: 4ms
memory: 40144kb

input:

100
)
()(
(
)
(
)
(
(
)
)
)(()
)
)))
)
)
(
(
(
)
(
(
)
(
)
(
(
(
))(
(
(
))((
(
)
(
))())
)
(()
)
)
(
)
(
(
)
)
(
)
(
))
(
(
)
)
(
)
)
)
)
(
())
)
(
(
)
)
(
)
(
))
(
)
)
(
(
(((
(
(
(()
)
)()())(()((()((())
(
)
)
(
(
)
)
(
)
(
)
(
))(
)
(
(
(
)
(
(((())

output:

impossible

result:

ok impossible

Test #20:

score: 0
Accepted
time: 3ms
memory: 39304kb

input:

100
)
)
()))((((
))()
(
(
(
)
(
)
(
(
)
()
(
(
)
)
(
)
(
(
)
)
)
(
)
)
(
(
)
)
(
)
)
)
)
(
(
)
((
(
(
)
)
(
(
)
(
)
(()((
)
(
)
)
(()))()()())))()()((
(
)
)
(
(
(
)
)
(
(
)
(
(
(
)
(
(
)
)(
(
)
)
)
(
(())())(()
)
)
(
()
((
(
)
)
)
)
(
)
(
(
)
)
(
())
)(

output:

76
30
86
85
33
38
39
80
41
42
43
46
47
49
84
51
53
73
72
57
70
60
61
62
69
68
65
66
21
95
14
15
16
12
94
11
19
92
22
9
7
6
5
98
26
29
87
75
81
100
3
56
4
20
97
18
17
13
10
8
2
34
88
89
83
82
90
91
79
78
93
77
74
99
71
96
59
36
37
40
44
45
48
50
52
35
55
58
23
63
64
54
67
32
31
28
27
25
24
1

result:

ok good plan

Test #21:

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

input:

100
(
(
)
(
)
(
(
(
(
)
)
)
)
()
)(
)
)
(
(
)
(
(
)
)
)
(
)
(
(
))))
(
)
(
)
(
(
(
()()(
)
())
(
(
)
)
(
(
)
(
(
)
)
(
(
(
(
(
)
(
(
(((
)
)
)
))))
(
))(
)
)
()
())()
)
)
(
)))
(
)((()))(
(
(((
((
(
)
(
(
)
(
)
)
()
)()
)
)
()))()(
)(())(
)
(
(
(
(
)(
)

output:

48
33
83
35
36
37
38
82
41
42
80
79
45
46
78
2
49
77
52
53
54
55
56
75
58
59
60
73
65
69
19
7
8
9
98
97
96
95
6
14
31
4
18
21
22
88
1
26
28
29
85
99
76
93
15
30
64
74
66
92
13
94
12
11
10
5
3
32
84
86
87
81
89
90
91
68
100
70
71
72
43
61
63
57
51
34
50
47
16
44
40
39
67
27
25
24
23
62
20
17

result:

ok good plan

Test #22:

score: 0
Accepted
time: 4ms
memory: 39428kb

input:

1000
(())())()(((())()())(((()(()))((()((((()())))())))))(()(()((())(((()))()(()
)
(
)
()
)
)((()))))
)
((((((()))()())))))((()(
((
()(()())))(()
)()
(
((
(
)
)
)(()
)))(
)
))
(
(()))))
)(())(((())((((
)
)
(
(
())))(())
(((
(
(((
())()(
()())
)
)
)
(
))))())(
)
))(
)
())(()(()))))()(()((())((((()())...

output:

impossible

result:

ok impossible

Test #23:

score: 0
Accepted
time: 4ms
memory: 40320kb

input:

1000
))(()))
(
)))(
)
((
()))()))))()()(
))))((((((((()()(())((()()
(
)
)()(()
(
()))))()
(
(()(()(((()())(((((((())()()())())(())()))))((()((())((((((()(()()
)(()())((()))
(((
)
)
(
)((
(
(
)
(
)
()(())(((
(
)
(
(
)
()(()(()()(()()((()))())((()())))))((())(((()()(())(()()())(()()(((())()(()((((((((...

output:

impossible

result:

ok impossible

Test #24:

score: 0
Accepted
time: 0ms
memory: 40152kb

input:

4000
(
)
))
)()))))(
(
)
(
)
)
)
)((()((
(
)
)()(
)
)
)
)
(
)
(
)
)
(
()))((()))))()((()(
(
)))
(
)
(
(
(
(
)
)()(()()(()()))))())
)
)
)(((
)
)
)
)
(
(
)
))()()))((())
(
(
)
(
))(
(
)
)
(
)
)
())(
)
(
(
(
)
())))(())((()(()()((()((
(
)
)
(
)
)
)
)
)
)
)
)
(
)
(()))))(
)
)
(
())))(((())()(
(
(
()(
(
...

output:

impossible

result:

ok impossible

Test #25:

score: 0
Accepted
time: 166ms
memory: 60932kb

input:

1000000
)
(
)()(((()))(
(
(
(
)
(
(
)
)
(((())((()(()((())
(
)
)(
)
)
))))(()))()())(()((()))(()()()))()()()))))))))(())))((((()(()()))((((((()((((()()(
)
((
)
)
(
)
())()()((
)
)))(())((()))((()()))(()(())())))())))())))(()()(
(
()(
(
(
()()
)
))
)
(
(
(
)
)
)
(
)
(
)
)
)
)(()))()))
(
)
)))
(
)
(
(...

output:

541083
541063
541066
541070
541071
541072
541073
541075
541077
541082
541062
541084
541085
541087
541088
541093
541094
541097
541104
541108
541046
541031
541032
541035
541038
541039
541041
541042
541044
541045
541109
541051
541052
541053
541054
541055
541057
541058
541060
541162
541148
541150
541153...

result:

ok good plan

Test #26:

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

input:

1
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

impossible

result:

ok impossible

Test #27:

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

input:

1
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))...

output:

impossible

result:

ok impossible

Test #28:

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

input:

1
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

1

result:

ok good plan

Test #29:

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

input:

1
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

impossible

result:

ok impossible

Test #30:

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

input:

1
((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...

output:

impossible

result:

ok impossible

Test #31:

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

input:

2
))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))...

output:

2
1

result:

ok good plan

Test #32:

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

input:

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

output:

impossible

result:

ok impossible

Test #33:

score: 0
Accepted
time: 20ms
memory: 54204kb

input:

3
)()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()(...

output:

3
1
2

result:

ok good plan

Test #34:

score: 0
Accepted
time: 62ms
memory: 54028kb

input:

1000000
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((((((
((((((...

output:

impossible

result:

ok impossible

Test #35:

score: 0
Accepted
time: 60ms
memory: 47884kb

input:

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

output:

impossible

result:

ok impossible

Test #36:

score: 0
Accepted
time: 108ms
memory: 54916kb

input:

1000000
))))))))))
((((((((((
))))))))))
((((((((((
))))))))))
((((((((((
))))))))))
((((((((((
))))))))))
((((((((((
))))))))))
((((((((((
))))))))))
((((((((((
))))))))))
((((((((((
))))))))))
((((((((((
))))))))))
((((((((((
))))))))))
((((((((((
))))))))))
((((((((((
))))))))))
((((((((((
))))))...

output:

555562
555542
555544
555546
555548
555550
555552
555554
555556
555558
555560
555540
555564
555566
555568
555570
555572
555574
555576
555578
555580
555520
555502
555504
555506
555508
555510
555512
555514
555516
555518
555582
555522
555524
555526
555528
555530
555532
555534
555536
555538
555644
555624...

result:

ok good plan

Test #37:

score: 0
Accepted
time: 115ms
memory: 68216kb

input:

999999
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)...

output:

666672
666657
666658
666659
666660
666661
666662
666663
666664
666665
666666
666667
666668
666669
666670
666671
666656
666673
666674
666675
666676
666677
666678
666679
666680
666681
666682
666683
666684
666685
666686
666641
666626
666627
666628
666629
666630
666631
666632
666633
666634
666635
666636...

result:

ok good plan

Test #38:

score: 0
Accepted
time: 216ms
memory: 65200kb

input:

1000000
)(
()(()))()((
)())
)()((((((
((((
))))))))()())((()(
)((
)())
))()((()
()
(
)(
()(
(((()((()())(()))(((())(((
)()()
)))(
(((
(()(()(())))(())))(((((
())())((()))(
(())
(()
()))(()(())()())(
())((
)))))))))
())()((())))(
()())((((()())()
((
()())
()((())
)()))))))))()())()))())
()())
)()())
...

output:

666770
666751
666753
269783
666756
666761
666764
269776
269775
666767
666768
269771
666749
269768
269766
666774
666775
269763
269761
269760
269758
666779
269755
269800
666719
269811
666724
666728
269808
666730
269805
666732
666735
269801
666783
269798
269797
269796
666739
666740
666741
269792
269791...

result:

ok good plan

Test #39:

score: 0
Accepted
time: 227ms
memory: 64636kb

input:

1000000
)()))))(()(((()
()((((()))
)())
)
()()(
()
())()((())))))())()(())(())
())))()())((
)()()((()((())
)
)()(
()()(
((())((
)(
(
)((()((()((()(())(()())
))()
())
()()()
(())
))()(()(()()()()((
(())))()((((()()(
(())
)())((()))
))(()
()()()(()(()()((((())))((())))(()()(()))))
(()()))()(())))()))(...

output:

748429
748421
204482
204481
204480
748423
204478
382165
528819
528818
204484
318078
204472
345736
748437
204469
204468
748441
204466
204493
748406
204501
318077
748408
204498
204497
748410
748414
528820
748443
204492
204491
748416
204489
204488
748417
204486
748419
748475
607857
204445
382178
748469...

result:

ok good plan

Test #40:

score: -100
Wrong Answer
time: 48ms
memory: 51388kb

input:

564
)())((())((()))))(()())((((()()(()(()))(()((((()()))(((()))(()()()(()((()()()()((()))))((())))()(()((())(()())))))))())))(((())()()()))))()((((()()))()(()()())))(()()(())((())((()())(()()())()(((()))()())())))(((()(((((()())()())))()()((())))()()()(()()))()(()()()(((())())))(()(()(()((())()((()(...

output:

impossible

result:

wrong answer you didn't find a solution but jury did