QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#536481#5108. Prehistoric ProgramsRngBased#AC ✓291ms34888kbC++141.8kb2024-08-29 13:36:402024-08-29 13:36:42

Judging History

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

  • [2024-08-29 13:36:42]
  • 评测
  • 测评结果:AC
  • 用时:291ms
  • 内存:34888kb
  • [2024-08-29 13:36:40]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;

int n;
pii eff[1000006];

pair<vector<int>, int> solve(vector<int> ord)
{
    vector<int> sol;
    sort(all(ord), [&](int i, int j) { return eff[i].F > eff[j].F; });
    
    int idx = 0, sum = 0;
    priority_queue<pii> pq;
    auto update = [&]()
    {
        while (idx < ord.size() && eff[ord[idx]].F + sum >= 0)
            pq.push(pii(eff[ord[idx]].S, ord[idx])), idx++;
    };

    update();
    while (!pq.empty())
    {
        auto [add, i] = pq.top();
        pq.pop();

        if (sum + eff[i].F < 0) break;
        sum += eff[i].S;
        sol.emplace_back(i);
        update();
    }

    return make_pair(sol, sum);
}


signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n;
    vector<int> add, sub;
    for (int i = 1; i <= n; i++)
    {
        string s;
        cin >> s;
        int sum = 0, low = 0;
        for (auto c : s)
        {
            if (c == '(')
                sum++;
            else 
                sum--;
            low = min(sum, low);
        }
        if (sum >= 0)
        {
            eff[i] = pii(low, sum);
            add.emplace_back(i);
        }
        else 
        {
            eff[i] = pii(low - sum, -sum);
            sub.emplace_back(i);
        }
    }
    auto [sol1, s1] = solve(add);
    auto [sol2, s2] = solve(sub);
    if (sol1.size() + sol2.size() == n && s1 == s2)
    {
        for (auto i : sol1)
            cout << i << '\n';
        reverse(all(sol2));
        for (auto i : sol2)
            cout << i << '\n';
    }
    else 
        cout << "impossible\n";

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 12ms
memory: 4752kb

input:

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

output:

41248
6827
17933
39338
30523
11635
8378
1194
39997
15203
12662
8282
34305
41357
24534
33154
37628
20200
45720
29189
40093
27739
38177
35948
32454
28930
42456
48879
12655
12299
46182
21094
4238
49233
44459
35822
33371
21519
18388
13809
9449
37172
27579
3502
48479
39917
15706
4704
40407
30710
47826
41...

result:

ok good plan

Test #2:

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

input:

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

output:

36
980
537
519
480
472
634
13
745
194
994
66
386
896
186
776
44
354
966
904
532
645
946
585
167
571
488
132
694
38
587
286
264
159
257
218
141
127
83
448
417
39
595
478
476
907
814
720
598
543
507
329
214
107
981
427
111
62
956
780
707
700
662
384
362
349
300
260
131
996
845
807
793
705
676
600
581
...

result:

ok good plan

Test #3:

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

input:

2
()
()

output:

2
1

result:

ok good plan

Test #4:

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

input:

2
((
))

output:

1
2

result:

ok good plan

Test #5:

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

input:

2
)(
()

output:

impossible

result:

ok impossible

Test #6:

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

input:

3
()
(
)

output:

2
1
3

result:

ok good plan

Test #7:

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

input:

3
)(
(
)

output:

2
1
3

result:

ok good plan

Test #8:

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

input:

5
))(
(()
)(
(
)

output:

4
2
3
1
5

result:

ok good plan

Test #9:

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

input:

3
((
))())
(

output:

1
3
2

result:

ok good plan

Test #10:

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

input:

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

output:

impossible

result:

ok impossible

Test #11:

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

input:

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

output:

479
448
329
311
483
443
255
232
199
146
414
357
350
335
297
265
253
211
177
80
496
495
494
492
491
489
487
486
480
476
474
472
467
464
459
456
452
449
445
442
440
439
437
436
435
434
431
429
428
427
426
424
420
416
415
413
412
411
410
409
407
406
405
404
399
398
395
393
392
388
381
378
373
370
368
3...

result:

ok good plan

Test #12:

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

input:

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

output:

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

result:

ok good plan

Test #13:

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

input:

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

output:

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

result:

ok good plan

Test #14:

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

input:

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

output:

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

result:

ok good plan

Test #15:

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

input:

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

output:

129
23
39
29
140
16
85
45
112
74
49
145
75
149
62
41
142
100
88
63
150
121
70
55
144
32
7
148
117
107
104
102
98
86
84
82
64
51
34
21
19
141
128
127
118
113
94
89
87
80
61
58
56
53
52
46
44
37
36
26
14
10
8
5
2
136
114
90
76
66
50
42
18
15
13
4
3
6
9
11
17
25
28
35
38
43
47
54
57
59
60
65
67
71
73
7...

result:

ok good plan

Test #16:

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

input:

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

output:

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

result:

ok good plan

Test #17:

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

input:

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

output:

468
54
142
423
234
205
744
163
415
702
365
390
379
327
127
713
472
421
204
579
540
439
396
102
85
746
734
707
544
539
313
642
590
585
655
646
122
46
4
1
658
657
601
405
161
47
12
535
274
236
216
202
180
104
99
79
34
473
342
316
158
730
706
705
681
630
614
571
547
526
524
504
485
482
453
336
328
325
...

result:

ok good plan

Test #18:

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

input:

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

output:

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

result:

ok good plan

Test #19:

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

input:

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

output:

impossible

result:

ok impossible

Test #20:

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

input:

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

output:

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

result:

ok good plan

Test #21:

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

input:

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

output:

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

result:

ok good plan

Test #22:

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

input:

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

output:

impossible

result:

ok impossible

Test #23:

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

input:

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

output:

impossible

result:

ok impossible

Test #24:

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

input:

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

output:

impossible

result:

ok impossible

Test #25:

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

input:

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

output:

149392
734985
320653
685162
392718
468537
91935
308736
335762
408311
931678
898628
48832
645366
466001
630655
837214
941474
22275
225116
948877
700314
253030
563491
499682
453729
438053
303619
580393
58321
113902
961246
352529
190553
613993
642440
276986
382014
279446
611091
181228
58358
970395
9686...

result:

ok good plan

Test #26:

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

input:

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

output:

impossible

result:

ok impossible

Test #27:

score: 0
Accepted
time: 10ms
memory: 21340kb

input:

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

output:

impossible

result:

ok impossible

Test #28:

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

input:

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

output:

1

result:

ok good plan

Test #29:

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

input:

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

output:

impossible

result:

ok impossible

Test #30:

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

input:

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

output:

impossible

result:

ok impossible

Test #31:

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

input:

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

output:

2
1

result:

ok good plan

Test #32:

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

input:

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

output:

impossible

result:

ok impossible

Test #33:

score: 0
Accepted
time: 10ms
memory: 20344kb

input:

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

output:

3
1
2

result:

ok good plan

Test #34:

score: 0
Accepted
time: 124ms
memory: 34888kb

input:

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

output:

impossible

result:

ok impossible

Test #35:

score: 0
Accepted
time: 118ms
memory: 34572kb

input:

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

output:

impossible

result:

ok impossible

Test #36:

score: 0
Accepted
time: 155ms
memory: 26812kb

input:

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

output:

1000000
999998
999996
999994
999992
999990
999988
999986
999984
999982
999980
999978
999976
999974
999972
999970
999968
999966
999964
999962
999960
999958
999956
999954
999952
999950
999948
999946
999944
999942
999940
999938
999936
999934
999932
999930
999928
999926
999924
999922
999920
999918
99991...

result:

ok good plan

Test #37:

score: 0
Accepted
time: 158ms
memory: 26924kb

input:

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

output:

999999
999998
999997
999996
999995
999994
999993
999992
999991
999990
999989
999988
999987
999986
999985
999984
999983
999982
999981
999980
999979
999978
999977
999976
999975
999974
999973
999972
999971
999970
999969
999968
999967
999966
999965
999964
999963
999962
999961
999960
999959
999958
999957...

result:

ok good plan

Test #38:

score: 0
Accepted
time: 281ms
memory: 31492kb

input:

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

output:

510441
605854
164663
944202
483356
500584
138068
889056
319417
879218
763948
732016
679768
637097
496501
492328
475292
417130
183559
163748
90286
924596
911154
786284
765327
748692
629235
590693
487793
428626
327042
321244
235485
217447
970762
651410
598737
480176
475331
378339
323909
295142
261112
...

result:

ok good plan

Test #39:

score: 0
Accepted
time: 291ms
memory: 31800kb

input:

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

output:

568499
250826
72642
791925
816445
675014
629151
494698
191981
124285
985988
795023
536620
425960
926090
561779
549647
463859
434240
300744
106383
907373
884793
810035
758663
689231
597972
575206
539400
212168
156606
137311
963161
930603
746420
592419
427235
388609
353729
333208
207485
193769
129338
...

result:

ok good plan

Test #40:

score: 0
Accepted
time: 47ms
memory: 3844kb

input:

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

output:

163
528
314
475
451
399
186
251
440
356
243
417
190
359
396
310
352
21
388
216
75
223
276
357
275
381
403
522
499
508
266
339
106
531
301
158
423
204
375
175
291
392
235
421
236
44
319
479
443
65
561
41
525
73
389
9
347
231
501
405
495
292
255
116
549
413
137
152
326
277
151
487
426
384
85
169
122
1...

result:

ok good plan

Test #41:

score: 0
Accepted
time: 47ms
memory: 4388kb

input:

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

output:

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

result:

ok good plan

Test #42:

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

input:

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

output:

51373
3817
38333
28440
23160
14136
47434
43701
7709
16318
17030
51691
60845
43609
51607
45575
24272
8970
57203
15571
7952
47005
39904
36934
1485
42660
28812
12548
5483
59616
47178
41633
36765
27238
18365
925
63335
60005
35379
28742
63066
44858
39470
29892
24239
16598
14144
13562
10743
60139
56433
53...

result:

ok good plan

Test #43:

score: 0
Accepted
time: 224ms
memory: 23888kb

input:

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

output:

504790
204843
495310
538676
343862
42954
399438
146851
562227
498212
266233
180224
118929
63131
694426
504382
488191
372668
325828
85220
67718
414295
400919
388851
386793
329734
235660
233827
98517
87230
76622
53673
678888
616123
607247
570883
521226
483338
325518
323865
298959
182800
121461
53936
2...

result:

ok good plan

Test #44:

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

input:

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

output:

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

result:

ok good plan

Test #45:

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

input:

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

output:

6
7
3
1
4
2
5
8

result:

ok good plan

Test #46:

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

input:

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

output:

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

result:

ok good plan

Test #47:

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

input:

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

output:

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

result:

ok good plan

Test #48:

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

input:

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

output:

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

result:

ok good plan

Test #49:

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

input:

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

output:

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

result:

ok good plan

Test #50:

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

input:

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

output:

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

result:

ok good plan

Test #51:

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

input:

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

output:

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

result:

ok good plan

Test #52:

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

input:

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

output:

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

result:

ok good plan

Test #53:

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

input:

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

output:

2709
3641
3074
2952
1969
1641
1426
1378
883
38
3670
3584
3560
3417
3356
3325
2860
2241
2202
2168
2067
2001
1719
1706
1607
1572
1342
1153
1129
731
549
540
193
183
3697
3692
3675
3625
3622
3608
3538
3473
3469
3447
3443
3436
3371
3334
3138
3136
3133
3080
2964
2962
2950
2889
2849
2707
2699
2685
2678
266...

result:

ok good plan

Test #54:

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

input:

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

output:

7783
7337
7172
4936
4898
2024
515
7687
7675
7669
7601
7590
7576
7535
7481
7412
7388
7386
7368
7288
7238
7117
7014
7007
7000
6989
6926
6915
6900
6825
6817
6735
6714
6702
6685
6671
6659
6633
6549
6543
6430
6417
6403
6399
6388
6355
6310
6274
6259
6245
6228
6180
6082
6081
6058
5997
5879
5828
5768
5747
5...

result:

ok good plan

Test #55:

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

input:

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

output:

1037
1937
271
2179
1730
1700
1431
1146
2198
2065
1857
1742
1443
1442
1440
1438
1377
1357
1306
974
935
584
39
2227
2117
2086
2070
2021
1910
1881
1875
1764
1502
821
768
566
549
383
200
139
2250
2190
2058
2028
2024
2004
1977
1906
1812
1769
1747
1718
1666
1640
1620
1539
1420
1396
1392
1339
1318
1297
128...

result:

ok good plan

Test #56:

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

input:

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

output:

1004
3255
3163
2854
3759
3673
3432
3052
2920
2653
2498
2091
1929
1789
1720
1718
1463
1316
1147
1007
857
708
695
4026
3866
3655
3383
3068
3012
2978
2964
2937
2791
2748
2746
2735
2652
2608
2588
2575
2485
2307
2211
2183
2180
2113
2027
1884
1862
1836
1757
1618
1599
1584
1580
1520
1509
1451
1393
1370
136...

result:

ok good plan

Test #57:

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

input:

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

output:

3932
3496
4856
2783
180
4937
4437
3979
3785
3268
3143
2813
2804
2771
2518
2293
1860
1657
1183
561
412
294
210
12
5209
5177
5143
5103
5026
4811
4778
4743
4722
4602
4568
4529
4511
4450
4397
4390
4363
4357
4305
4273
4240
4228
4069
3918
3881
3824
3771
3746
3692
3683
3645
3615
3576
3421
3370
3344
3297
31...

result:

ok good plan

Test #58:

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

input:

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

output:

208
24
3153
2388
2109
1199
974
633
206
3361
3358
3344
3267
3066
2950
2823
2751
2642
2635
2632
2464
2463
2445
2283
2076
1890
1887
1848
1827
1799
1782
1770
1668
1654
1652
1437
1413
1401
1353
1273
1187
1175
1031
980
926
885
717
714
701
640
639
620
503
377
368
259
167
144
100
80
66
3450
3405
3395
3367
3...

result:

ok good plan

Test #59:

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

input:

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

output:

3246
2233
334
253
3461
2926
2781
2585
2547
1962
1932
1331
708
287
278
76
3957
3954
3476
3320
3209
2890
2767
2711
2571
2447
2440
2436
2372
2166
2079
1886
1836
1566
1515
1213
1197
1173
1100
1092
930
793
484
299
246
218
148
138
3857
3826
3819
3760
3741
3715
3674
3654
3584
3543
3250
3248
3241
3174
3167
...

result:

ok good plan

Test #60:

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

input:

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

output:

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

result:

ok good plan

Test #61:

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

input:

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

output:

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

result:

ok good plan

Test #62:

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

input:

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

output:

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

result:

ok good plan

Test #63:

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

input:

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

output:

6
10
7
5
4
3
9
1
8
2
11

result:

ok good plan

Test #64:

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

input:

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

output:

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

result:

ok good plan

Test #65:

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

input:

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

output:

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

result:

ok good plan

Test #66:

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

input:

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

output:

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

result:

ok good plan

Test #67:

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

input:

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

output:

1
10
8
7
2
3
5
6
9
4

result:

ok good plan

Test #68:

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

input:

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

output:

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

result:

ok good plan

Test #69:

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

input:

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

output:

2
1
3

result:

ok good plan

Test #70:

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

input:

1
(

output:

impossible

result:

ok impossible

Test #71:

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

input:

1
)

output:

impossible

result:

ok impossible

Test #72:

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

input:

1
)(

output:

impossible

result:

ok impossible

Test #73:

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

input:

1
()

output:

1

result:

ok good plan

Test #74:

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

input:

2
(
)

output:

1
2

result:

ok good plan

Test #75:

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

input:

2
)
(

output:

2
1

result:

ok good plan

Test #76:

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

input:

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

output:

3
5
2
1
6
4

result:

ok good plan

Extra Test:

score: 0
Extra Test Passed