QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#69639#5108. Prehistoric Programsricky0129AC ✓451ms75004kbC++172.1kb2022-12-29 03:44:132022-12-29 03:44:14

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-29 03:44:14]
  • 评测
  • 测评结果:AC
  • 用时:451ms
  • 内存:75004kb
  • [2022-12-29 03:44:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define FOR(i,n) for(int i=0;i<n;i++)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second

const int MOD = (int)1e9+7;

struct obj{
//    string val;
    int idx;
    int sum, left,right;
    obj(int sum=0,int left=0,int right=0) : sum(sum), left(left), right(right) {} 
    bool operator< (obj lhs) const {
        if(sum<=0 == lhs.sum<=0){
            if(sum<=0){
                return tie(left,sum)<tie(lhs.left,lhs.sum);
            }
            else return tie(right,sum)<tie(lhs.right,lhs.sum);
        }
        return tie(sum)<tie(lhs.sum);
    }
};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<string> C;
    int n;
    cin>>n;
    vector<obj> A;
    FOR(i,n){
        string in;
        cin>>in;
        int curr = 0;
        int mini = INT_MAX;
        FOR(j,sz(in)){
            if(in[j]=='(') curr++;
            else curr--;
            mini = min(mini,curr);
        }
        int sum = curr;
        int maxi = INT_MAX;
        curr = 0;
        for(int j=sz(in)-1;j>=0;j--){
            if(in[j]==')') curr++;
            else curr--;
            maxi = min(maxi,curr);
        }
        obj x(-sum,-mini,maxi);
        x.idx = i;
        C.pb(in);
        A.pb(x);
    }
    sort(A.begin(),A.end());
    //for(auto x: A) cout<<x.val<<endl;
    bool check = true;
    int open = 0;
    int close = 0;
    for(obj x: A){
        //string in = x.val;
        FOR(i,sz(C[x.idx])){
            if(C[x.idx][i]==')') close++;
            else open++;
            if(close>open) check = false;
        }
    }
    if(open!=close) check = false;
    if(!check) cout<<"impossible\n";
    else{
        for(obj x: A){
            //cout<<x.idx<<endl;
            printf("%d\n",x.idx+1);
        }
    }

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 19ms
memory: 6584kb

input:

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

output:

4238
2458
48374
389
6754
18533
6986
32583
23456
169
5803
31692
34539
10427
26677
35132
30771
39743
41740
24373
46194
25061
45491
5699
34110
23312
31402
33777
41641
28794
23551
41639
6701
7365
6381
35743
22710
42121
40415
3880
34723
20865
11768
35499
40332
30949
34479
15279
31817
35256
27864
17649
25...

result:

ok good plan

Test #2:

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

input:

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

output:

36
66
386
585
257
127
39
814
907
329
598
62
981
707
384
131
662
793
511
807
449
271
327
632
474
422
746
387
20
334
553
535
171
473
989
502
31
915
88
919
168
715
738
945
60
863
820
667
324
859
316
134
98
799
725
604
852
929
258
208
414
563
17
881
33
464
947
390
872
774
566
406
819
164
640
177
243
247...

result:

ok good plan

Test #3:

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

input:

2
()
()

output:

1
2

result:

ok good plan

Test #4:

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

input:

2
((
))

output:

1
2

result:

ok good plan

Test #5:

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

input:

2
)(
()

output:

impossible

result:

ok impossible

Test #6:

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

input:

3
()
(
)

output:

2
1
3

result:

ok good plan

Test #7:

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

input:

3
)(
(
)

output:

2
1
3

result:

ok good plan

Test #8:

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

input:

5
))(
(()
)(
(
)

output:

2
4
3
1
5

result:

ok good plan

Test #9:

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

input:

3
((
))())
(

output:

1
3
2

result:

ok good plan

Test #10:

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

input:

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

output:

impossible

result:

ok impossible

Test #11:

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

input:

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

output:

479
329
311
232
483
199
297
414
211
357
80
265
177
253
271
159
158
157
156
153
442
431
160
440
439
269
437
436
166
435
434
268
264
172
262
429
284
456
124
288
287
286
128
129
130
131
132
133
285
452
136
152
283
139
282
141
449
143
378
277
275
274
445
149
381
406
207
208
209
210
413
214
412
411
410
4...

result:

ok good plan

Test #12:

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

input:

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

output:

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

result:

ok good plan

Test #13:

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

input:

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

output:

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

result:

ok good plan

Test #14:

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

input:

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

output:

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

result:

ok good plan

Test #15:

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

input:

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

output:

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

result:

ok good plan

Test #16:

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

input:

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

output:

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

result:

ok good plan

Test #17:

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

input:

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

output:

468
390
396
4
122
1
601
657
274
79
180
158
526
485
730
547
25
571
131
530
41
166
43
103
246
164
55
56
230
341
494
418
395
481
408
606
406
243
622
605
495
250
624
469
281
625
238
587
618
160
609
255
612
258
225
259
265
162
263
264
650
176
492
181
182
184
185
186
172
654
191
169
653
661
651
195
470
64...

result:

ok good plan

Test #18:

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

input:

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

output:

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

result:

ok good plan

Test #19:

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

input:

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

output:

impossible

result:

ok impossible

Test #20:

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

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: 2ms
memory: 3504kb

input:

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

output:

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

result:

ok good plan

Test #22:

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

input:

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

output:

impossible

result:

ok impossible

Test #23:

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

input:

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

output:

impossible

result:

ok impossible

Test #24:

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

input:

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

output:

impossible

result:

ok impossible

Test #25:

score: 0
Accepted
time: 330ms
memory: 66420kb

input:

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

output:

264227
770337
898404
83071
269214
857929
897909
731069
196234
352796
904916
134097
308325
501576
309146
592970
992894
748267
675083
900795
267140
619800
507757
610823
714320
902203
833824
769249
932913
799635
470977
175996
703503
799479
25080
164427
705720
356849
385146
999836
920721
466467
637563
6...

result:

ok good plan

Test #26:

score: 0
Accepted
time: 41ms
memory: 22464kb

input:

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

output:

impossible

result:

ok impossible

Test #27:

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

input:

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

output:

impossible

result:

ok impossible

Test #28:

score: 0
Accepted
time: 45ms
memory: 22656kb

input:

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

output:

1

result:

ok good plan

Test #29:

score: 0
Accepted
time: 45ms
memory: 22624kb

input:

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

output:

impossible

result:

ok impossible

Test #30:

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

input:

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

output:

impossible

result:

ok impossible

Test #31:

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

input:

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

output:

2
1

result:

ok good plan

Test #32:

score: 0
Accepted
time: 37ms
memory: 19380kb

input:

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

output:

impossible

result:

ok impossible

Test #33:

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

input:

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

output:

3
1
2

result:

ok good plan

Test #34:

score: 0
Accepted
time: 130ms
memory: 66296kb

input:

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

output:

impossible

result:

ok impossible

Test #35:

score: 0
Accepted
time: 146ms
memory: 66408kb

input:

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

output:

impossible

result:

ok impossible

Test #36:

score: 0
Accepted
time: 229ms
memory: 66292kb

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

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: 451ms
memory: 66360kb

input:

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

output:

164663
944202
483356
500584
889056
90286
732016
496501
879218
637097
679768
763948
163748
590693
629235
924596
321244
911154
428626
323909
378339
475331
970762
261112
67591
897141
235797
766848
130656
553153
880821
354542
480934
740159
491924
786672
578545
80944
422516
318856
663182
949927
782080
81...

result:

ok good plan

Test #39:

score: 0
Accepted
time: 404ms
memory: 66352kb

input:

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

output:

568499
675014
629151
795023
985988
425960
463859
106383
689231
597972
137311
388609
353729
427235
129338
207485
470327
123122
116108
770416
623824
905927
696104
192291
542007
437875
289835
902316
713994
328008
287685
186938
333468
77139
391833
122925
123227
460894
104949
858526
209291
777702
815683
...

result:

ok good plan

Test #40:

score: 0
Accepted
time: 104ms
memory: 13200kb

input:

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

output:

163
542
108
367
236
287
469
358
360
537
253
305
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: 0
Accepted
time: 98ms
memory: 12720kb

input:

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

output:

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

result:

ok good plan

Test #42:

score: 0
Accepted
time: 138ms
memory: 15768kb

input:

64026
)()()()))((())((()(())())(()()())))(())))()))()(((())())))()))(()(()())((())((()(()))))()))())()(()(()))))())))(()()()()(((((()()()))))))((((()(()(())()))((()))))()())())(()(((()))))()))())))(()()()(())))((((())(())())(()()))()))))(())))()(((())()()()())()))))(())()(()(((())(()()()()((()()((()...

output:

17030
24272
1485
27238
56433
36141
40015
45353
9742
34448
13709
29121
1889
10165
17456
48613
12907
11895
50885
25948
44572
26319
38775
13600
24001
17460
45527
1521
43971
10216
62803
43131
59021
1400
5953
2328
5117
14420
26585
16974
50781
6736
49484
2586
49599
53602
46482
54436
10839
36581
31019
2323...

result:

ok good plan

Test #43:

score: 0
Accepted
time: 336ms
memory: 54292kb

input:

741507
)))((())))))()))(()()())((()((
))())
()
)(((()))()((()()(()())(())(((
(()))())()))))((
))(
)()
((()((()()()))(
(()(
(()())())(
)
)
(((()()(()(
()()(((
)(())))((((()((()()))))(()())(()))())((()((()((((()))()()(
()))
())())())))(()))(
())))()(
)(
(())()()())()())()((()))(
(())
)))()()
)
)(())()...

output:

204843
399438
562227
498212
85220
400919
329734
235660
386793
607247
678888
25279
53936
298959
323865
316054
382031
701764
203448
430469
723227
216616
386600
85379
629123
212026
82698
654766
348918
16430
167630
373707
255480
74820
719644
168266
570582
419793
620885
243995
371922
218916
423177
474326...

result:

ok good plan

Test #44:

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

input:

32
())((())(()(((())())()())((())(()(((((((()))()(())))))())(())))((())((((()))(()(()(()(()))()(())())((()())(()((((((()(()(()()(()))()(())(()(()()))()())))()((()()(()(())))((()(()(()))))())()()(())(())(())()))(((()((((()())(()()()()()())()())())((()(()(()()
()
()))()()()(()())()((())))()((()()(()()...

output:

7
23
17
25
2
21
1
32
22
11
3
6
10
24
27
8
15
14
29
31
26
9
19
20
4
30
18
16
28
12
5
13

result:

ok good plan

Test #45:

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

input:

8
())(()()))))()(()))))()()(()()(())))((())))))(((())))))())((((()))((()))((())))()()))()(())(()(()()()(()())()(()((())()))(((((()(((()((()()((()()(())(()())()((()))))())()())(()))())(((((((()())(())))(()))))(())(())(()))))))(()(((()((()((((()))(()(((()))()))()())(((()))(((())(())))))(((())()()()))(...

output:

6
3
7
2
1
5
4
8

result:

ok good plan

Test #46:

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

input:

32
()))()(()))()()()()()(())((()()(()))(()
(()())())()))()(())())))()(()())()((()(()(()))()(()((((((((()))()))))((((())()))()((((()))((())()(()(()((()()()))))()()())()()((()(()()(((()))()))((()(()()(((()((())((((((((()())()(((()(()))(
)))()()()((())()()
())))((()))(()(((()((()()()))(()
)((()))))()))...

output:

23
29
27
14
10
13
31
8
21
4
17
28
2
32
6
20
26
7
19
15
1
22
24
11
3
18
12
25
9
30
5
16

result:

ok good plan

Test #47:

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

input:

53
))(((((())))))))((()()())()))())())())())(())())(())())(((()((()())(()(())))())(((
()()))((())))()))()(())))()))()(()(())))((())((((((()))()(()))))))))((()))))))))((())()))(()))())()()(()))()())()())())()(())(((()(
)())
()))))()))()(()()))()))(()((((()))(()))())(((()))(()()()))(())))(())))()(((((...

output:

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

result:

ok good plan

Test #48:

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

input:

25
)()((()())()))())))(((())))(())(()))))(()(()))((()()())(()((()())))(())())())())((()((()()(())))))))()((())())(()()(()()()())()())(()((()())(((())))()))(())()()()()((()))()(((())(())())((()((()))))(()(((()(())()()(((()))(()())(()))((())()))()))())(((()))))()()()((())((())()))()(())()(((((()())(((...

output:

5
21
25
11
19
9
14
12
20
7
13
22
1
15
4
16
8
24
6
17
23
10
2
3
18

result:

ok good plan

Test #49:

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

input:

90
))))((()()()))())))(
()())((((())))()))((())()()))))())(()()()(()))())))))((())())))()))(()())((())()(())))((((()(()()()())))()()))()(()())))())(((
))))())))()))))()((()(())(()((())(())()(()())))))()((()))((()()(()())()((()())((()()(()()(())())())()()(()))((()((()()(()()(()((()()()()))(())))))())...

output:

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

result:

ok good plan

Test #50:

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

input:

16
))))))(((()(())()()(()((()()((())(()()(())))((())))))))(())(()))()((())((()(()()))())((())))()()()((()()))(((()()))()()))))()())))()))(((((()))(()()((()(()()()((((((()()(((((()(())))())()(())()())()(()(())()))()()()))(()(()))(())))(()))(((())))((((((()))(()((((())()())()(())()))()))(())()))))())(...

output:

3
5
11
14
10
6
12
9
1
16
2
15
7
13
8
4

result:

ok good plan

Test #51:

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

input:

28
(())((()(()
(()))())()()()()(())()()(()
(()()))()))()))()((()()()()))()((()))))))())))(()))))(())())()()(()(((((((()((())))(()))(())))())(((())))))))))))))))))))))))))))))))))))))))))))))))
)())())((((()((()()(()(()
)(()()((()((())((()()))())
(((()((((()())((((()())(())))())(()))))))((())()))))()...

output:

23
11
27
28
17
1
18
5
9
26
25
4
16
10
14
19
13
12
20
6
24
22
15
2
7
8
21
3

result:

ok good plan

Test #52:

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

input:

14
))(())()((((()((()((()(()))))())))((()()((())(((()))(())))((())(())(()(()(())(
(()()())(()(())(()()))))))))())())()))())))())()(()))())))())(((())()(((((()())(()())()(()
()))))()((()()()(()())(())()(((()))()())((((()(()()())))(()))(()()()())(())())())))()))((()())()))(((((()()((()(()))()()))()()(...

output:

13
14
12
7
1
6
3
8
4
2
5
9
10
11

result:

ok good plan

Test #53:

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

input:

3711
(
)(
)(
(
)(()
((
(
(
))
(
))())
(
)((
)
)
))))
)
)
(
)
((
(
)((
()
(
(
()))
()(()
)(()((
)
(
)
)((
)))))
(
)(
)(((
)((((((
)
((
()()()(((
)
)()
)(
)()())
(
((
(((
)
(
)(
)
)(
((
)(()
)
(
(()())))))(
(
(
()(
())
(
)((
)
()(
)
)((
()
(
)
)())
)(
()(
)(
)
)))))(
)(
(
()()
(
)))(((
)
)(()()(
(
(()...

output:

2709
1378
3641
1969
883
3074
1706
3670
2001
3325
193
2168
183
731
1129
3417
2067
2202
1153
2860
540
202
610
622
507
1705
2192
1037
1334
1701
213
783
1209
2493
806
1753
2131
1757
2115
2849
3608
136
3622
602
1300
967
1291
87
401
1521
3443
3436
2462
2345
700
2699
3334
646
335
3133
2685
2678
3138
1158
3...

result:

ok good plan

Test #54:

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

input:

7863
(
)
)
)
)
))
(
(
(
)
)
(
(
)
((
(
)
)
(
(
)
(
(
(
)
(
)
)
)
)
(
)
(
)
)
)
(
(
)
)
)
)
(
((
(
)
((
(
)
))
(
)
((
(
)
(
)
(
(
(
(
(
)
)
(
)
(
()
)
)
(
(
)
)
(
)
)
(
(
)
)
)
(
)
))
(
)
)
)
)
(
(
(
(
(
(
)
(
(
)
)
(
)
(
(
)
(
(
()
)
(
)
)
)
(
(
)
)
)
(
((
(
)
)(
()
)
)
)(
(
)
)
)
)
(
)
(
(
)
(
(
)
...

output:

4898
7337
515
7172
2024
7783
4936
5828
160
2090
158
5695
532
3228
529
6180
1041
3116
7386
6685
6259
7388
165
6926
3875
2455
7117
6989
5685
3385
3356
4517
1601
4506
7481
6543
3568
6702
5711
701
121
3243
3556
5121
1749
707
1853
3834
7601
7535
2113
3846
4867
4870
811
1941
1956
7238
3206
6355
4222
3413
...

result:

ok good plan

Test #55:

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

input:

2272
)
)
(
)
)
(()()
(
))()((()((
)
()(
))
))
(
)((
()
)(((
(()))()
))(((((
)
)
)()((((
(()(((
)())()
()(()
)(
)()(((
()
(((
))
))
()
(
(
()
)
(
(
(
((((()()((()
((
)
(
)
)((
)((
)((
((
((
(
((
(
())
)
(
()
(
)()(())
)
())(
(())()
(())((
))
)()()())
(()))(
()
(
)(
())
())()((
)((
))
((((
(()(
))()()...

output:

1037
271
1937
1431
1730
1700
2198
1857
1306
1442
2065
935
1377
1742
1440
1438
584
974
1357
39
2070
2117
768
1881
2227
1764
1035
1718
783
367
413
1640
1666
430
1977
72
302
1288
2024
339
1539
174
581
1297
543
1420
22
2190
1318
640
1906
896
532
665
1339
2028
188
1872
434
906
330
2011
930
2007
918
1145
...

result:

ok good plan

Test #56:

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

input:

4127
)
)(
)
(
)
)
()(
)
)(
(
)
))
)())
((
((
)()(
(
(
(
)
)
((())
(
(
(
)(
)((
)((
)()
)
))
(
(
)
(
)
)
(
(
)
((
((
()
(
())
(
(
))
(
(
(
(
()
)
())
)(
))
)
(
))
)(
)
(((
(
)
)
(
()
)(
)
(
(
(
)
(
((
(
)))
(
(
)(
(((
)(
())
)
()
)
)
)
)
()((
()
)()
(
(
(
(
(
)
)(
(
)()
)
)
(
(
()(((
()
))
((
()
)
)
...

output:

1004
2854
3255
3163
1789
1718
1720
2498
3052
857
1929
1147
3673
2653
695
1316
3759
708
1463
2920
3432
2091
775
584
1618
2608
1179
2485
4026
1047
82
739
2211
652
1580
1584
1862
165
1599
2307
1451
3866
1757
1393
2575
1370
1369
384
2937
2791
2964
1509
2735
1520
2027
1278
2588
3012
3655
167
1836
2113
27...

result:

ok good plan

Test #57:

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

input:

5314
)
)
((
(
(
)
)()
)
(
)
)))
(((()(
)
()(
())
)
(
(
()
)))
)
)(
()
(
(
()(
(
(
))
(())
)((
))
(
))
)(
(
(
(
(((
(
((
(
)
(
((
(
)
))(
)
))
(
)
))(
(
(
)))
))
(
)(
(
(((
)))
(())((
)(
())(
(
()
()
(
(
(
)(
)
(
)
)
))
(()
)()
()
(
(
(
())
()(
)
(
)
(
(
(
(
)
)(
)()(
)
)
)(
)
)
(
(
)(
((
)()
))
)
(
...

output:

3496
3932
180
2783
4856
2293
2771
3785
1657
3979
4937
1860
3268
2804
1183
561
210
3143
2518
294
2813
12
4437
1606
4069
4602
2788
4390
567
3421
1570
2685
4529
3746
698
2625
5026
126
3771
2676
1026
4743
4357
4363
3576
144
2100
2083
1173
3297
5209
441
4568
1710
3881
1825
1231
3014
4511
361
342
5177
391...

result:

ok good plan

Test #58:

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

input:

3465
(
)
)
(()
(
)()
(
(
)
)
)((
)((
(
)
)))
((
)
)
)(()
(
((
)
)(
(((((
(
)
(
))(
(
(()
))()(
)
))
(
(
(
))
)(
(
((
(
(
)
)
(
)
)
(
)
())
(
(
((
)
)(
)
(
)
)()((
(
)(
)))
(
)
)
(((
)
))(
()
)))
)))
(
(
)
)
)
)()))
)
((
(((()
)
)
)
)
(
))(
)
(
)
)
))(()((
()
)))
(
(
(
)
)(
(
)((((
)()
)
)
(
))((
())...

output:

24
208
633
2109
1199
3153
206
2388
974
1353
2283
1668
1413
980
2632
1827
1437
3066
701
2751
2642
259
620
3267
1799
1031
1273
2950
66
1401
3344
714
1782
144
640
80
717
2464
2445
2823
2076
926
1175
1887
1890
2463
1187
3358
368
1848
377
1654
1652
3361
1312
691
205
1946
1944
3326
3325
347
1311
1308
1907...

result:

ok good plan

Test #59:

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

input:

3992
)())(()(
((
))
((())
(())
)()
)
()(
(
)
(
((
(
)()
(
()))
)((
())
(
)
()
(
(()))
)(
((
(
)
(())(
((
))
((
)
)
)
)
())
(
(((
(
()
)
()))(()
(
)(
))
(
(()(
()
(
)
()))
)(
)(
())))(
)())
(
))
(
(((
)
))
(
(
)((
()
)
(((
)
(
))
)
()
(
)
(
(((((
(
)
((()()((())
))
(
()()
)(
(
)(
)(
(
(
)
)(())(
)(((...

output:

253
2233
3246
708
2781
2547
1932
2926
3461
76
2585
1962
2436
1100
3954
2767
484
1886
3957
1092
1173
2079
246
3209
2890
3476
148
2571
1213
218
1515
793
2447
299
2166
1836
3320
1197
1566
2711
2440
3715
910
1901
1184
3819
3072
550
3857
906
2402
2403
3104
635
679
1034
2839
3760
688
658
1053
2150
3543
21...

result:

ok good plan

Test #60:

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

input:

127
)))()())))))))()((
))((()(((
))(()((())))((()()(((()(()(()(()()(((())(())())(())
)()((())()(())))()))())()(()()))
))((()())((((((
()()()((
(())(()((()((()(()))())(((())())())))())(()(
)(()))))()))()(((()(()()()()()()))(
)((())())
()(()()(()(())))())())))))))
)()))()(())())()))))())
((()))))))()(...

output:

68
73
22
97
98
106
66
102
125
105
122
110
6
7
95
69
56
84
27
35
18
94
77
36
112
113
14
65
87
55
71
107
86
34
78
74
91
3
118
5
2
72
90
40
96
70
63
28
64
103
93
124
44
61
80
83
100
23
75
67
45
120
43
119
13
42
24
88
41
114
54
19
53
104
85
59
21
17
60
32
8
99
101
26
81
30
57
12
49
37
1
82
31
79
46
52
5...

result:

ok good plan

Test #61:

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

input:

7074
(
(
)
(
(
(
(
)
)
)
(
)
)
(
)
)
(
(
(
(
)
(
)
)
)
(
(
)
)
))
(
(
)
)
(
(
(
(
(
(
(
)
)
)
)
(
)
(
)
(
)
)
(
)
(
)
()
)
(
)
(
)
(
(
(
)
)
)
(
)
(
(
)
)
)
(
)
(
(
)
)
(
(
(
(
)
)
)
((
)
(
()
)
)
)
)
(
(
(
)
(
)
((
)
)
)
(
(
(
(
(
)
)
(
(
(
(
)
)
(
(
(
(
(
)
(
)
(
)
)
(
)
(
(
(
(
(
(
)
)
(
)
)
)
)
...

output:

1782
469
1201
6842
4428
5145
3823
5459
905
844
6482
5142
6789
6352
1547
976
2181
366
4080
3037
985
89
2135
346
3228
103
3926
5790
5036
5784
2796
4662
6536
5782
1103
1803
5544
4865
6845
2471
1665
3877
2973
4849
4751
5245
5975
3887
4198
2670
5819
1525
3020
3539
3315
4061
5716
3549
2537
4547
4683
4226
...

result:

ok good plan

Test #62:

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

input:

61
)
)
(
)
)
((
)
)
)
)
(
(
(
)(
))
(
(
(
))
()
)
)
)(
(
(
()
)
(
(
((
(
)(((
()(
(
(
))
)
))
)
(
))
)
(
(
(
(
)()
)
)
(
(
()
(
)
)()
)
(
)
(
(
))(

output:

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

result:

ok good plan

Test #63:

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

input:

11
))()()(
))
(
(
(()
(()
)(()())((
)))()((
(())
())((
))

output:

3
4
5
6
9
7
10
8
1
2
11

result:

ok good plan

Test #64:

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

input:

86
)
)
)
)
(
)
)
)
((
)
(
)
)
(
)
)
)
((
)
)
)
)
)
)
)
)
(
)
)
(
(
)
)
(
)
)
(
(
(
)
(
(
)
(
)
)
(
(
(
)
(
(
)
(
)
(
(
)
)
(
(
(
)
(
()
(
(
)
(
(
(
(
)
(
)
(
(
()
(
(
)
(
)
(
(
)

output:

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

result:

ok good plan

Test #65:

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

input:

45
)
)
((
)
)
(
)
(
(
)
(
)
)
((
))
(
)
(
)
((
(
(
))
((
)
)
)
(
)
)
)
(
(
(
(
)
)(
(
)
)
)
(
(
(
)

output:

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

result:

ok good plan

Test #66:

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

input:

20
((
)
)))
(
)((
)
(
((()()
(
)(()
(
(
)))
))
))
()(
(
((
())))
(

output:

18
1
8
11
20
17
12
9
7
4
16
5
10
6
2
14
15
13
3
19

result:

ok good plan

Test #67:

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

input:

10
((
(
)
))
)
)
(
(
)
(

output:

1
2
7
8
10
3
5
6
9
4

result:

ok good plan

Test #68:

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

input:

14
)()((())(()
(())
)(()(())((()())
())((())(()()(((())
()(()
)(
))(((
))
(((())
(())
)))))
)
()))(()(()
())

output:

9
5
2
10
4
1
3
6
7
13
12
14
8
11

result:

ok good plan

Test #69:

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

input:

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

output:

2
1
3

result:

ok good plan

Test #70:

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

input:

1
(

output:

impossible

result:

ok impossible

Test #71:

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

input:

1
)

output:

impossible

result:

ok impossible

Test #72:

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

input:

1
)(

output:

impossible

result:

ok impossible

Test #73:

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

input:

1
()

output:

1

result:

ok good plan

Test #74:

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

input:

2
(
)

output:

1
2

result:

ok good plan

Test #75:

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

input:

2
)
(

output:

2
1

result:

ok good plan

Test #76:

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

input:

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

output:

3
5
1
2
6
4

result:

ok good plan

Extra Test:

score: 0
Extra Test Passed