QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#356452#5108. Prehistoric ProgramsTWTP_TCTF#WA 195ms29604kbC++141.7kb2024-03-17 20:01:082024-03-17 20:01:09

Judging History

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

  • [2024-03-17 20:01:09]
  • 评测
  • 测评结果:WA
  • 用时:195ms
  • 内存:29604kb
  • [2024-03-17 20:01:08]
  • 提交

answer

#include<iostream>
#include <bits/stdc++.h>

#define ld long double
#define ll long long
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 1e4 + 9, MOD = 998244353;

//
// + +, - - , - +
//(((  , )))  , )))(((

//  ))))(((( , (((((( , ))))))
pair<int, int> calc(string &s) {
    int cnt = 0;
    int mn = 1e9;
    for (auto i: s) {
        if (i == '(') {
            cnt++;
        } else {
            cnt--; // ((()
        }
        mn = min(mn, cnt);
    }
    return {mn, cnt};
}

// )))) , )))(((( -3 , 1      // )(((  ))))))) (((((((((((      // 7,5 // 5,5
bool sortt(pair<int, pair<int, int> > &x, pair<int, pair<int, int> > &y) {
    pair<int, int> a = x.second, b = y.second;

    if (a.second >= 0 && b.second >= 0) {
        return a.first > b.first;
    }
    if (a.second < 0 && b.second < 0) {
        return a.first < b.first;
    }
    return a.second > b.second;
}

void doWork() {
    int n;
    cin >> n;
    vector<pair<int, pair<int, int> > > v;

    for (int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        v.push_back({i, calc(s)});
    }
    sort(v.begin(), v.end(), sortt);
    ll total = 0;
    for (auto i: v) {
        if (total + i.second.first < 0) {
            cout << "impossible";
            return;
        }
        total += i.second.second;
    }
    if (total != 0) {
        cout << "impossible";
    } else {
        for (auto i: v)cout << i.first << "\n";
    }
}

int main() {

    IO
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; i++) {
        //  cout << "Case #" << i << ": ";
        doWork();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 9ms
memory: 4304kb

input:

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

output:

25955
25989
25988
25985
25983
25980
25978
25977
25974
25968
25960
25958
25957
25956
25990
25951
25950
25946
25944
25943
25941
25940
25937
25935
25931
25925
25917
25915
26017
26063
26051
26047
26045
26042
26039
26038
26036
26027
26025
26024
26022
26021
25914
26016
26012
26010
26009
26007
26005
26001
...

result:

ok good plan

Test #2:

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

input:

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

output:

511
162
803
164
590
166
324
168
801
725
171
502
316
943
177
178
804
799
514
182
585
584
798
881
309
188
189
190
894
945
577
876
125
126
127
471
131
615
977
134
135
136
934
473
474
611
576
604
143
857
347
147
877
935
598
335
334
496
498
329
327
245
228
229
287
774
557
554
282
280
553
852
715
707
242
...

result:

ok good plan

Test #3:

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

input:

2
()
()

output:

1
2

result:

ok good plan

Test #4:

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

input:

2
((
))

output:

1
2

result:

ok good plan

Test #5:

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

input:

2
)(
()

output:

impossible

result:

ok impossible

Test #6:

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

input:

3
()
(
)

output:

2
1
3

result:

ok good plan

Test #7:

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

input:

3
)(
(
)

output:

2
1
3

result:

ok good plan

Test #8:

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

input:

5
))(
(()
)(
(
)

output:

2
4
3
1
5

result:

ok good plan

Test #9:

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

input:

3
((
))())
(

output:

1
3
2

result:

ok good plan

Test #10:

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

input:

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

output:

impossible

result:

ok impossible

Test #11:

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

input:

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

output:

420
416
214
211
210
209
208
207
203
415
199
198
196
424
194
192
191
426
226
399
234
232
404
405
406
228
227
427
409
410
411
412
219
413
414
153
440
442
160
159
158
157
156
445
439
152
149
449
143
452
141
139
177
428
186
429
184
182
431
180
178
239
176
434
172
435
436
437
166
309
362
321
320
318
315
...

result:

ok good plan

Test #12:

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

input:

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

output:

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

result:

ok good plan

Test #13:

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

input:

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

output:

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

result:

ok good plan

Test #14:

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

input:

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

output:

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

result:

ok good plan

Test #15:

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

input:

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

output:

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

result:

ok good plan

Test #16:

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

input:

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

output:

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

result:

ok good plan

Test #17:

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

input:

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

output:

229
581
584
243
587
238
588
589
231
230
246
228
227
225
592
220
593
594
214
264
555
556
274
563
569
570
571
265
213
263
573
574
259
258
255
578
250
164
625
632
176
175
635
172
636
169
166
180
162
160
159
158
157
155
152
150
191
212
601
208
605
606
609
195
612
281
618
622
624
186
185
184
182
181
384
...

result:

ok good plan

Test #18:

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

input:

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

output:

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

result:

ok good plan

Test #19:

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

input:

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

output:

impossible

result:

ok impossible

Test #20:

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

input:

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

output:

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

result:

ok good plan

Test #21:

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

input:

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

output:

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

result:

ok good plan

Test #22:

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

input:

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

output:

impossible

result:

ok impossible

Test #23:

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

input:

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

output:

impossible

result:

ok impossible

Test #24:

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

input:

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

output:

impossible

result:

ok impossible

Test #25:

score: 0
Accepted
time: 161ms
memory: 15600kb

input:

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

output:

528195
528176
528177
528180
528181
528183
528187
528188
528189
528171
528196
528201
528204
528206
528208
528211
528212
528213
528149
528125
528127
528129
528133
528135
528137
528139
528146
528215
528151
528152
528154
528155
528157
528159
528160
528169
528293
528269
528270
528271
528272
528276
528279...

result:

ok good plan

Test #26:

score: 0
Accepted
time: 15ms
memory: 20388kb

input:

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

output:

impossible

result:

ok impossible

Test #27:

score: 0
Accepted
time: 15ms
memory: 19808kb

input:

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

output:

impossible

result:

ok impossible

Test #28:

score: 0
Accepted
time: 15ms
memory: 21080kb

input:

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

output:

1

result:

ok good plan

Test #29:

score: 0
Accepted
time: 11ms
memory: 21116kb

input:

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

output:

impossible

result:

ok impossible

Test #30:

score: 0
Accepted
time: 11ms
memory: 21300kb

input:

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

output:

impossible

result:

ok impossible

Test #31:

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

input:

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

output:

2
1

result:

ok good plan

Test #32:

score: 0
Accepted
time: 7ms
memory: 16212kb

input:

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

output:

impossible

result:

ok impossible

Test #33:

score: 0
Accepted
time: 11ms
memory: 19956kb

input:

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

output:

3
1
2

result:

ok good plan

Test #34:

score: 0
Accepted
time: 61ms
memory: 16276kb

input:

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

output:

impossible

result:

ok impossible

Test #35:

score: 0
Accepted
time: 57ms
memory: 15980kb

input:

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

output:

impossible

result:

ok impossible

Test #36:

score: 0
Accepted
time: 98ms
memory: 17312kb

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: 105ms
memory: 29604kb

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: 195ms
memory: 16228kb

input:

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

output:

218824
673999
673994
218791
673992
673991
673990
673985
673979
673978
673975
673972
218812
218814
218815
673957
674001
673949
673946
673942
218831
673937
673936
673935
218838
218841
218845
218846
218847
673921
673920
218853
218747
674105
674101
218721
674096
218724
218725
674093
218730
674085
674084...

result:

ok good plan

Test #39:

score: 0
Accepted
time: 173ms
memory: 15816kb

input:

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

output:

469346
187051
721754
469340
356016
469342
187057
721748
469343
187061
721746
187064
187067
721743
469345
187050
469349
721726
469351
721716
721715
469355
187083
469357
187088
187090
721695
187097
721690
721817
469318
186999
721833
187002
187005
187006
721828
721827
721826
187011
721822
187015
187016...

result:

ok good plan

Test #40:

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

input:

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

output:

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

result:

ok good plan

Test #41:

score: -100
Wrong Answer
time: 36ms
memory: 4636kb

input:

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

output:

impossible

result:

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