QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#355543#5108. Prehistoric ProgramsInfinityNS#WA 217ms24564kbC++141.1kb2024-03-16 20:02:112024-03-16 20:02:11

Judging History

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

  • [2024-03-16 20:02:11]
  • 评测
  • 测评结果:WA
  • 用时:217ms
  • 内存:24564kb
  • [2024-03-16 20:02:11]
  • 提交

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(a[0]!=b[0]){
        if(Get1(a)==0)return a[0]>b[0];
        return a[0]<b[0];
    }else{
        return a[1]>b[1];
    }
}
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;
}

详细

Test #1:

score: 100
Accepted
time: 11ms
memory: 4124kb

input:

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

output:

41248
4238
13809
27609
5338
2458
389
48374
6754
48749
18533
42979
14096
6986
5803
169
23456
32583
3405
31692
43508
38930
26695
26677
34539
9225
10427
46194
25061
35132
11398
46429
41740
21764
39743
30771
2253
24373
5699
31402
35039
45491
33777
23312
34110
39389
35743
6381
41639
41641
28794
23551
979...

result:

ok good plan

Test #2:

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

input:

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

output:

36
13
66
386
966
585
286
257
127
83
39
476
595
329
814
214
598
907
427
981
62
662
131
384
707
793
511
807
449
379
869
271
767
80
638
327
746
474
422
239
632
387
20
915
919
296
88
535
168
553
473
334
715
171
975
989
31
345
502
481
819
464
98
177
725
881
208
164
799
738
778
731
604
134
667
640
258
33
...

result:

ok good plan

Test #3:

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

input:

2
()
()

output:

1
2

result:

ok good plan

Test #4:

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

input:

2
((
))

output:

1
2

result:

ok good plan

Test #5:

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

input:

2
)(
()

output:

impossible

result:

ok impossible

Test #6:

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

input:

3
()
(
)

output:

2
1
3

result:

ok good plan

Test #7:

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

input:

3
)(
(
)

output:

2
1
3

result:

ok good plan

Test #8:

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

input:

5
))(
(()
)(
(
)

output:

2
4
3
1
5

result:

ok good plan

Test #9:

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

input:

3
((
))())
(

output:

1
3
2

result:

ok good plan

Test #10:

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

input:

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

output:

impossible

result:

ok impossible

Test #11:

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

input:

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

output:

479
311
329
232
483
199
443
350
80
253
414
211
265
297
177
357
413
203
205
207
208
156
209
445
210
153
214
416
415
152
149
157
219
412
411
410
449
409
226
227
228
176
406
405
404
143
431
442
440
439
166
437
436
435
171
172
160
434
159
178
180
420
182
158
184
429
186
428
427
426
191
192
194
424
196
1...

result:

ok good plan

Test #12:

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

input:

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

output:

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

result:

ok good plan

Test #13:

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

input:

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

output:

26
5
11
2
47
46
41
40
28
18
16
13
8
15
33
37
4
42
44
3
19
10
29
21
6
31
12
36
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: 3776kb

input:

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

output:

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

result:

ok good plan

Test #15:

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

input:

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

output:

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

result:

ok good plan

Test #16:

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

input:

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

output:

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

result:

ok good plan

Test #17:

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

input:

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

output:

468
163
390
379
204
396
707
585
590
1
4
122
405
658
657
601
79
34
274
104
180
473
158
681
547
571
504
705
269
485
108
149
526
730
25
246
103
341
481
408
55
56
426
164
530
156
131
606
406
494
166
395
382
43
218
41
418
230
228
429
446
593
231
592
229
263
238
427
589
588
243
587
419
584
250
581
255
258...

result:

ok good plan

Test #18:

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

input:

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

output:

43
37
48
66
32
38
44
46
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
95
42
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: 3720kb

input:

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

output:

impossible

result:

ok impossible

Test #20:

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

input:

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

output:

51
41
86
73
26
72
29
30
70
69
33
68
66
65
62
38
39
61
42
43
60
57
46
47
53
49
16
6
7
92
9
87
11
12
5
15
94
84
19
95
21
22
80
76
98
14
85
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: 0ms
memory: 3852kb

input:

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

output:

60
78
79
48
80
46
45
82
83
42
41
85
38
37
36
35
33
49
2
52
53
54
55
56
58
59
77
75
65
73
1
95
96
4
97
18
98
19
9
21
22
8
7
6
26
28
29
31
88
69
14
76
99
15
93
64
30
74
92
66
100
72
94
81
91
90
84
89
86
87
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: 3692kb

input:

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

output:

impossible

result:

ok impossible

Test #23:

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

input:

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

output:

impossible

result:

ok impossible

Test #24:

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

input:

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

output:

impossible

result:

ok impossible

Test #25:

score: 0
Accepted
time: 177ms
memory: 15548kb

input:

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

output:

149392
264227
387984
770337
898404
995820
83071
269214
349084
857929
897909
731069
174818
604894
385160
196234
765299
352796
760108
904916
134097
526593
708004
308325
748267
992894
309146
911588
501576
540367
592970
675083
489285
197429
900795
342091
160328
474263
619800
507757
475916
267140
610823
...

result:

ok good plan

Test #26:

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

input:

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

output:

impossible

result:

ok impossible

Test #27:

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

input:

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

output:

impossible

result:

ok impossible

Test #28:

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

input:

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

output:

1

result:

ok good plan

Test #29:

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

input:

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

output:

impossible

result:

ok impossible

Test #30:

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

input:

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

output:

impossible

result:

ok impossible

Test #31:

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

input:

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

output:

2
1

result:

ok good plan

Test #32:

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

input:

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

output:

impossible

result:

ok impossible

Test #33:

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

input:

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

output:

3
1
2

result:

ok good plan

Test #34:

score: 0
Accepted
time: 96ms
memory: 15520kb

input:

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

output:

impossible

result:

ok impossible

Test #35:

score: 0
Accepted
time: 88ms
memory: 15416kb

input:

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

output:

impossible

result:

ok impossible

Test #36:

score: 0
Accepted
time: 154ms
memory: 15440kb

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: 24564kb

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: 217ms
memory: 15580kb

input:

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

output:

510441
164663
483356
944202
500584
889056
763948
163748
496501
637097
90286
732016
679768
879218
183559
590693
911154
924596
321244
428626
629235
261112
598737
480176
475331
970762
651410
67591
323909
378339
295142
480934
740159
880821
235797
947844
354542
850025
553153
451519
130656
491924
897141
7...

result:

ok good plan

Test #39:

score: 0
Accepted
time: 208ms
memory: 15516kb

input:

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

output:

568499
250826
675014
494698
629151
985988
795023
425960
536620
300744
463859
926090
561779
106383
597972
575206
137311
689231
129338
930603
427235
333208
746420
207485
963161
353729
388609
696104
623824
487205
123122
905927
997127
834142
470327
116108
770416
122925
209291
357972
902316
713994
287685...

result:

ok good plan

Test #40:

score: 0
Accepted
time: 56ms
memory: 3996kb

input:

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

output:

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

result:

ok good plan

Test #41:

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

input:

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

output:

impossible

result:

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