QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#215246#5108. Prehistoric ProgramsYYYYYYYYAC ✓145ms31528kbC++142.3kb2023-10-15 07:16:532023-10-15 07:16:53

Judging History

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

  • [2023-10-15 07:16:53]
  • 评测
  • 测评结果:AC
  • 用时:145ms
  • 内存:31528kb
  • [2023-10-15 07:16:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

void processString(int num, vector<array<int, 3>>* data);//to store the strings' properties
void selfDefinedSort(vector<array<int, 3>>* data);//sort the strings according to self-defined criteria
bool check(int num, vector<array<int, 3>> data);//check if the result is a legal permutation

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int num;
	cin >> num;
	vector<array<int, 3>> data(num);
	
	processString(num, &data);
	selfDefinedSort(&data);

	if(!check(num, data)) cout << "impossible\n";
	else {
		for(int i = 0; i < num; i++){
			cout << data[i][2] << "\n";
		}
	}
	return 0;
}

void processString(int num, vector<array<int, 3>>* data){
    for(int i = 0; i < num; i++){
		string str;
		cin >> str;
		int mn = 0, total = 0;
		for(int j = 0; j < str.length(); j++){
			if(str[j] == '(') total++; // (: 1, ): -1
			else total--;
			mn = min(mn, total);
			//minimum is the number of unpaired ')' the string has
		}
		total -= mn;
		//total is the number of unpaired '(' the string has
		(*data)[i][0] = total;
		(*data)[i][1] = -mn;
		(*data)[i][2] = i + 1;
		//store the string's index
	}
	return;
}
void selfDefinedSort(vector<array<int, 3>>* data){
    //use the built-in sorting for vector and self-define the sorting
    sort((*data).begin(), (*data).end(), [&](const array<int, 3> &a, const array<int, 3> &b){
        int temp1 = (a[0] == a[1] ? 0 : (a[0] > a[1] ? 1 : -1));
        int temp2 = (b[0] == b[1] ? 0 : (b[0] > b[1] ? 1 : -1));
        //0 if the string has no unpaired '(', 1 if the string has more '(' than ')', -1 otherwise
        if (temp1 != temp2) return temp1 > temp2;
        //the larger temporary signal should be placed first
        if (temp1 == 1) return a[1] < b[1];
        //the string with less unpaired ')' should be placed first
        else return a[0] > b[0];
        //the string with more unpaired '(' should be placed first
    });
    return;
}
bool check(int num, const vector<array<int, 3>> data){
    int mn = 0, total = 0;
	for(auto x : data){
		mn = min(mn, total - x[1]);
		if(mn < 0) return false;
		//return false if ')' outnumber '('
		total += x[0] - x[1];
	}
	if(total != 0) return false;
	//return false some brackets remain unpaired
	return true;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 4420kb

input:

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

output:

26315
26345
26341
26339
26336
26334
26333
26329
26328
26327
26321
26320
26318
26317
26316
26347
26313
26311
26308
26307
26305
26302
26297
26295
26294
26292
26290
26289
26286
26384
26414
26413
26412
26409
26406
26402
26401
26399
26398
26396
26395
26394
26393
26285
26383
26382
26380
26376
26370
26366
...

result:

ok good plan

Test #2:

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

input:

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

output:

598
268
267
265
590
258
257
929
595
253
252
271
933
934
247
245
243
242
604
935
239
827
287
563
564
919
301
566
296
570
291
290
573
826
286
575
576
282
577
280
925
584
585
814
945
198
636
638
947
640
190
189
188
948
632
646
182
181
179
178
177
650
652
171
216
825
611
229
228
615
619
223
820
819
217
...

result:

ok good plan

Test #3:

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

input:

2
()
()

output:

1
2

result:

ok good plan

Test #4:

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

input:

2
((
))

output:

1
2

result:

ok good plan

Test #5:

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

input:

2
)(
()

output:

impossible

result:

ok impossible

Test #6:

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

input:

3
()
(
)

output:

2
1
3

result:

ok good plan

Test #7:

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

input:

3
)(
(
)

output:

2
1
3

result:

ok good plan

Test #8:

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

input:

5
))(
(()
)(
(
)

output:

2
4
3
1
5

result:

ok good plan

Test #9:

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

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

input:

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

output:

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

result:

ok good plan

Test #12:

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

input:

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

output:

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

result:

ok good plan

Test #13:

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

input:

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

output:

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

result:

ok good plan

Test #14:

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

input:

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

output:

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

result:

ok good plan

Test #15:

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

input:

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

output:

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

result:

ok good plan

Test #16:

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

input:

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

output:

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

result:

ok good plan

Test #17:

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

input:

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

output:

230
665
243
450
585
668
238
669
455
231
246
229
228
227
672
225
224
584
673
220
258
657
658
265
264
263
440
441
442
259
674
588
661
255
587
446
250
663
664
690
184
182
181
180
473
176
175
475
172
185
169
477
166
164
163
162
160
159
158
680
218
581
214
213
212
461
677
208
204
269
681
195
578
684
468
...

result:

ok good plan

Test #18:

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

input:

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

output:

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

result:

ok good plan

Test #19:

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

input:

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

output:

impossible

result:

ok impossible

Test #20:

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

input:

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

output:

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

result:

ok good plan

Test #21:

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

input:

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

output:

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

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

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: 129ms
memory: 26744kb

input:

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

output:

534143
534126
534127
534129
534130
534133
534135
534139
534140
534142
534125
534144
534145
534146
534150
534153
534154
534155
534158
534104
534082
534090
534091
534097
534098
534100
534102
534103
534159
534110
534111
534112
534113
534114
534117
534118
534119
534215
534201
534203
534204
534206
534209...

result:

ok good plan

Test #26:

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

input:

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

output:

impossible

result:

ok impossible

Test #27:

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

input:

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

output:

impossible

result:

ok impossible

Test #28:

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

input:

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

output:

1

result:

ok good plan

Test #29:

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

input:

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

output:

impossible

result:

ok impossible

Test #30:

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

input:

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

output:

impossible

result:

ok impossible

Test #31:

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

input:

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

output:

2
1

result:

ok good plan

Test #32:

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

input:

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

output:

impossible

result:

ok impossible

Test #33:

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

input:

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

output:

3
1
2

result:

ok good plan

Test #34:

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

input:

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

output:

impossible

result:

ok impossible

Test #35:

score: 0
Accepted
time: 63ms
memory: 26472kb

input:

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

output:

impossible

result:

ok impossible

Test #36:

score: 0
Accepted
time: 107ms
memory: 26800kb

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: 95ms
memory: 31528kb

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: 145ms
memory: 26612kb

input:

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

output:

206352
578956
206360
206359
578966
578975
578977
578984
578989
578955
206350
578997
579001
579005
206342
579014
579017
579019
206374
578928
206383
578935
206380
578939
578941
578942
578943
206338
578944
206371
578950
206367
206366
206365
578953
578954
206307
579052
579053
206314
579063
206311
579064...

result:

ok good plan

Test #39:

score: 0
Accepted
time: 134ms
memory: 26728kb

input:

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

output:

578993
206267
578977
206265
578981
206262
578982
578987
578989
578975
206256
206255
206253
578999
579001
579002
579005
579009
578946
206290
206289
578929
206286
578932
206283
578938
578941
579021
206279
578950
578955
206274
578969
206271
578970
578974
206209
579081
206219
579082
579085
206215
579095...

result:

ok good plan

Test #40:

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

input:

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

output:

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

result:

ok good plan

Test #41:

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

input:

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

output:

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

result:

ok good plan

Test #42:

score: 0
Accepted
time: 24ms
memory: 4784kb

input:

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

output:

16651
14200
23409
25515
36753
58630
39037
28166
29778
53637
36752
53634
20443
31719
46297
5059
9781
58648
36742
14193
46277
14191
9785
20440
23402
21451
9788
53629
58599
58574
58578
58580
5109
20450
46335
25499
27918
16633
39021
25502
5097
21447
5042
58601
46329
5091
23412
46323
36762
32352
5085
255...

result:

ok good plan

Test #43:

score: 0
Accepted
time: 108ms
memory: 20584kb

input:

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

output:

140120
329701
329699
140107
140108
591188
329693
677839
677836
329690
329686
329683
140118
329703
140121
329680
677832
591195
140125
140127
140128
329675
677830
329669
140132
591170
329739
140079
329736
140081
140082
677851
329735
329734
140086
591169
329732
329663
329725
329724
329721
140093
329720...

result:

ok good plan

Test #44:

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

input:

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

output:

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

result:

ok good plan

Test #45:

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

input:

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

output:

6
3
7
2
1
4
5
8

result:

ok good plan

Test #46:

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

input:

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

output:

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

result:

ok good plan

Test #47:

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

input:

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

output:

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

result:

ok good plan

Test #48:

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

input:

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

output:

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

result:

ok good plan

Test #49:

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

input:

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

output:

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

result:

ok good plan

Test #50:

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

input:

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

output:

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

result:

ok good plan

Test #51:

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

input:

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

output:

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

result:

ok good plan

Test #52:

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

input:

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

output:

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

result:

ok good plan

Test #53:

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

input:

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

output:

2482
2456
2457
1111
2460
2461
1107
2462
2465
2466
2472
1097
2475
2453
2488
2489
2493
1090
1089
2495
1087
2497
2499
1084
1082
2434
1146
1145
1142
2426
2428
1137
1136
2431
2432
1133
1132
1081
1129
1128
1127
2437
2438
2441
2447
1118
2451
1116
2452
1035
2535
1047
1046
2538
1044
1043
2542
2547
1039
1038
...

result:

ok good plan

Test #54:

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

input:

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

output:

3228
3242
3241
3240
3239
6355
3233
6359
6360
3243
3227
6362
3223
3222
3221
6364
3219
3217
3253
3266
6341
6342
3261
3260
3259
3256
3254
6366
3251
3250
3249
3248
6349
3245
6351
3181
3192
3190
6380
3188
6381
3186
6383
3182
6378
3180
3176
3175
6388
3169
3166
3165
3204
3215
6367
6368
3212
6370
6371
3207
...

result:

ok good plan

Test #55:

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

input:

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

output:

1145
1172
1167
1163
1162
1159
1157
1156
1149
1146
1174
1143
1141
1136
1134
1132
1127
1126
1120
1199
1226
1222
1220
1217
1215
1211
1202
1200
1119
1198
1187
1185
1184
1182
1179
1177
1176
1037
1061
1057
1055
1050
1048
1047
1044
1039
1065
1035
1024
1017
1012
1010
1007
1002
1000
1099
1118
1117
1112
1108
...

result:

ok good plan

Test #56:

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

input:

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

output:

2752
1269
1268
2731
2735
1265
1264
2737
2741
1260
2743
2746
2748
1255
1254
2728
2758
2766
1248
1247
2767
1245
1244
2768
2769
2770
2772
2774
2776
2705
2686
1301
2691
1299
2693
2694
2696
1294
2698
2701
2703
1289
1288
2779
2706
1285
1284
2714
2715
2716
1278
1277
1276
2718
1274
2720
2726
2844
2821
1200
...

result:

ok good plan

Test #57:

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

input:

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

output:

1933
3421
1920
1921
4498
4496
1927
1928
3874
4492
1918
1934
3418
1936
1938
4489
4488
3417
4486
1944
4510
1884
1885
3428
4518
1893
1894
3427
4512
4511
1945
1902
4509
3426
1908
1911
4505
4504
3424
3423
2000
1979
1980
1981
4475
4474
1986
4468
3412
4466
3414
4463
3410
4460
4459
3876
3408
4456
2012
3407
...

result:

ok good plan

Test #58:

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

input:

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

output:

1031
3053
3054
2705
3055
3056
1037
1036
1035
2704
1033
1032
1930
3057
3058
3059
1933
2703
1935
1936
1937
1938
1020
1019
1059
2713
1072
1071
1914
3042
1067
1066
2711
3044
3046
2710
1018
1058
1057
1919
1920
3051
1923
1927
1929
1045
1044
980
993
992
990
2698
988
987
2697
985
984
1954
3079
1951
979
978
...

result:

ok good plan

Test #59:

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

input:

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

output:

2072
2062
2063
2064
2066
2067
2068
2069
2071
2060
2079
2083
2084
2085
2086
2087
2090
2035
2016
2019
2020
2022
2027
2031
2032
2033
2093
2036
2040
2050
2053
2056
2057
2059
2169
2155
2156
2158
2162
2163
2166
2167
2168
2154
2170
2171
2172
2173
2176
2178
2180
2135
2104
2108
2120
2121
2123
2126
2127
2130
...

result:

ok good plan

Test #60:

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

input:

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

output:

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

result:

ok good plan

Test #61:

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

input:

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

output:

5636
2882
5650
5649
2885
2888
5646
2890
2891
5645
5644
2894
5642
5640
2899
5637
2881
2905
2911
2912
2913
2914
5630
2916
5628
2919
2920
2921
2922
2923
2925
2926
5655
5665
2848
5664
2851
5662
2853
2854
5661
2856
2857
5659
5656
2863
2864
2865
2927
2867
2868
2869
2870
5654
5653
5652
2874
2875
2876
5651
...

result:

ok good plan

Test #62:

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

input:

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

output:

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

result:

ok good plan

Test #63:

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

input:

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

output:

3
4
5
6
7
10
9
8
1
2
11

result:

ok good plan

Test #64:

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

input:

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

output:

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

result:

ok good plan

Test #65:

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

input:

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

output:

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

result:

ok good plan

Test #66:

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

input:

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

output:

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

result:

ok good plan

Test #67:

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

input:

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

output:

1
2
7
8
10
3
4
5
6
9

result:

ok good plan

Test #68:

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

input:

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

output:

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

result:

ok good plan

Test #69:

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

input:

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

output:

2
1
3

result:

ok good plan

Test #70:

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

input:

1
(

output:

impossible

result:

ok impossible

Test #71:

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

input:

1
)

output:

impossible

result:

ok impossible

Test #72:

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

input:

1
)(

output:

impossible

result:

ok impossible

Test #73:

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

input:

1
()

output:

1

result:

ok good plan

Test #74:

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

input:

2
(
)

output:

1
2

result:

ok good plan

Test #75:

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

input:

2
)
(

output:

2
1

result:

ok good plan

Test #76:

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

input:

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

output:

3
5
2
1
4
6

result:

ok good plan

Extra Test:

score: 0
Extra Test Passed