QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#302954#6307. Chase Game 2Szy#AC ✓36ms9904kbC++231.1kb2024-01-11 16:03:322024-01-11 16:03:32

Judging History

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

  • [2024-01-11 16:03:32]
  • 评测
  • 测评结果:AC
  • 用时:36ms
  • 内存:9904kb
  • [2024-01-11 16:03:32]
  • 提交

answer

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

const int maxn = 1e5 + 10;
int n, cnt[maxn], a, b;
vector<int>v[maxn];
priority_queue<int>q;

void sol() {
    scanf("%d", &n);
    while (!q.empty()) q.pop();
    for (int i = 1; i <= n; ++i) v[i].clear(), cnt[i] = 0;
    for (int i = 1; i < n; ++i) {
        scanf("%d%d", &a, &b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    if (n == 2) {
        puts("-1");
        return;
    }
    for (int i = 1; i <= n; ++i) {
        if (v[i].size() == 1) ++cnt[v[i][0]];
    }
    int mx=0,sum=0,g=0;
    for (int i = 1; i <= n; ++i)
    {
        if (cnt[i])
        {
            ++g;
            mx=max(mx,cnt[i]);
            sum+=cnt[i];
            //printf("[%d]\n",i);
        }
    }
    if (g == 1) {
        puts("-1");
        return;
    }
    if(mx>=(sum-mx)) {
        printf("%d\n", mx);
    }
    else printf("%d\n",(sum+1)/2);
}
int main() {
    int TT;
    scanf("%d", &TT);
    while (TT--) sol();
    return 0;
}
/*
4
2
1 2
4
1 2
2 3
3 4
4
1 2
2 3
2 4
5
1 2
3 5
2 3
3 4
*/

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5980kb

input:

4
2
1 2
4
1 2
2 3
3 4
4
1 2
2 3
2 4
5
1 2
2 3
3 4
3 5

output:

-1
1
-1
2

result:

ok 4 number(s): "-1 1 -1 2"

Test #2:

score: 0
Accepted
time: 5ms
memory: 5984kb

input:

10000
4
1 2
1 3
3 4
4
1 2
1 3
1 4
4
1 2
2 3
1 4
5
1 2
2 3
1 4
4 5
5
1 2
2 3
3 4
4 5
4
1 2
2 3
2 4
5
1 2
1 3
2 4
2 5
4
1 2
2 3
1 4
5
1 2
1 3
2 4
1 5
5
1 2
2 3
3 4
2 5
5
1 2
1 3
2 4
2 5
4
1 2
1 3
3 4
5
1 2
1 3
3 4
1 5
4
1 2
1 3
1 4
5
1 2
1 3
3 4
3 5
5
1 2
2 3
3 4
3 5
4
1 2
1 3
2 4
5
1 2
2 3
2 4
3 5
5
...

output:

1
-1
1
1
1
-1
2
1
2
2
2
1
2
-1
2
2
1
2
2
1
1
1
-1
2
2
2
1
-1
1
1
2
1
1
-1
1
2
1
1
1
-1
1
1
2
2
2
1
1
1
-1
1
2
1
1
2
1
2
1
1
2
-1
-1
-1
2
2
2
1
1
1
2
2
2
-1
1
2
-1
1
1
-1
2
-1
-1
1
2
2
2
1
1
1
1
1
1
1
1
1
2
-1
1
1
2
-1
2
1
1
1
-1
2
-1
1
-1
-1
2
-1
2
1
2
2
1
1
1
1
2
1
1
1
1
-1
2
1
2
1
1
1
1
1
1
1
2
-1...

result:

ok 10000 numbers

Test #3:

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

input:

10000
9
1 2
2 3
3 4
4 5
1 6
6 7
5 8
7 9
9
1 2
2 3
2 4
1 5
2 6
4 7
6 8
1 9
9
1 2
2 3
1 4
4 5
5 6
4 7
2 8
1 9
10
1 2
2 3
1 4
3 5
3 6
2 7
6 8
6 9
6 10
10
1 2
1 3
3 4
2 5
1 6
5 7
4 8
2 9
7 10
10
1 2
2 3
2 4
1 5
3 6
6 7
5 8
4 9
9 10
9
1 2
2 3
2 4
1 5
3 6
2 7
1 8
2 9
9
1 2
1 3
2 4
1 5
3 6
3 7
7 8
8 9
10
1...

output:

1
3
3
3
2
2
3
2
3
2
3
2
3
2
3
3
3
2
3
2
3
2
3
3
2
2
3
3
3
3
3
3
2
3
3
3
4
3
3
3
2
3
3
3
3
3
2
3
3
3
3
3
3
2
3
2
3
2
2
3
3
4
3
4
3
3
2
2
3
2
2
2
3
3
2
3
3
2
4
3
3
3
2
3
2
2
3
3
3
3
2
3
3
2
3
3
3
3
3
2
3
2
2
3
5
3
3
2
2
3
2
3
4
2
5
3
2
3
3
2
3
2
3
3
3
3
2
2
3
3
3
2
3
3
3
3
3
3
2
3
3
2
2
4
3
3
3
3
2
3
...

result:

ok 10000 numbers

Test #4:

score: 0
Accepted
time: 5ms
memory: 5976kb

input:

10000
9
1 2
2 3
1 4
2 5
3 6
5 7
2 8
2 9
9
1 2
2 3
1 4
2 5
5 6
5 7
1 8
7 9
9
1 2
1 3
1 4
1 5
4 6
5 7
1 8
6 9
9
1 2
1 3
3 4
2 5
2 6
6 7
6 8
6 9
10
1 2
1 3
2 4
1 5
2 6
5 7
4 8
1 9
9 10
10
1 2
1 3
3 4
4 5
5 6
2 7
7 8
7 9
1 10
10
1 2
1 3
3 4
3 5
1 6
2 7
3 8
3 9
6 10
10
1 2
2 3
1 4
1 5
3 6
2 7
6 8
4 9
5 1...

output:

3
3
3
3
3
2
4
2
2
3
3
3
3
3
3
3
3
3
2
3
3
3
2
2
2
3
3
2
3
2
3
3
3
2
3
2
3
3
3
3
4
2
2
3
2
2
3
4
3
4
3
3
3
3
3
3
3
2
3
3
2
2
3
4
2
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
1
2
3
2
2
3
3
2
3
3
2
2
3
2
3
2
3
3
2
2
3
3
2
3
3
3
2
3
3
2
2
3
3
3
2
3
3
5
4
3
2
3
2
3
3
3
3
2
2
3
3
3
3
3
3
2
3
2
3
3
3
4
3
2
3
2
3
3
3
2
...

result:

ok 10000 numbers

Test #5:

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

input:

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

output:

5
6
5
5
5
4
5
6
3
6
5
4
5
6
5
6
5
5
5
5
5
4
5
5
5
6
6
5
6
4
5
5
6
4
5
5
4
5
3
6
5
5
6
5
5
4
5
3
6
6
5
5
6
4
6
5
5
5
6
5
5
5
4
6
4
5
5
5
4
5
5
5
6
7
5
5
6
6
4
6
5
5
5
5
6
6
5
6
6
6
4
5
6
4
5
4
4
5
5
6
5
5
5
7
5
5
5
5
4
4
6
4
6
4
5
4
4
6
4
5
5
5
4
5
5
5
6
5
5
6
5
5
3
4
6
4
4
5
5
5
4
4
6
5
5
5
5
6
5
6
...

result:

ok 10000 numbers

Test #6:

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

input:

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

output:

11
11
12
14
10
11
14
11
14
12
11
12
12
11
13
12
12
13
12
13
10
10
13
12
11
11
12
11
12
12
11
12
13
10
14
12
11
9
11
12
12
11
13
12
14
13
10
9
12
13
12
12
12
14
12
11
13
11
13
13
14
11
13
13
13
11
11
13
11
13
13
11
11
12
12
11
11
11
13
12
13
11
13
12
12
13
13
12
13
14
11
12
11
12
11
12
12
13
14
12
12...

result:

ok 4000 numbers

Test #7:

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

input:

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

output:

25
23
22
23
25
23
24
25
21
21
24
24
23
21
25
25
25
23
25
24
23
22
26
26
23
24
25
26
24
23
22
25
25
24
23
22
24
22
24
23
24
26
25
22
22
22
25
21
25
24
26
26
25
24
25
24
24
25
23
24
23
24
21
23
24
25
22
25
24
25
22
25
22
23
24
26
25
27
23
24
25
25
23
23
24
23
23
25
25
27
22
21
23
28
27
23
25
26
23
23
...

result:

ok 2000 numbers

Test #8:

score: 0
Accepted
time: 18ms
memory: 6020kb

input:

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

output:

236
231
238
231
227
235
241
230
238
230
236
237
224
237
241
235
244
242
245
243
234
236
239
231
228
227
228
238
243
234
238
255
253
230
239
254
226
233
230
242
235
240
235
242
229
249
246
249
242
243
234
237
235
227
249
240
244
233
234
244
241
233
234
225
237
242
239
242
232
248
233
234
220
222
227
...

result:

ok 200 numbers

Test #9:

score: 0
Accepted
time: 18ms
memory: 6540kb

input:

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

output:

2403
2490
2391
2263
2356
2482
2384
2469
2386
2265
2283
2342
2381
2382
2261
2353
2287
2499
2458
2426

result:

ok 20 numbers

Test #10:

score: 0
Accepted
time: 36ms
memory: 9608kb

input:

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

output:

22980
24011

result:

ok 2 number(s): "22980 24011"

Test #11:

score: 0
Accepted
time: 9ms
memory: 6084kb

input:

10000
9
9 2
5 7
8 9
9 4
3 5
3 6
9 5
1 9
9
4 2
9 4
4 8
1 4
9 7
4 6
5 3
5 4
9
4 1
9 6
7 4
4 2
7 5
2 3
6 2
3 8
9
7 9
6 8
5 2
9 4
1 3
6 5
4 6
6 3
9
6 3
3 5
3 2
4 1
1 8
3 1
9 4
3 7
10
6 4
1 3
1 6
7 9
6 9
4 8
4 10
2 9
3 5
9
8 2
8 9
8 3
9 7
5 9
1 3
3 6
4 9
10
4 6
3 5
7 6
3 2
6 10
6 8
9 6
6 2
6 1
9
8 4
7 1
...

output:

4
4
2
2
4
3
3
6
3
5
-1
4
5
5
3
4
3
5
4
4
3
3
2
5
5
5
3
5
6
5
-1
3
5
-1
-1
5
-1
4
3
3
3
2
-1
-1
6
4
-1
3
6
5
-1
5
4
4
-1
3
2
3
3
2
3
5
-1
3
-1
5
3
-1
4
4
4
4
4
4
4
3
2
-1
-1
3
2
5
4
2
-1
5
2
3
-1
3
2
-1
6
4
3
5
3
4
5
2
3
2
2
-1
-1
5
4
3
3
-1
-1
-1
2
3
4
5
-1
5
3
-1
6
-1
2
3
6
6
5
2
4
3
6
-1
5
5
3
6
2...

result:

ok 10000 numbers

Test #12:

score: 0
Accepted
time: 9ms
memory: 6304kb

input:

10000
9
8 1
5 8
3 9
6 9
6 8
3 4
2 9
6 7
9
3 8
8 4
9 2
6 2
2 5
2 7
1 5
8 2
9
1 2
6 5
1 6
6 7
1 3
8 6
4 6
1 9
9
2 3
8 3
9 4
5 4
3 7
3 4
1 3
6 1
10
10 4
10 9
10 5
1 8
10 7
6 3
10 2
3 10
10 8
10
6 10
1 6
4 8
9 6
2 4
5 6
7 6
4 3
4 6
10
2 8
3 2
7 4
5 6
10 3
6 4
7 1
6 9
3 4
9
2 3
5 3
3 7
3 4
3 9
6 3
3 1
3 ...

output:

3
3
4
3
5
5
3
-1
4
2
-1
3
4
5
-1
6
3
6
-1
5
4
-1
2
3
3
3
2
4
-1
5
3
-1
7
5
4
5
5
-1
5
4
6
5
3
-1
4
3
5
6
3
4
-1
5
5
3
3
5
-1
2
4
2
-1
5
-1
5
3
-1
2
3
3
-1
-1
4
5
6
2
2
3
3
3
3
-1
-1
4
4
2
-1
3
2
-1
3
5
4
-1
-1
6
3
4
5
2
5
-1
2
-1
2
4
-1
-1
3
4
6
6
7
4
-1
4
4
2
-1
4
5
4
2
4
4
-1
2
3
3
3
5
6
3
6
5
-1
...

result:

ok 10000 numbers

Test #13:

score: 0
Accepted
time: 18ms
memory: 6044kb

input:

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

output:

-1
-1
13
-1
8
-1
5
12
6
9
5
6
-1
-1
-1
5
5
-1
10
-1
10
7
6
-1
-1
7
5
-1
4
11
-1
9
-1
10
9
-1
6
8
10
10
-1
-1
9
5
12
5
11
12
6
7
5
6
6
-1
6
9
5
6
9
-1
10
8
-1
-1
9
5
10
-1
12
10
10
-1
-1
10
-1
5
6
-1
5
5
5
4
-1
5
10
6
7
9
8
9
4
5
4
7
10
-1
-1
6
-1
6
9
-1
-1
6
10
-1
6
7
4
5
-1
-1
-1
-1
12
6
6
7
5
-1
1...

result:

ok 10000 numbers

Test #14:

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

input:

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

output:

8
5
6
8
5
-1
-1
6
10
-1
-1
6
4
4
14
6
5
6
5
10
-1
6
9
11
8
8
9
-1
12
12
4
5
5
5
-1
11
7
-1
-1
8
9
9
9
7
5
8
-1
5
5
7
5
5
8
5
12
6
7
9
10
-1
5
-1
5
11
6
5
12
7
-1
5
9
10
-1
10
6
4
8
10
10
-1
4
5
6
12
-1
7
6
7
6
5
4
5
7
5
10
5
4
6
7
7
7
-1
-1
5
-1
9
5
10
10
8
-1
5
-1
6
-1
9
-1
11
5
8
11
8
12
11
10
11
...

result:

ok 10000 numbers

Test #15:

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

input:

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

output:

23
12
10
24
18
24
18
-1
11
12
15
15
29
12
-1
13
20
-1
15
12
-1
11
11
24
19
16
29
27
26
-1
-1
12
22
15
16
26
25
12
24
26
13
29
15
-1
-1
-1
23
12
26
13
-1
14
-1
21
21
25
-1
-1
13
13
-1
12
14
13
12
13
13
14
15
-1
16
21
14
26
23
13
16
12
23
14
17
17
24
29
17
14
19
23
29
-1
12
-1
12
19
14
24
15
19
15
15
...

result:

ok 4000 numbers

Test #16:

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

input:

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

output:

19
18
24
28
18
-1
14
12
-1
-1
25
25
17
13
11
22
11
-1
28
16
13
12
-1
29
13
11
29
-1
18
-1
11
-1
23
12
12
13
20
13
18
12
24
20
23
23
17
26
-1
23
26
15
26
21
12
-1
24
24
30
-1
-1
-1
18
21
11
13
-1
-1
16
15
25
-1
25
20
10
25
27
-1
15
19
14
30
19
23
31
15
27
24
13
15
-1
23
20
-1
-1
19
-1
12
11
19
-1
11
...

result:

ok 4000 numbers

Test #17:

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

input:

2000
98
96 39
67 96
76 1
76 75
82 76
65 76
76 13
76 60
2 66
53 76
76 90
76 45
62 84
51 76
6 74
21 33
68 23
81 6
72 17
76 14
26 41
24 95
81 48
79 76
11 76
30 76
76 64
55 76
44 76
3 15
77 32
88 68
57 12
76 63
59 76
7 81
76 10
76 87
40 92
76 28
57 67
17 67
76 70
9 68
20 69
17 5
65 38
36 89
23 94
71 25
...

output:

32
50
51
34
50
50
54
49
31
24
-1
58
47
36
-1
52
47
54
32
36
47
50
22
34
-1
52
32
53
34
-1
25
23
-1
26
26
30
25
21
45
47
-1
22
51
41
34
-1
-1
44
32
31
53
54
51
26
48
-1
-1
-1
24
26
33
23
23
-1
48
34
53
22
49
30
48
26
-1
-1
31
24
52
-1
33
48
43
39
37
-1
54
-1
53
27
25
32
58
62
24
-1
23
-1
23
26
32
-1
...

result:

ok 2000 numbers

Test #18:

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

input:

2000
93
21 92
6 91
12 59
53 8
4 59
37 59
14 85
82 59
35 59
19 20
59 54
49 59
59 62
23 59
10 59
46 32
65 39
41 10
2 91
59 55
42 74
59 17
39 77
56 15
9 19
70 59
16 60
26 67
14 59
59 90
77 54
59 68
59 60
45 59
63 64
76 92
63 59
86 26
84 59
59 44
69 59
46 93
59 46
59 9
32 43
41 7
56 59
78 59
59 58
31 59...

output:

36
31
22
25
24
-1
58
26
22
37
31
59
-1
36
21
45
-1
-1
48
-1
23
54
-1
51
35
33
-1
22
33
23
55
53
37
49
25
33
39
42
36
40
55
44
-1
49
25
39
25
-1
33
-1
-1
-1
24
-1
45
51
27
-1
49
-1
49
-1
24
-1
24
-1
21
50
35
23
-1
24
34
41
52
31
-1
23
-1
29
58
32
26
52
33
51
32
31
-1
26
23
49
21
37
52
-1
24
26
-1
24
...

result:

ok 2000 numbers

Test #19:

score: 0
Accepted
time: 18ms
memory: 6388kb

input:

200
948
17 489
79 914
669 852
634 946
442 360
722 329
66 632
869 397
56 96
309 83
133 17
86 578
67 535
808 825
163 810
367 350
351 853
137 325
349 338
67 399
273 307
148 871
548 428
571 817
940 22
494 886
422 277
545 34
650 88
942 464
201 867
917 705
775 67
132 867
447 80
230 198
105 76
742 796
884 ...

output:

238
228
311
335
-1
228
-1
305
220
498
317
-1
-1
229
-1
-1
-1
226
308
245
313
-1
-1
243
-1
478
-1
327
332
492
482
477
484
512
463
482
317
-1
340
-1
469
-1
506
246
469
-1
329
-1
461
252
232
461
328
-1
299
223
244
321
259
495
473
-1
499
507
497
246
250
473
341
240
489
329
497
301
-1
304
-1
308
306
318
...

result:

ok 200 numbers

Test #20:

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

input:

200
994
228 352
219 305
893 377
538 253
563 847
836 856
900 721
9 92
823 335
197 796
641 673
580 747
333 415
382 721
857 480
839 442
370 85
300 805
622 446
712 851
861 329
557 887
530 865
132 928
591 59
531 736
185 749
23 209
488 344
55 384
738 121
898 908
656 788
318 832
231 703
904 538
766 827
303...

output:

247
-1
324
-1
236
472
-1
496
332
473
508
306
326
325
-1
242
300
495
-1
-1
-1
346
-1
499
328
-1
481
455
322
-1
478
325
472
242
-1
-1
476
-1
335
313
477
298
-1
331
233
-1
327
242
-1
231
-1
478
-1
488
240
495
-1
311
465
332
499
248
-1
472
-1
468
334
-1
505
-1
510
323
479
-1
-1
473
236
320
238
237
227
4...

result:

ok 200 numbers

Test #21:

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

input:

20
9437
1041 614
2260 1041
1041 6652
1041 1062
5344 1041
1041 7452
7610 1041
1041 5923
1041 5301
7923 1041
1041 4157
1041 2967
1041 1141
1041 2909
1041 8211
1041 8350
3111 1041
4586 1041
9059 1041
4166 1041
1041 5399
1041 7089
1041 7274
1041 9119
4262 1041
8772 1041
1337 1041
7182 1041
1041 7957
104...

output:

-1
2463
4553
2356
3027
-1
-1
3088
3138
4832
-1
-1
4962
-1
4975
4921
-1
2421
2447
2323

result:

ok 20 numbers

Test #22:

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

input:

20
9157
1840 2053
4000 2053
2053 3759
5162 2053
2053 5660
2053 3419
7930 2053
2053 5157
2882 2053
2053 3253
2558 2053
8765 2053
7636 2053
2053 8803
2053 736
2053 9032
2053 4816
2053 1955
2053 8119
6138 2053
2053 3020
1894 2053
2053 1232
2053 1282
2053 5570
1262 2053
2504 2053
5169 2053
4338 2053
205...

output:

-1
2298
3322
4685
4911
4755
4858
-1
4795
2279
4799
2378
2455
2421
4674
2331
-1
4955
3039
4624

result:

ok 20 numbers

Test #23:

score: 0
Accepted
time: 33ms
memory: 9904kb

input:

2
97074
85963 67826
85963 58732
85963 66509
18931 85963
24345 85963
55283 87512
35724 35295
52714 85963
77338 64660
86660 31150
90257 89313
85963 10008
40466 85963
59061 65531
40301 85963
36139 52308
33257 85963
85963 5002
12888 11473
5932 75469
85963 22794
67230 85963
39349 85963
14191 85963
1243 8...

output:

32327
46820

result:

ok 2 number(s): "32327 46820"

Test #24:

score: 0
Accepted
time: 33ms
memory: 9648kb

input:

2
94295
28534 2134
2310 28534
28534 87013
49342 90726
87228 28534
79091 28534
84629 20054
28534 65122
62137 18206
26136 29225
75846 28534
18413 73926
56246 28534
32682 28534
73339 28534
67264 88141
14488 29602
30585 11013
71473 28534
63066 57800
63481 2923
27807 73127
28534 87446
67889 28878
14097 4...

output:

31501
32940

result:

ok 2 number(s): "31501 32940"