QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#355541#5108. Prehistoric ProgramsInfinityNS#WA 214ms24416kbC++141.0kb2024-03-16 19:55:422024-03-16 19:55:42

Judging History

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

  • [2024-03-16 19:55:42]
  • 评测
  • 测评结果:WA
  • 用时:214ms
  • 内存:24416kb
  • [2024-03-16 19:55:42]
  • 提交

answer

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

const int N=1e7+50;
char s[N];

int Get1(array<int,3> a){
    if(a[1]>=0)return 0;
    return 1;
}
bool cmp(array<int,3> a,array<int,3> b){
    if(Get1(a)!=Get1(b))return Get1(a)<Get1(b);
    if(Get1(a)==0)return a[0]>b[0];
    return a[0]<b[0];
}
int main(){
    int n;
    scanf("%i",&n);
    vector<array<int,3>> tmp;
    for(int i=1;i<=n;i++){
        scanf("%s",s+1);
        int m=strlen(s+1);
        int bal=0,mn=0;
        for(int j=1;j<=m;j++){
            if(s[j]=='(')bal++;
            else bal--;
            mn=min(mn,bal);
        }
        tmp.pb({mn,bal,i});
    }
    sort(tmp.begin(),tmp.end(),cmp);
    int bal=0;
    bool ok=true;
    for(int i=0;i<tmp.size();i++){
        if(bal+tmp[i][0]<0)ok=false;
        bal+=tmp[i][1];
    }
    if(bal!=0)ok=false;
    if(ok){
        for(int i=0;i<tmp.size();i++)printf("%i\n",tmp[i][2]);
    }else{
        printf("impossible\n");
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 1ms
memory: 3824kb

input:

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

output:

779
268
267
265
711
258
257
778
544
253
252
535
854
247
245
243
242
707
239
553
554
557
522
770
301
517
297
296
948
771
719
291
290
962
287
286
774
282
280
524
852
715
534
271
188
570
573
966
198
197
575
576
577
190
189
566
881
798
584
585
182
181
799
179
178
177
562
229
228
560
788
561
790
223
963
...

result:

ok good plan

Test #3:

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

input:

2
()
()

output:

1
2

result:

ok good plan

Test #4:

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

input:

2
((
))

output:

1
2

result:

ok good plan

Test #5:

score: 0
Accepted
time: 1ms
memory: 4008kb

input:

2
)(
()

output:

impossible

result:

ok impossible

Test #6:

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

input:

3
()
(
)

output:

1
2
3

result:

ok good plan

Test #7:

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

input:

3
)(
(
)

output:

2
1
3

result:

ok good plan

Test #8:

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

input:

5
))(
(()
)(
(
)

output:

2
4
3
1
5

result:

ok good plan

Test #9:

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

input:

3
((
))())
(

output:

1
3
2

result:

ok good plan

Test #10:

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

input:

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

output:

impossible

result:

ok impossible

Test #11:

score: 0
Accepted
time: 1ms
memory: 4088kb

input:

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

output:

205
415
416
214
211
210
209
208
207
414
204
203
420
199
198
196
424
194
228
239
399
401
234
232
404
405
406
192
227
226
409
410
411
412
219
413
159
437
438
166
439
440
442
443
160
436
158
157
156
445
153
152
149
449
431
191
426
427
428
186
429
184
182
240
180
178
177
434
172
171
435
367
325
362
321
...

result:

ok good plan

Test #12:

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

input:

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

output:

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

result:

ok good plan

Test #13:

score: 0
Accepted
time: 1ms
memory: 3784kb

input:

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

output:

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

result:

ok good plan

Test #14:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

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

output:

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

result:

ok good plan

Test #15:

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

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
19
10
32
4
8
14
15
5
26
102
23
117
55
75
80
50
84
18
16
29
113
112
145
107
82
114
76
74
34
63
136
39
53
90
88
144
85
21
140
13
41
7
62
45
122
40
81
96
111
79
97
125
12
116
123
22
108
139
20
115...

result:

ok good plan

Test #16:

score: 0
Accepted
time: 1ms
memory: 3800kb

input:

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

output:

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

result:

ok good plan

Test #17:

score: 0
Accepted
time: 1ms
memory: 3764kb

input:

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

output:

581
263
573
574
259
258
255
578
252
250
246
264
584
243
585
587
238
588
589
590
231
556
530
297
294
541
287
547
549
281
554
555
230
276
274
563
569
269
570
571
572
265
181
195
612
191
618
622
624
186
185
184
182
197
180
625
632
176
175
635
172
636
169
594
229
228
227
591
225
224
592
220
593
526
214
...

result:

ok good plan

Test #18:

score: 0
Accepted
time: 1ms
memory: 3836kb

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
20
6
22
9
4
10
27
28
19
29
18
17
31
11
12
42
95
25
7
63
54
96
2
75
76
77
78
99
98
97
80
5
3
93
92
90
89
83
8
85
16
1
33
34
35
36
30
39
40
41
45
26
47
49
24
73
52
23
55
56
58
21
64
15
14
69
13
71
72

result:

ok good plan

Test #19:

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

input:

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

output:

impossible

result:

ok impossible

Test #20:

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

input:

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

output:

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

result:

ok good plan

Test #21:

score: 0
Accepted
time: 1ms
memory: 4056kb

input:

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

output:

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

result:

ok good plan

Test #22:

score: 0
Accepted
time: 1ms
memory: 3852kb

input:

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

output:

impossible

result:

ok impossible

Test #23:

score: 0
Accepted
time: 1ms
memory: 3736kb

input:

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

output:

impossible

result:

ok impossible

Test #24:

score: 0
Accepted
time: 2ms
memory: 4056kb

input:

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

output:

impossible

result:

ok impossible

Test #25:

score: 0
Accepted
time: 178ms
memory: 15484kb

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: 21ms
memory: 13492kb

input:

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

output:

impossible

result:

ok impossible

Test #27:

score: 0
Accepted
time: 26ms
memory: 13508kb

input:

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

output:

impossible

result:

ok impossible

Test #28:

score: 0
Accepted
time: 22ms
memory: 13796kb

input:

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

output:

1

result:

ok good plan

Test #29:

score: 0
Accepted
time: 18ms
memory: 13536kb

input:

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

output:

impossible

result:

ok impossible

Test #30:

score: 0
Accepted
time: 22ms
memory: 13476kb

input:

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

output:

impossible

result:

ok impossible

Test #31:

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

input:

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

output:

2
1

result:

ok good plan

Test #32:

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

input:

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

output:

impossible

result:

ok impossible

Test #33:

score: 0
Accepted
time: 22ms
memory: 13596kb

input:

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

output:

3
1
2

result:

ok good plan

Test #34:

score: 0
Accepted
time: 101ms
memory: 15628kb

input:

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

output:

impossible

result:

ok impossible

Test #35:

score: 0
Accepted
time: 99ms
memory: 15476kb

input:

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

output:

impossible

result:

ok impossible

Test #36:

score: 0
Accepted
time: 143ms
memory: 15588kb

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: 141ms
memory: 24416kb

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: 214ms
memory: 15728kb

input:

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

output:

628371
628357
628360
628361
628362
628366
249235
628368
249232
249230
628370
249241
628372
628374
628379
249217
628384
628385
628387
249211
249210
249208
249252
249263
628332
628334
249260
249258
249257
249256
628341
249254
249253
628394
628346
628347
628348
628350
249246
628351
249244
628354
628355...

result:

ok good plan

Test #39:

score: 0
Accepted
time: 200ms
memory: 15636kb

input:

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

output:

683984
478548
212277
212276
212275
683980
683981
212272
683982
478547
683977
349893
349894
683990
212264
683995
683997
212261
212260
684000
212289
683946
212299
683954
683955
212294
683956
683958
683960
683962
684001
683964
349888
212286
683967
683969
683970
212282
212280
684055
684039
684041
684043...

result:

ok good plan

Test #40:

score: 0
Accepted
time: 48ms
memory: 4196kb

input:

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

output:

163
469
537
542
305
108
253
358
105
360
287
367
236
307
93
563
359
17
243
329
541
528
95
267
65
445
134
75
465
356
513
100
26
113
302
514
44
405
342
555
54
281
531
265
547
340
133
153
139
286
350
451
301
421
52
11
255
483
24
299
408
32
463
235
81
529
330
533
553
223
552
373
510
43
327
137
443
111
53...

result:

ok good plan

Test #41:

score: -100
Wrong Answer
time: 51ms
memory: 4180kb

input:

109
)(()((())()(())())))))((()(((()((()()())))()))()()()()))(()(()()((()()())())()))())(((()()))(()))))(()((()((()()(((()))()((((()(()()()(()))))))))())((())(())()((()))))((())()()())))))(())))())()())))())()(()))))(())()(((()((((()))))((()())()())())))())((()(()())()())((((()()(()((()))(())((()((()...

output:

impossible

result:

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