QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#66124#5108. Prehistoric ProgramsSortingAC ✓475ms39480kbC++142.6kb2022-12-06 23:31:052022-12-06 23:31:06

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-06 23:31:06]
  • 评测
  • 测评结果:AC
  • 用时:475ms
  • 内存:39480kb
  • [2022-12-06 23:31:05]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

#define all(x) (x).begin(), (x).end()

const int N = 1e6 + 3;
const int INF = 1e9;

int m[N], s[N], n;

struct SegmentTree{
    pair<int, int> mx[4 * N];

    void init(const vector<int> &p, int i = 0, int l = 0, int r = n - 1){
        if(l == r){
            mx[i] = {s[p[l]] - m[p[l]], l};
            return;
        }
        int mid = (l + r) >> 1;
        init(p, 2 * i + 1, l, mid);
        init(p, 2 * i + 2, mid + 1, r);
        mx[i] = max(mx[2 * i + 1], mx[2 * i + 2]);
    }

    pair<int, int> query(int sl, int sr, int i = 0, int l = 0, int r = n - 1){
        if(sr < l || r < sl) return {-INF, -1};
        if(sl <= l && r <= sr) return mx[i];
        int mid = (l + r) >> 1;
        return max(query(sl, sr, 2 * i + 1, l, mid), query(sl, sr, 2 * i + 2, mid + 1, r));
    }

    void update(int s, int i = 0, int l = 0, int r = n - 1){
        if(s < l || r < s) return;
        if(l == r){
            mx[i] = {-INF, l};
            return;
        }
        int mid = (l + r) >> 1;
        update(s, 2 * i + 1, l, mid);
        update(s, 2 * i + 2, mid + 1, r);
        mx[i] = max(mx[2 * i + 1], mx[2 * i + 2]);
    }
} st;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;

    int total_sum = 0;
    for(int i = 0; i < n; ++i){
        string str;
        cin >> str;
        for(char c: str){
            s[i] += c == '(' ? 1 : -1;
            m[i] = min(m[i], s[i]);
        }
        total_sum += s[i];
        // cout << s[i] << " - " << m[i] << endl;
    }

    if(total_sum != 0){
        cout << "impossible\n";
        return 0;
    }

    vector<int> p(n);
    std::iota(all(p), 0);
    sort(all(p), [&](int l, int r){
        return m[l] > m[r];
    });

    st.init(p);

    int prefix = 0;
    vector<int> ans;
    for(int i = 0; i < n; ++i){
        int l = 0, r = n - 1;
        while(l != r){
            int mid = (l + r + 1) >> 1;
            if(prefix + m[p[mid]] >= 0)
                l = mid;
            else
                r = mid - 1;
        }

        int to = l;
        // cout << to << " to" << endl;
        auto [mx, pos] = st.query(0, to);
        if(mx == -INF){
            cout << "impossible\n";
            return 0;
        }

        st.update(pos);
        if(prefix + m[p[pos]] < 0){
            cout << "impossible\n";
            return 0;
        }

        prefix += s[p[pos]];
        ans.push_back(p[pos]+ 1);
    }

    for(int x: ans)
        cout << x << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

41248
6827
8378
17933
12662
24534
39338
11635
30523
1194
8776
27739
39997
15203
44055
34305
8282
4894
20200
41357
21747
45720
15706
29189
28930
37628
32454
40093
15912
33154
28445
46182
32068
38245
21519
38177
44459
35948
49233
25565
27579
18388
12655
3797
39764
16420
35822
48879
42456
20550
3502
12...

result:

ok good plan

Test #2:

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

input:

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

output:

36
537
980
519
480
354
634
904
994
472
745
44
16
194
159
694
13
782
488
776
896
66
152
186
386
325
583
167
38
532
966
651
145
218
946
363
234
736
571
132
645
764
95
448
141
585
204
148
53
478
587
156
24
845
417
264
202
507
107
286
675
487
257
547
875
726
259
276
676
720
83
127
124
630
275
150
111
54...

result:

ok good plan

Test #3:

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

input:

2
()
()

output:

2
1

result:

ok good plan

Test #4:

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

input:

2
((
))

output:

1
2

result:

ok good plan

Test #5:

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

input:

2
)(
()

output:

impossible

result:

ok impossible

Test #6:

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

input:

3
()
(
)

output:

2
3
1

result:

ok good plan

Test #7:

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

input:

3
)(
(
)

output:

2
1
3

result:

ok good plan

Test #8:

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

input:

5
))(
(()
)(
(
)

output:

4
3
2
1
5

result:

ok good plan

Test #9:

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

input:

3
((
))())
(

output:

1
3
2

result:

ok good plan

Test #10:

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

input:

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

output:

impossible

result:

ok impossible

Test #11:

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

input:

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

output:

479
255
448
146
311
329
335
443
483
232
199
317
326
30
407
361
80
265
357
253
297
350
177
211
414
377
134
173
454
116
391
497
364
9
5
44
122
137
471
460
459
109
16
107
106
105
104
136
17
492
99
464
442
19
20
96
440
95
139
102
128
445
129
124
130
6
449
7
120
496
131
494
495
94
117
4
10
11
12
13
114
4...

result:

ok good plan

Test #12:

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

input:

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

output:

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

result:

ok good plan

Test #13:

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

input:

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

output:

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

result:

ok good plan

Test #14:

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

input:

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

output:

17
125
19
21
30
56
25
33
55
18
2
102
93
8
121
45
3
29
126
71
105
150
47
9
72
95
57
85
59
43
61
89
142
50
124
88
134
122
135
91
24
12
98
146
86
62
132
41
115
77
147
23
120
110
27
51
70
28
148
7
127
67
36
58
139
76
16
133
10
11
14
87
84
106
69
60
38
116
31
42
114
90
82
78
128
101
80
137
117
129
96
5
1...

result:

ok good plan

Test #15:

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

input:

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

output:

129
23
40
39
45
140
29
85
16
111
96
97
62
41
112
7
74
145
75
49
79
21
144
88
13
63
149
81
116
139
20
55
142
100
82
34
150
121
70
108
78
90
53
102
84
107
117
32
125
137
130
76
136
114
80
113
19
148
104
98
86
64
51
122
123
115
124
72
1
48
27
28
73
3
133
50
18
14
8
5
26
10
141
128
127
118
94
89
2
61
58...

result:

ok good plan

Test #16:

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

input:

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

output:

129
63
125
85
109
72
127
64
112
32
50
7
114
44
144
12
133
15
131
61
107
101
41
100
22
37
35
20
90
46
42
88
84
95
28
78
115
43
120
70
27
16
82
146
117
71
94
103
139
4
113
119
24
45
132
23
34
39
137
13
40
14
128
91
31
11
1
56
130
75
140
92
52
122
77
116
83
148
102
143
147
21
69
150
49
86
124
26
19
9
5...

result:

ok good plan

Test #17:

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

input:

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

output:

468
54
142
472
423
685
127
71
261
744
205
234
106
42
540
415
365
702
163
313
421
538
642
579
327
544
439
713
379
390
525
49
102
746
497
236
85
204
687
453
321
161
396
539
734
607
28
47
707
223
706
12
46
655
646
585
590
532
232
216
202
122
4
1
515
595
24
659
466
8
316
99
535
657
658
405
601
420
240
3...

result:

ok good plan

Test #18:

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

input:

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

output:

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

result:

ok good plan

Test #19:

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

input:

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

output:

impossible

result:

ok impossible

Test #20:

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

input:

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

output:

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

result:

ok good plan

Test #21:

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

input:

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

output:

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

result:

ok good plan

Test #22:

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

input:

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

output:

impossible

result:

ok impossible

Test #23:

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

input:

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

output:

impossible

result:

ok impossible

Test #24:

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

input:

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

output:

impossible

result:

ok impossible

Test #25:

score: 0
Accepted
time: 349ms
memory: 35472kb

input:

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

output:

149392
734985
685162
320653
789563
48832
468537
392718
487646
684341
308736
91935
976915
466001
335762
898628
931678
837214
645366
225116
22275
408311
941474
630655
438053
948877
58321
643823
190553
695772
570665
961246
37856
825892
453729
253030
144676
747730
613993
372556
700314
113902
563491
5803...

result:

ok good plan

Test #26:

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

input:

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

output:

impossible

result:

ok impossible

Test #27:

score: 0
Accepted
time: 44ms
memory: 19520kb

input:

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

output:

impossible

result:

ok impossible

Test #28:

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

input:

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

output:

1

result:

ok good plan

Test #29:

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

input:

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

output:

impossible

result:

ok impossible

Test #30:

score: 0
Accepted
time: 19ms
memory: 19664kb

input:

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

output:

impossible

result:

ok impossible

Test #31:

score: 0
Accepted
time: 25ms
memory: 14772kb

input:

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

output:

2
1

result:

ok good plan

Test #32:

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

input:

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

output:

impossible

result:

ok impossible

Test #33:

score: 0
Accepted
time: 13ms
memory: 19520kb

input:

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

output:

3
1
2

result:

ok good plan

Test #34:

score: 0
Accepted
time: 67ms
memory: 11208kb

input:

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

output:

impossible

result:

ok impossible

Test #35:

score: 0
Accepted
time: 59ms
memory: 11204kb

input:

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

output:

impossible

result:

ok impossible

Test #36:

score: 0
Accepted
time: 263ms
memory: 35332kb

input:

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

output:

286072
268218
291344
276244
299946
315142
267974
291368
312412
317316
299688
308960
308828
283972
332110
267980
320522
302408
315178
299664
331846
302354
299712
295798
317310
320438
331828
302132
277730
299714
295100
323084
302402
289068
317112
302346
327016
317288
311838
295886
291484
267954
292808...

result:

ok good plan

Test #37:

score: 0
Accepted
time: 274ms
memory: 39480kb

input:

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

output:

833342
500000
833341
833340
833339
833338
833337
833336
833335
833334
833333
833332
833331
833330
833329
833327
833326
833325
833324
833323
833322
833321
833320
833319
833318
833317
833316
833315
833314
833328
833373
833372
833371
833370
833369
833368
833367
833366
833365
833364
833363
833362
833361...

result:

ok good plan

Test #38:

score: 0
Accepted
time: 475ms
memory: 35332kb

input:

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

output:

510441
605854
748692
138068
164663
492328
319417
944202
483356
900779
217447
500584
487793
417130
475292
889056
297126
115549
77177
32767
235485
327042
765327
786284
163748
879218
90286
496501
732016
763948
183559
637097
679768
751678
216576
234564
711610
952893
823885
181686
269671
924596
911154
32...

result:

ok good plan

Test #39:

score: 0
Accepted
time: 447ms
memory: 35448kb

input:

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

output:

250826
72642
791925
568499
191981
124285
816445
884793
212168
549647
494698
675014
629151
539400
758663
434240
985988
425960
795023
536620
156606
907373
810035
106383
926090
463859
300744
561779
389500
62534
345990
932889
989137
50626
428524
193769
592419
137311
597972
689231
575206
497979
239080
32...

result:

ok good plan

Test #40:

score: 0
Accepted
time: 53ms
memory: 3676kb

input:

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

output:

163
314
186
528
475
251
399
451
396
99
440
417
356
275
190
388
243
540
310
499
213
359
357
21
352
522
216
426
375
403
169
525
276
75
223
56
291
381
508
122
339
319
204
423
266
175
158
106
301
531
479
155
164
116
292
392
378
413
326
41
235
151
421
44
236
443
73
561
347
85
9
205
162
556
138
65
437
231...

result:

ok good plan

Test #41:

score: 0
Accepted
time: 66ms
memory: 4160kb

input:

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

output:

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

result:

ok good plan

Test #42:

score: 0
Accepted
time: 93ms
memory: 5436kb

input:

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

output:

51373
3817
47434
28440
38333
16318
55435
35379
14136
7709
23160
7952
51691
14144
60845
60005
28812
43701
8970
59616
47005
36934
15571
17030
50972
12548
43609
53703
39904
57203
45575
18695
44491
925
51607
34251
6005
41465
50503
24627
46573
47178
24272
62489
10355
38521
29892
6391
34274
13333
55944
25...

result:

ok good plan

Test #43:

score: 0
Accepted
time: 361ms
memory: 32380kb

input:

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

output:

504790
495310
204843
538676
266233
146851
42954
343862
108754
98517
76622
414295
67718
325828
372668
488191
180224
399438
570883
233827
694426
504382
63131
118929
498212
562227
150505
672160
325518
53673
388851
85220
545675
55818
345221
483338
182800
521226
87230
400919
386793
235660
329734
668537
4...

result:

ok good plan

Test #44:

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

input:

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

output:

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

result:

ok good plan

Test #45:

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

input:

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

output:

6
7
2
3
1
8
5
4

result:

ok good plan

Test #46:

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

input:

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

output:

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

result:

ok good plan

Test #47:

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

input:

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

output:

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

result:

ok good plan

Test #48:

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

input:

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

output:

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

result:

ok good plan

Test #49:

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

input:

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

output:

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

result:

ok good plan

Test #50:

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

input:

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

output:

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

result:

ok good plan

Test #51:

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

input:

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

output:

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

result:

ok good plan

Test #52:

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

input:

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

output:

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

result:

ok good plan

Test #53:

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

input:

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

output:

2709
38
1572
1607
1719
1342
3560
3584
3641
883
1641
1969
2952
3074
1426
1378
2808
920
557
2130
1982
865
2707
2427
731
3670
3417
3325
183
3356
540
193
549
1706
2168
2241
2202
2001
2067
1129
1153
2860
1922
82
1697
1791
2543
2171
2854
3486
2404
1526
1898
1797
1656
1996
1956
722
564
37
29
1225
1102
1261...

result:

ok good plan

Test #54:

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

input:

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

output:

2024
7783
515
7172
7337
4936
4898
4620
5197
402
5490
7007
1749
6989
1802
7000
1607
1601
1558
7014
1627
1626
1621
258
1647
2090
6817
2113
6825
2060
53
2226
15
2149
44
47
158
160
165
6926
187
1853
6915
1956
121
1941
6900
529
532
7412
968
958
856
7590
1041
7601
7386
7388
7368
707
701
645
7535
564
811
7...

result:

ok good plan

Test #55:

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

input:

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

output:

1037
1443
271
1937
1396
1502
1700
1730
2179
1431
1146
299
272
566
549
1875
2086
383
39
584
1742
1857
2065
2198
935
974
1377
1357
1440
1442
1438
1306
1630
2061
778
1125
1188
18
727
939
1747
2250
1620
1392
200
139
1764
1881
2117
2070
2227
1910
2021
821
768
293
459
1945
1293
1510
1011
1567
1706
2158
14...

result:

ok good plan

Test #56:

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

input:

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

output:

1004
1007
2854
3255
3163
1065
2978
3673
857
695
708
3759
2920
2091
1929
3052
2498
2653
1316
1463
3432
1147
1720
1718
1789
535
1609
1407
2412
2458
2503
276
3488
3190
3619
3991
2814
3953
778
777
775
107
3655
821
854
856
1047
82
911
928
918
63
3866
384
652
165
4026
167
739
584
2113
2937
2211
2183
2180
...

result:

ok good plan

Test #57:

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

input:

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

output:

3496
3932
180
4856
2783
3192
2868
302
1643
4811
1183
294
412
12
210
561
4937
2813
2804
2771
2518
3785
3143
3268
1860
4437
1657
3979
2293
4915
1206
5244
3116
2088
2321
2319
2302
3158
3163
2645
2456
798
513
168
389
1651
1719
1792
3612
4167
3761
3475
3464
4464
3390
4066
4824
4743
4778
4722
1026
4568
46...

result:

ok good plan

Test #58:

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

input:

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

output:

208
24
1770
503
100
2635
3153
633
206
2109
2388
974
1199
180
855
2979
2363
2923
91
1351
1487
1986
1912
485
228
1046
1237
882
864
2278
2445
2076
620
2283
639
640
701
714
717
3066
144
3344
167
3361
3358
80
66
3267
368
377
259
2642
1353
1848
1437
1401
2632
1413
1273
1799
1652
1654
1782
1668
1827
980
10...

result:

ok good plan

Test #59:

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

input:

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

output:

253
287
1331
334
3246
2233
1748
3248
2880
138
76
708
278
2781
2926
3461
1932
2585
2547
1962
3079
975
438
955
2432
2899
2942
3617
3655
1406
1381
1865
1794
818
2112
3584
3741
3674
656
1092
1100
1213
148
1173
1197
930
299
218
484
793
246
3209
2767
2711
2890
3954
3957
3320
3476
1886
1836
1566
1515
2372
...

result:

ok good plan

Test #60:

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

input:

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

output:

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

result:

ok good plan

Test #61:

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

input:

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

output:

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

result:

ok good plan

Test #62:

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

input:

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

output:

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

result:

ok good plan

Test #63:

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

input:

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

output:

6
10
7
8
1
5
4
3
11
2
9

result:

ok good plan

Test #64:

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

input:

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

output:

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

result:

ok good plan

Test #65:

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

input:

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

output:

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

result:

ok good plan

Test #66:

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

input:

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

output:

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

result:

ok good plan

Test #67:

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

input:

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

output:

1
10
8
7
2
4
9
6
5
3

result:

ok good plan

Test #68:

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

input:

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

output:

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

result:

ok good plan

Test #69:

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

input:

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

output:

2
1
3

result:

ok good plan

Test #70:

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

input:

1
(

output:

impossible

result:

ok impossible

Test #71:

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

input:

1
)

output:

impossible

result:

ok impossible

Test #72:

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

input:

1
)(

output:

impossible

result:

ok impossible

Test #73:

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

input:

1
()

output:

1

result:

ok good plan

Test #74:

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

input:

2
(
)

output:

1
2

result:

ok good plan

Test #75:

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

input:

2
)
(

output:

2
1

result:

ok good plan

Test #76:

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

input:

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

output:

3
2
5
4
6
1

result:

ok good plan

Extra Test:

score: 0
Extra Test Passed