QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#583097#5108. Prehistoric ProgramsdeepthoughtWA 274ms80588kbC++231.4kb2024-09-22 18:19:382024-09-22 18:19:39

Judging History

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

  • [2024-09-22 18:19:39]
  • 评测
  • 测评结果:WA
  • 用时:274ms
  • 内存:80588kb
  • [2024-09-22 18:19:38]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
pair<int, int> look(const string& s) {
    int fin = 0;
    int minima = 0;
    for(int i = 0; i < s.length(); i++) {
        if(s[i] == '(') fin++;
        else fin--;
        // if(s.length() == 150) cout << i << " " << fin << endl;
        minima = min(fin, minima);
    }
    return {fin, minima};
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector <string> a(n + 1);
    vector <pair <int, int>> v1;
    vector <pair <int, pair<int, int>>> v2;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        auto ax = look(a[i]);
        int minima = ax.second;
        int fin = ax.first;
        if(fin >= 0) {
            v1.push_back({-minima, i});
        }
        else {
            v2.push_back({minima, {- fin,i}});
        }
    }
    vector <int> ans;
    string s = "";
    
    sort(v1.begin(), v1.end());
    for(auto x: v1) {
        int idx = x.second;
        s += a[idx];
        ans.push_back(idx);
    }


    sort(v2.begin(), v2.end());
    for(auto x: v2) {
        int idx = x.second.second;
        s += a[idx];
        // cout << idx << " " << a[idx] << endl;
        ans.push_back(idx);
    }

    auto bx = look(s);
    
    if(bx.second >= 0 && bx.first == 0) {
        for(auto x: ans)
            cout << x << '\n';
    }
    else cout << "impossible" << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 13ms
memory: 7352kb

input:

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

output:

1
2
5
7
8
9
10
11
12
13
14
16
19
23
27
28
29
30
32
34
35
37
38
42
43
44
54
55
58
59
61
65
69
70
72
76
77
79
80
87
91
92
93
94
95
96
97
99
103
112
116
117
118
120
122
125
126
127
128
129
130
131
133
135
136
143
146
147
148
149
150
151
154
161
162
163
164
165
166
169
172
175
176
177
178
179
181
182
18...

result:

ok good plan

Test #2:

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

input:

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

output:

1
3
10
12
13
14
17
18
20
22
30
31
33
35
36
39
45
54
58
60
62
64
65
66
75
77
80
83
84
85
88
89
90
92
97
98
101
104
106
110
112
115
122
123
125
126
127
128
131
134
135
136
143
147
162
164
166
168
171
177
178
179
181
182
188
189
190
197
198
206
208
209
212
213
214
215
216
217
221
223
228
229
239
242
24...

result:

ok good plan

Test #3:

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

input:

2
()
()

output:

1
2

result:

ok good plan

Test #4:

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

input:

2
((
))

output:

1
2

result:

ok good plan

Test #5:

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

input:

2
)(
()

output:

impossible

result:

ok impossible

Test #6:

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

input:

3
()
(
)

output:

1
2
3

result:

ok good plan

Test #7:

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

input:

3
)(
(
)

output:

2
1
3

result:

ok good plan

Test #8:

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

input:

5
))(
(()
)(
(
)

output:

2
4
3
1
5

result:

ok good plan

Test #9:

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

input:

3
((
))())
(

output:

1
3
2

result:

ok good plan

Test #10:

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

input:

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

output:

impossible

result:

ok impossible

Test #11:

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

input:

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

output:

1
4
6
7
10
11
12
13
16
17
19
20
22
23
24
26
27
29
31
33
36
37
38
40
41
45
46
49
51
52
53
55
56
58
59
60
62
65
66
69
70
71
72
73
74
75
76
77
78
79
80
82
83
85
86
87
90
91
92
94
95
96
99
102
104
105
106
107
109
114
117
120
124
128
129
130
131
132
133
136
139
141
143
149
152
153
156
157
158
159
160
166...

result:

ok good plan

Test #12:

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

input:

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

output:

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

result:

ok good plan

Test #13:

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

input:

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

output:

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

result:

ok good plan

Test #14:

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

input:

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

output:

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

result:

ok good plan

Test #15:

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

input:

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

output:

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

result:

ok good plan

Test #16:

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

input:

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

output:

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

result:

ok good plan

Test #17:

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

input:

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

output:

1
4
7
9
13
16
17
19
20
21
22
25
27
34
37
41
43
45
48
55
56
57
58
62
65
66
67
69
74
79
80
81
82
95
97
101
103
104
105
108
112
116
121
122
131
136
138
141
148
149
150
152
155
156
157
158
159
160
162
163
164
166
169
172
175
176
180
181
182
184
185
186
191
195
197
204
208
212
213
214
218
220
224
225
227...

result:

ok good plan

Test #18:

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

input:

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

output:

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

result:

ok good plan

Test #19:

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

input:

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

output:

impossible

result:

ok impossible

Test #20:

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

input:

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

output:

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

result:

ok good plan

Test #21:

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

input:

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

output:

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

result:

ok good plan

Test #22:

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

input:

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

output:

impossible

result:

ok impossible

Test #23:

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

input:

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

output:

impossible

result:

ok impossible

Test #24:

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

input:

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

output:

impossible

result:

ok impossible

Test #25:

score: 0
Accepted
time: 217ms
memory: 72576kb

input:

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

output:

2
4
5
6
8
9
12
13
20
23
28
29
30
31
32
36
37
38
42
44
49
52
54
55
60
63
65
66
69
74
77
82
86
87
88
89
90
91
94
95
98
99
100
102
104
106
110
111
112
117
119
120
122
133
135
139
140
142
143
144
147
149
150
151
153
156
157
159
164
165
167
168
170
172
177
179
180
181
183
190
192
193
197
200
203
204
207
...

result:

ok good plan

Test #26:

score: 0
Accepted
time: 21ms
memory: 24740kb

input:

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

output:

impossible

result:

ok impossible

Test #27:

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

input:

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

output:

impossible

result:

ok impossible

Test #28:

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

input:

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

output:

1

result:

ok good plan

Test #29:

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

input:

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

output:

impossible

result:

ok impossible

Test #30:

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

input:

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

output:

impossible

result:

ok impossible

Test #31:

score: 0
Accepted
time: 23ms
memory: 31012kb

input:

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

output:

2
1

result:

ok good plan

Test #32:

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

input:

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

output:

impossible

result:

ok impossible

Test #33:

score: 0
Accepted
time: 21ms
memory: 34320kb

input:

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

output:

3
1
2

result:

ok good plan

Test #34:

score: 0
Accepted
time: 76ms
memory: 68640kb

input:

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

output:

impossible

result:

ok impossible

Test #35:

score: 0
Accepted
time: 86ms
memory: 70320kb

input:

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

output:

impossible

result:

ok impossible

Test #36:

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

input:

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

output:

2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
72
74
76
78
80
82
84
86
88
90
92
94
96
98
100
102
104
106
108
110
112
114
116
118
120
122
124
126
128
130
132
134
136
138
140
142
144
146
148
150
152
154
156
158
160
162
164
166
168
170
172
174
176
1...

result:

ok good plan

Test #37:

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

input:

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

output:

500001
500002
500003
500004
500005
500006
500007
500008
500009
500010
500011
500012
500013
500014
500015
500016
500017
500018
500019
500020
500021
500022
500023
500024
500025
500026
500027
500028
500029
500030
500031
500032
500033
500034
500035
500036
500037
500038
500039
500040
500041
500042
500043...

result:

ok good plan

Test #38:

score: 0
Accepted
time: 272ms
memory: 80588kb

input:

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

output:

5
10
11
13
14
17
20
21
27
29
33
36
37
40
43
49
57
59
61
62
63
65
75
83
84
87
90
93
99
102
104
115
119
128
133
139
146
151
154
155
157
158
159
164
173
174
176
181
183
185
187
190
191
194
196
197
207
212
214
215
218
219
222
223
224
226
229
230
233
237
239
240
243
244
249
250
251
252
253
257
258
260
26...

result:

ok good plan

Test #39:

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

input:

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

output:

2
5
6
12
13
15
19
20
23
26
29
36
38
39
44
46
47
59
61
66
70
72
75
86
87
92
94
97
99
100
101
104
110
113
115
118
119
126
128
132
134
136
138
141
143
149
150
157
158
163
168
171
180
187
189
190
193
195
211
219
225
228
230
232
233
235
237
239
243
247
253
257
258
259
260
269
270
273
274
278
279
282
284
...

result:

ok good plan

Test #40:

score: 0
Accepted
time: 78ms
memory: 26308kb

input:

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

output:

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

result:

ok good plan

Test #41:

score: -100
Wrong Answer
time: 84ms
memory: 25384kb

input:

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

output:

impossible

result:

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