QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#617072#1957. Friendship GraphsFolity#AC ✓124ms7324kbC++201.2kb2024-10-06 13:47:462024-10-06 13:47:47

Judging History

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

  • [2024-10-06 13:47:47]
  • 评测
  • 测评结果:AC
  • 用时:124ms
  • 内存:7324kb
  • [2024-10-06 13:47:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

const int N=1005;
int n,m,x,y;
bool a[N][N];
vector<int> e[N];
void adde(int x,int y){
    e[x].push_back(y);
}
int col[N],cnt[3];
bool flag=1;
void dfs(int u,int f){
    ++cnt[col[u]];
    for(int v:e[u])if(v^f){
        if(col[v]){
            if(col[v]!=3-col[u])flag=0;
        }
        else col[v]=3-col[u],dfs(v,u);
    }
}

vector<pii> blo;
bool f[N],g[N];

int main(){
    cin>>n>>m;
    for(int i=1;i<=m;++i){
        cin>>x>>y;
        a[x][y]=a[y][x]=1;
    }
    for(int i=1;i<=n;++i)
        for(int j=i+1;j<=n;++j)
            if(!a[i][j])adde(i,j),adde(j,i);
    for(int i=1;i<=n;++i)if(!col[i]){
        cnt[1]=cnt[2]=0;
        col[i]=1,dfs(i,0);
        if(!flag)break;
        blo.push_back({cnt[1],cnt[2]});
    }
    if(!flag){cout<<"-1\n";return 0;}
    f[0]=1;
    for(auto [v,w]:blo){
        memset(g,0,sizeof(g));
        for(int j=v;j<=n;++j)g[j]|=f[j-v];
        for(int j=w;j<=n;++j)g[j]|=f[j-w];
        memcpy(f,g,sizeof(f));
    }
    int ans=n+1;
    for(int i=0;i<=n;++i)if(f[i])ans=min(ans,abs(n-i*2));
    if(ans>n)cout<<"-1\n";
    else cout<<ans<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 108ms
memory: 4724kb

input:

1000 499000
20 615
260 390
779 37
13 563
650 605
358 684
783 370
162 90
379 662
88 208
458 371
178 3
590 762
455 514
738 641
270 805
205 881
205 315
837 54
976 579
519 532
982 669
563 804
648 274
268 293
182 392
337 772
961 603
294 607
546 772
189 218
702 266
515 610
691 965
643 235
509 193
184 302
...

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 117ms
memory: 4552kb

input:

1000 498999
35 65
880 835
501 309
590 758
882 857
356 493
43 623
644 637
361 785
58 317
26 11
595 521
723 629
611 36
789 29
30 650
426 475
852 862
667 137
677 173
656 44
457 279
680 567
789 989
368 873
510 721
128 584
835 956
419 779
607 568
317 790
932 580
336 400
74 265
772 855
939 816
448 883
381...

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 123ms
memory: 4680kb

input:

1000 498998
667 721
880 868
426 900
882 839
789 440
590 395
356 847
852 758
35 648
26 723
611 329
644 560
723 45
595 813
501 338
58 762
30 302
43 340
361 734
74 863
128 433
656 196
677 188
932 651
835 603
368 568
336 105
317 225
457 350
419 771
607 545
789 31
772 465
510 542
680 888
504 445
884 999
...

output:

2

result:

ok single line: '2'

Test #4:

score: 0
Accepted
time: 117ms
memory: 4604kb

input:

1000 499499
552 449
897 36
561 770
188 194
233 385
689 608
814 604
386 789
440 778
51 295
368 726
835 647
182 31
387 250
202 887
607 184
189 192
54 774
252 403
562 109
878 528
258 449
823 460
619 906
952 96
69 383
630 81
474 996
273 651
749 270
682 976
147 209
287 612
402 108
575 479
864 462
1000 72...

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 120ms
memory: 4640kb

input:

1000 498751
681 409
733 39
732 717
449 73
41 314
80 971
61 44
139 989
93 338
235 188
113 955
362 380
471 183
228 566
120 625
543 1
450 262
411 197
470 342
461 616
704 186
345 782
499 672
391 288
541 531
917 742
736 819
345 428
821 265
321 789
270 742
452 609
386 668
60 440
421 23
386 677
167 69
944 ...

output:

498

result:

ok single line: '498'

Test #6:

score: 0
Accepted
time: 121ms
memory: 4548kb

input:

1000 499000
679 199
582 83
847 334
396 135
314 922
406 13
371 181
325 954
279 841
428 913
363 248
750 509
283 910
403 697
298 213
56 57
172 914
89 580
203 814
499 491
875 236
846 806
434 31
990 138
883 476
441 309
67 662
829 2
619 824
418 151
788 630
194 350
81 484
548 497
892 45
684 818
516 387
873...

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 121ms
memory: 4548kb

input:

1000 498501
590 631
599 460
689 534
154 899
941 870
605 576
2 374
343 119
264 170
866 139
907 319
256 962
937 684
227 461
805 523
640 16
939 858
593 485
501 791
426 556
596 682
524 5
79 143
782 491
659 211
608 362
85 881
361 867
791 509
601 9
658 609
268 519
391 379
231 580
100 674
668 219
203 778
1...

output:

998

result:

ok single line: '998'

Test #8:

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

input:

1000 249500
596 90
14 715
205 280
125 829
988 726
888 600
689 300
576 837
407 955
473 827
181 232
871 719
528 529
981 53
348 17
245 859
135 52
98 955
671 45
735 48
612 327
122 141
697 215
527 884
31 16
408 262
826 153
464 675
526 344
744 739
838 337
860 9
988 526
498 101
324 212
752 129
119 191
660 ...

output:

0

result:

ok single line: '0'

Test #9:

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

input:

1000 249499
473 827
576 837
205 280
407 955
14 715
125 829
988 726
596 90
689 300
888 600
981 53
671 45
245 859
181 339
98 955
871 719
528 529
135 52
735 48
348 379
612 857
31 327
408 706
464 675
527 884
122 141
826 153
697 579
988 526
324 212
138 316
660 549
860 9
131 782
119 191
752 363
838 510
74...

output:

-1

result:

ok single line: '-1'

Test #10:

score: 0
Accepted
time: 68ms
memory: 7268kb

input:

1000 289101
851 683
314 539
40 366
43 66
782 468
282 843
284 650
455 144
416 146
694 563
879 73
619 563
229 447
472 349
659 262
792 343
690 177
565 191
844 716
756 24
728 971
911 540
675 85
934 110
496 726
956 615
713 747
252 960
77 707
247 671
53 417
334 414
713 24
269 547
399 864
160 542
761 133
3...

output:

398

result:

ok single line: '398'

Test #11:

score: 0
Accepted
time: 68ms
memory: 7324kb

input:

1000 289100
851 683
455 960
43 66
782 468
416 146
314 539
40 366
282 843
694 563
284 650
619 563
229 447
472 349
792 343
879 73
659 262
690 177
565 191
675 242
756 24
911 540
956 615
934 617
844 716
496 726
728 971
77 707
713 24
334 414
247 671
53 417
252 960
713 747
269 547
390 373
399 864
761 354
...

output:

-1

result:

ok single line: '-1'

Test #12:

score: 0
Accepted
time: 99ms
memory: 5504kb

input:

1000 409500
606 839
517 698
761 152
582 382
302 633
725 114
261 469
104 723
34 275
336 658
786 133
243 313
367 839
422 137
440 620
597 337
581 141
84 326
791 744
122 64
56 457
784 786
199 919
235 697
41 64
235 470
439 444
858 746
830 314
998 147
367 421
201 209
326 124
831 712
625 745
453 870
414 38...

output:

800

result:

ok single line: '800'

Test #13:

score: 0
Accepted
time: 99ms
memory: 5580kb

input:

1000 409499
761 661
302 728
517 190
582 357
725 64
606 591
261 659
104 158
581 526
367 591
440 221
56 668
336 313
243 409
786 151
791 356
422 775
84 679
597 859
122 109
34 261
784 170
235 927
199 217
998 923
830 900
858 646
41 109
235 719
439 872
625 322
414 963
929 562
33 373
435 392
531 676
831 88...

output:

-1

result:

ok single line: '-1'

Test #14:

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

input:

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

output:

5

result:

ok single line: '5'

Test #15:

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

input:

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

output:

5

result:

ok single line: '5'

Test #16:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #17:

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

input:

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

output:

5

result:

ok single line: '5'

Test #18:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #19:

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

input:

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

output:

5

result:

ok single line: '5'

Test #20:

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

input:

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

output:

-1

result:

ok single line: '-1'

Test #21:

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

input:

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

output:

4

result:

ok single line: '4'

Test #22:

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

input:

8 21
2 5
1 3
8 4
8 6
4 7
6 5
2 6
6 3
1 5
8 7
1 7
6 4
3 7
2 4
8 3
2 3
6 7
2 7
8 5
2 8
4 3

output:

4

result:

ok single line: '4'

Test #23:

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

input:

100 4923
22 33
71 92
89 32
66 16
81 9
15 64
4 16
12 6
93 80
6 28
59 73
10 50
63 17
19 64
55 40
32 53
27 8
58 46
24 99
90 14
94 89
78 97
83 16
80 53
83 72
4 72
79 86
44 85
62 63
22 90
84 96
34 12
75 71
59 49
41 32
32 97
30 36
57 7
77 83
67 99
47 76
59 70
29 92
81 75
48 76
83 20
70 9
52 53
88 100
52 8...

output:

0

result:

ok single line: '0'

Test #24:

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

input:

100 4888
73 90
42 60
45 65
62 32
64 1
45 6
98 50
58 32
45 48
47 77
43 49
74 49
52 19
83 93
54 3
86 8
90 19
32 2
69 59
62 4
80 24
62 48
19 7
63 71
67 79
31 65
72 29
41 94
32 83
81 88
25 76
99 100
34 30
44 70
78 59
77 82
17 34
26 5
67 96
41 81
2 6
72 70
35 2
89 46
74 72
98 66
8 72
68 14
80 96
91 6
91 ...

output:

-1

result:

ok single line: '-1'

Test #25:

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

input:

100 4905
22 98
43 90
32 64
66 60
6 94
71 99
4 60
12 41
93 96
6 73
59 2
10 93
63 45
19 97
64 40
5 86
27 91
58 90
24 97
95 97
94 85
35 97
83 60
36 15
83 53
4 53
79 87
19 79
62 28
66 1
42 17
34 12
75 9
59 38
87 94
64 85
30 92
57 78
77 41
67 53
16 54
59 74
29 85
81 7
22 16
83 17
38 71
37 66
73 93
52 96
...

output:

0

result:

ok single line: '0'

Test #26:

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

input:

100 4894
73 46
77 6
45 10
62 3
64 73
45 7
98 24
58 2
45 18
47 33
43 37
84 53
52 56
83 24
54 16
86 28
90 56
32 57
69 71
62 26
26 35
62 56
93 50
63 48
67 77
31 10
72 92
41 79
32 43
81 39
25 57
99 94
34 89
44 20
78 71
90 33
17 44
1 61
67 19
41 88
72 20
2 7
35 57
89 37
74 90
98 63
8 90
95 61
80 19
91 7
...

output:

-1

result:

ok single line: '-1'

Test #27:

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

input:

100 4815
63 14
6 59
89 46
90 30
37 67
30 72
63 21
2 40
12 56
45 18
86 62
20 97
89 6
55 85
34 66
40 94
67 93
11 16
21 36
5 87
70 64
5 24
55 18
14 64
32 24
31 6
71 41
27 23
81 21
24 23
95 44
78 44
70 88
96 24
63 68
55 16
78 56
68 34
92 24
44 56
4 97
75 30
95 41
36 13
2 41
29 67
48 42
96 30
80 88
100 9...

output:

46

result:

ok single line: '46'

Test #28:

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

input:

100 4814
61 60
45 76
35 29
61 71
89 53
5 27
87 4
57 38
28 66
89 42
74 6
84 36
51 68
87 51
25 11
79 77
92 70
26 68
48 1
36 33
12 59
7 65
55 65
31 63
75 28
29 91
56 66
31 43
27 93
68 2
51 72
21 13
86 47
86 22
35 55
48 27
8 70
54 58
29 53
75 46
63 67
59 73
87 79
16 22
5 51
30 94
19 65
3 26
58 44
17 69
...

output:

-1

result:

ok single line: '-1'

Test #29:

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

input:

100 4635
63 74
32 72
4 52
37 97
29 14
61 28
63 48
2 28
60 68
8 32
47 26
19 70
4 56
55 59
50 11
36 93
62 22
35 73
70 61
21 22
70 13
100 49
56 42
74 26
95 11
46 9
1 44
85 75
80 65
79 35
21 7
20 22
63 64
100 15
79 83
65 73
31 34
97 83
54 58
73 23
80 26
18 93
78 79
91 70
98 93
20 42
17 74
2 40
45 22
99 ...

output:

76

result:

ok single line: '76'

Test #30:

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

input:

100 4634
5 19
8 44
35 29
24 13
87 26
86 85
63 21
95 4
13 65
24 16
56 67
84 85
15 74
86 93
11 19
50 21
30 61
74 53
91 83
97 46
41 11
58 57
63 99
83 73
29 58
60 68
70 56
99 2
15 99
62 43
82 81
60 71
35 40
91 23
61 87
45 19
48 22
83 79
16 99
8 16
86 7
85 23
31 38
34 74
56 80
59 2
51 56
90 21
29 38
27 7...

output:

-1

result:

ok single line: '-1'

Test #31:

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

input:

100 4902
63 29
91 11
60 27
45 58
8 32
98 76
63 74
100 7
49 35
80 24
42 72
5 93
60 45
20 92
55 91
88 76
92 37
77 22
36 75
69 11
97 36
87 76
97 75
55 97
32 86
15 93
40 90
54 40
84 29
61 93
47 23
50 37
2 27
87 28
12 58
55 26
63 47
2 76
3 28
25 53
32 18
19 45
68 98
31 66
83 18
100 13
81 6
99 73
12 62
52...

output:

0

result:

ok single line: '0'

Test #32:

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

input:

100 4901
33 67
59 9
35 29
30 88
64 62
34 23
5 26
49 28
39 7
64 17
95 38
35 65
40 99
5 60
14 10
78 26
45 52
21 98
29 38
83 65
91 25
56 7
79 49
5 88
89 47
84 39
96 93
87 62
10 88
70 7
40 4
27 39
31 1
87 93
35 16
48 45
92 9
3 94
29 58
89 42
86 62
54 39
34 38
60 66
34 82
8 93
95 7
42 25
50 47
83 82
29 6...

output:

-1

result:

ok single line: '-1'

Test #33:

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

input:

100 4870
2 26
87 58
1 44
2 34
39 44
17 37
53 57
87 9
68 27
66 49
88 63
67 64
53 64
18 24
34 76
95 64
55 83
82 72
28 66
61 54
100 49
91 76
34 7
85 50
5 83
27 58
82 25
38 51
96 69
96 77
78 69
67 43
88 57
10 45
94 36
33 83
82 88
60 83
50 63
65 81
59 63
82 26
68 47
75 43
50 9
37 36
57 69
39 71
100 77
55...

output:

2

result:

ok single line: '2'

Test #34:

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

input:

100 4869
18 3
89 39
47 3
66 76
21 57
89 78
88 78
1 14
2 75
71 90
52 14
28 66
10 86
24 87
67 58
48 86
1 67
24 39
2 1
64 82
86 30
31 67
81 14
51 18
50 27
33 32
18 54
67 59
9 90
87 35
26 79
81 11
27 25
63 67
38 42
88 32
73 46
62 39
9 78
80 100
26 78
26 31
38 74
51 77
26 38
95 91
17 6
8 29
12 53
96 78
7...

output:

-1

result:

ok single line: '-1'

Test #35:

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

input:

100 4710
37 47
36 97
94 16
1 7
96 43
17 97
68 40
95 79
17 73
59 76
65 45
93 5
68 37
41 14
66 50
34 7
100 81
37 83
33 26
85 77
96 41
66 63
78 28
87 55
55 79
100 64
70 50
41 99
41 81
88 34
93 79
65 21
54 79
23 14
98 14
100 96
71 54
19 6
64 77
85 28
17 96
12 67
94 77
96 49
74 18
41 34
46 21
65 96
78 20...

output:

56

result:

ok single line: '56'

Test #36:

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

input:

100 4709
41 24
80 91
40 32
4 76
18 96
80 86
79 35
62 99
24 52
74 4
81 76
38 52
89 71
27 67
81 45
87 99
28 61
48 71
24 78
8 56
53 47
44 30
5 85
51 18
37 32
76 39
41 29
58 42
9 85
31 85
26 83
53 56
87 86
71 70
72 62
79 69
93 61
20 30
9 47
52 35
26 40
26 53
89 25
51 38
26 70
8 44
50 45
36 35
12 80
99 3...

output:

-1

result:

ok single line: '-1'

Test #37:

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

input:

100 4390
75 32
70 59
14 50
94 4
64 86
1 97
8 42
1 38
66 31
8 73
85 92
91 79
35 89
59 29
90 10
6 79
31 47
46 53
84 32
99 22
71 51
1 29
44 3
50 35
36 87
50 16
82 67
93 33
93 29
77 64
82 30
82 28
88 6
5 82
44 18
97 59
91 77
31 94
39 24
57 42
61 92
80 20
3 16
61 47
55 29
10 2
91 9
58 24
97 68
70 16
91 1...

output:

60

result:

ok single line: '60'

Test #38:

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

input:

100 4389
43 23
81 32
16 59
41 94
86 16
24 23
83 90
65 56
58 57
82 13
74 100
52 92
31 44
82 3
1 99
71 42
31 34
65 22
72 2
90 61
38 80
33 30
51 18
49 20
6 56
43 59
97 98
26 97
28 14
21 48
70 54
1 86
73 4
67 19
94 38
100 17
27 52
26 89
53 66
21 45
21 38
67 57
51 100
21 92
68 89
15 24
8 4
64 37
50 28
28...

output:

-1

result:

ok single line: '-1'

Test #39:

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

input:

100 4887
100 49
99 94
1 96
66 7
58 63
80 76
22 33
84 1
26 4
54 97
56 79
5 29
92 74
8 35
9 23
82 2
44 22
15 89
20 58
62 38
41 36
5 45
79 76
90 99
32 89
26 63
27 77
88 73
37 89
40 63
88 76
69 7
80 55
80 89
13 50
83 11
83 73
82 76
52 45
27 80
83 40
8 78
99 30
31 45
72 3
48 49
4 53
78 53
48 21
11 79
94 ...

output:

0

result:

ok single line: '0'

Test #40:

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

input:

100 4884
16 21
16 19
23 59
90 55
55 5
55 77
7 85
30 27
79 54
100 5
25 72
46 18
85 72
2 50
46 75
12 54
62 15
54 21
69 14
1 11
93 70
1 44
3 66
52 18
45 99
73 41
70 47
36 62
31 44
4 41
93 73
91 28
20 16
72 76
6 93
36 83
100 71
85 82
43 32
74 71
13 83
32 30
48 49
8 60
44 56
69 91
50 49
32 48
87 98
43 46...

output:

-1

result:

ok single line: '-1'

Test #41:

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

input:

100 4845
100 73
99 89
1 33
69 47
2 38
26 56
89 76
84 88
26 30
50 55
84 46
54 15
64 76
8 63
65 89
97 59
21 61
22 86
96 4
41 29
62 7
5 96
38 23
90 81
85 76
66 98
27 45
88 71
10 72
63 76
73 55
83 3
26 59
26 10
13 18
70 34
83 95
97 47
52 20
27 9
70 59
41 58
8 31
31 18
67 55
48 73
87 53
77 49
48 94
6 92
...

output:

14

result:

ok single line: '14'

Test #42:

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

input:

100 4844
16 86
26 75
16 72
90 57
60 22
60 69
7 65
85 71
79 51
81 63
25 82
54 26
85 82
78 28
54 57
12 30
6 39
54 86
69 49
1 19
93 27
21 68
3 100
31 30
69 21
18 100
51 86
36 79
57 99
25 77
9 11
92 28
20 51
24 99
6 78
36 56
81 5
14 34
43 76
37 30
45 68
32 91
100 19
8 96
34 84
46 98
83 82
52 30
4 22
43 ...

output:

-1

result:

ok single line: '-1'

Test #43:

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

input:

100 4635
43 55
62 40
62 14
100 94
48 73
87 40
59 58
32 74
23 93
33 51
4 2
47 8
94 26
1 79
92 46
7 63
89 82
20 96
70 65
89 74
35 50
87 96
74 64
23 45
46 76
50 23
60 55
78 6
70 32
57 45
12 78
92 14
59 56
81 65
46 54
76 9
41 9
20 46
48 42
41 57
18 47
4 87
70 66
79 46
75 14
77 65
86 27
65 66
39 81
92 10...

output:

40

result:

ok single line: '40'

Test #44:

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

input:

100 4634
87 22
87 41
21 59
64 52
42 14
42 23
55 1
9 98
20 65
75 63
31 44
26 9
9 99
86 44
26 100
33 43
6 85
26 27
16 21
25 58
68 82
25 82
94 11
85 24
23 14
2 76
18 92
36 52
14 65
31 78
68 19
7 15
70 63
12 96
62 25
75 5
11 18
60 95
3 38
54 58
95 50
29 91
8 93
16 17
95 41
32 77
60 23
47 63
32 57
6 31
4...

output:

-1

result:

ok single line: '-1'

Test #45:

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

input:

100 4215
35 17
5 76
21 61
80 72
10 8
1 58
100 1
25 96
78 26
36 27
48 46
20 41
89 29
43 75
59 66
71 56
43 28
24 42
64 97
11 49
100 57
97 45
98 68
31 55
15 57
32 62
76 72
12 9
20 51
10 82
17 13
54 61
28 26
59 76
21 44
28 5
74 79
78 33
71 57
6 45
87 66
27 65
38 44
55 76
22 93
71 74
67 33
59 36
46 66
87...

output:

40

result:

ok single line: '40'

Test #46:

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

input:

100 4214
17 78
26 86
82 42
9 46
18 39
50 45
18 91
87 31
27 100
59 35
89 79
10 46
80 22
99 49
28 31
77 87
78 47
99 41
52 23
55 12
97 21
2 68
71 41
34 24
9 14
19 79
50 54
82 57
44 25
44 21
6 90
12 4
65 17
88 73
35 22
15 68
12 90
28 11
1 21
1 17
62 13
83 79
6 57
76 86
55 6
30 23
9 83
73 8
85 7
31 8
15 ...

output:

-1

result:

ok single line: '-1'

Test #47:

score: 0
Accepted
time: 119ms
memory: 4664kb

input:

999 494702
993 189
655 901
119 956
811 856
83 927
567 643
407 766
861 44
627 307
454 540
837 727
796 680
183 84
368 563
704 538
182 302
423 521
274 71
720 767
989 332
371 794
385 253
904 262
55 426
768 282
765 330
604 53
41 531
460 405
470 657
52 391
756 382
616 18
712 995
42 79
697 247
811 915
411 ...

output:

689

result:

ok single line: '689'

Test #48:

score: 0
Accepted
time: 120ms
memory: 4668kb

input:

999 494701
26 823
705 22
716 512
943 184
498 771
952 450
715 418
925 579
412 22
583 302
465 34
574 285
629 158
448 793
917 491
435 447
172 610
220 973
835 309
183 938
105 605
373 659
109 259
776 127
424 393
533 749
452 501
293 887
277 88
62 706
845 691
514 311
6 80
51 28
397 542
686 380
481 673
791 ...

output:

-1

result:

ok single line: '-1'

Test #49:

score: 0
Accepted
time: 120ms
memory: 4724kb

input:

999 485836
47 103
328 371
94 779
403 772
420 144
516 265
6 330
652 815
900 903
412 64
598 710
796 446
224 690
226 29
355 193
76 310
855 216
927 614
135 814
411 442
684 219
768 156
68 244
379 45
46 141
267 336
368 705
5 265
819 335
384 253
980 38
345 685
653 641
105 464
905 336
495 450
69 36
690 267
...

output:

701

result:

ok single line: '701'

Test #50:

score: 0
Accepted
time: 124ms
memory: 4872kb

input:

999 485835
957 233
224 996
59 344
895 774
708 881
964 930
966 466
276 970
501 166
408 388
372 30
909 914
615 350
616 444
786 401
950 449
777 253
64 509
65 782
468 572
644 214
370 399
642 996
526 946
694 962
149 438
895 5
239 618
309 251
99 740
286 36
306 797
950 344
97 660
98 698
977 687
642 628
120...

output:

-1

result:

ok single line: '-1'

Test #51:

score: 0
Accepted
time: 120ms
memory: 4940kb

input:

999 473171
43 277
415 852
492 8
576 270
961 524
801 632
171 30
736 781
279 786
983 638
523 839
715 902
497 332
153 614
426 936
316 538
294 77
692 671
545 332
851 278
60 481
735 82
952 961
28 483
666 662
615 695
364 394
33 847
528 595
72 800
951 359
591 455
574 886
11 966
82 161
315 383
537 652
948 9...

output:

701

result:

ok single line: '701'

Test #52:

score: 0
Accepted
time: 110ms
memory: 4844kb

input:

999 473170
175 847
770 799
182 938
531 829
140 943
622 39
429 916
941 68
579 790
99 945
236 327
585 367
501 425
266 25
482 738
300 863
143 546
450 163
316 601
94 146
827 243
501 824
875 67
886 530
759 484
986 742
601 248
744 967
776 150
62 749
152 945
382 366
575 867
841 535
274 669
743 176
621 44
3...

output:

-1

result:

ok single line: '-1'

Test #53:

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

input:

999 447841
25 925
158 951
885 683
857 793
898 268
970 59
801 170
203 362
96 111
226 877
425 798
219 818
172 410
569 274
83 449
736 65
247 935
548 931
352 727
505 455
656 399
799 150
124 119
369 498
136 330
769 333
905 8
557 823
896 580
612 480
720 386
587 972
464 299
31 819
673 301
468 10
831 301
68...

output:

701

result:

ok single line: '701'

Test #54:

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

input:

999 447840
85 227
675 453
75 746
605 134
530 646
820 579
341 606
221 105
475 894
798 843
210 564
637 103
7 787
188 969
111 25
548 338
266 776
597 393
804 415
252 988
155 251
594 294
245 133
547 725
362 431
406 973
152 501
440 854
755 186
488 358
826 866
26 79
15 367
257 481
924 686
496 82
909 271
82...

output:

-1

result:

ok single line: '-1'

Test #55:

score: 0
Accepted
time: 118ms
memory: 4820kb

input:

999 491696
999 817
915 878
679 216
411 297
870 893
794 251
886 913
481 615
303 382
297 346
709 93
905 844
684 935
480 72
326 606
638 318
544 651
101 496
984 405
494 191
549 242
60 926
738 580
469 989
600 631
458 455
569 366
873 629
45 356
387 999
500 281
363 465
165 651
714 801
75 943
613 320
286 88...

output:

301

result:

ok single line: '301'

Test #56:

score: 0
Accepted
time: 114ms
memory: 4756kb

input:

999 491695
197 537
246 620
729 365
619 297
460 70
775 809
285 527
844 928
828 258
44 2
641 686
536 271
828 610
998 907
921 548
243 884
261 150
159 501
862 824
333 623
241 394
519 511
949 610
475 666
296 135
983 209
199 375
656 845
692 925
393 412
658 942
220 863
276 223
53 125
729 859
409 280
715 15...

output:

-1

result:

ok single line: '-1'

Test #57:

score: 0
Accepted
time: 115ms
memory: 4856kb

input:

999 475816
91 53
901 108
846 875
118 834
924 465
579 863
860 253
872 306
324 214
302 443
418 974
769 709
681 188
571 67
186 983
273 513
786 163
592 908
364 241
841 812
523 517
48 682
900 230
145 458
620 400
868 528
827 608
481 827
320 273
659 951
688 893
741 37
395 626
239 138
553 461
693 598
191 16...

output:

301

result:

ok single line: '301'

Test #58:

score: 0
Accepted
time: 112ms
memory: 4956kb

input:

999 475815
430 616
360 484
149 758
488 328
260 541
40 816
208 192
940 60
459 231
465 706
145 654
999 198
63 490
887 771
671 287
193 579
815 476
241 302
404 984
163 66
482 985
50 868
812 126
120 72
774 934
813 373
952 440
614 224
226 619
242 956
788 888
208 227
729 150
416 578
958 835
498 918
63 675
...

output:

-1

result:

ok single line: '-1'

Test #59:

score: 0
Accepted
time: 110ms
memory: 5272kb

input:

999 453131
375 412
54 662
114 511
116 928
45 94
934 197
431 549
223 756
346 321
867 787
863 956
454 961
183 682
484 478
755 678
395 496
22 410
913 637
125 285
980 327
259 992
486 820
265 101
999 154
440 482
987 122
711 545
217 545
60 303
218 944
184 813
705 716
73 138
594 633
627 870
304 775
111 722...

output:

301

result:

ok single line: '301'

Test #60:

score: 0
Accepted
time: 111ms
memory: 5284kb

input:

999 453130
545 889
244 933
824 471
528 58
431 807
760 413
958 838
994 340
952 559
434 528
656 478
109 717
955 330
977 132
743 42
909 106
355 477
608 695
23 627
433 227
564 718
728 454
92 476
62 979
264 451
211 714
895 46
782 580
648 454
196 684
686 918
988 670
495 301
44 575
608 769
850 982
978 692
...

output:

-1

result:

ok single line: '-1'

Test #61:

score: 0
Accepted
time: 97ms
memory: 5940kb

input:

999 407761
589 544
125 4
646 698
706 567
13 641
110 559
631 792
952 105
707 446
507 501
706 402
710 880
185 220
101 951
691 896
163 279
969 180
738 340
564 400
618 881
259 735
543 93
955 4
107 330
259 258
672 542
91 247
332 546
292 397
345 4
532 900
123 142
672 895
960 472
672 248
972 123
360 196
31...

output:

301

result:

ok single line: '301'

Test #62:

score: 0
Accepted
time: 102ms
memory: 5872kb

input:

999 407760
775 221
372 672
761 685
409 940
198 571
798 69
470 347
480 960
845 971
333 874
593 296
493 302
454 297
326 967
150 849
323 553
648 689
651 701
492 456
367 340
298 969
788 15
794 755
817 454
272 684
165 92
477 672
387 880
298 365
424 263
902 854
906 644
224 861
728 615
641 144
556 461
250 ...

output:

-1

result:

ok single line: '-1'

Test #63:

score: 0
Accepted
time: 114ms
memory: 4788kb

input:

999 491016
867 728
907 606
249 180
899 606
263 158
433 870
610 110
119 69
104 930
744 487
155 792
417 973
489 808
287 782
515 358
818 298
486 711
249 767
562 769
682 453
346 798
379 542
582 243
848 890
920 214
36 119
437 156
140 67
36 220
6 322
375 318
801 72
503 197
858 242
406 229
601 719
86 824
6...

output:

1

result:

ok single line: '1'

Test #64:

score: 0
Accepted
time: 119ms
memory: 4764kb

input:

999 491015
206 754
426 451
348 77
102 836
729 458
44 735
835 624
19 619
480 392
470 335
986 330
7 624
411 526
867 503
430 800
893 884
534 347
132 45
106 935
304 374
936 415
768 312
828 638
965 342
186 773
190 442
364 305
837 250
893 132
305 53
550 283
660 975
1 677
200 229
732 13
304 35
811 505
919 ...

output:

-1

result:

ok single line: '-1'

Test #65:

score: 0
Accepted
time: 115ms
memory: 4984kb

input:

999 473551
680 382
864 383
332 303
963 670
958 51
470 661
448 609
573 944
204 213
572 535
5 510
877 55
225 874
54 808
533 227
37 222
262 785
444 639
940 867
425 733
746 900
826 933
561 736
768 516
87 530
875 611
449 183
225 921
148 454
984 645
150 275
322 620
880 28
119 732
744 344
693 692
875 616
1...

output:

1

result:

ok single line: '1'

Test #66:

score: 0
Accepted
time: 114ms
memory: 4972kb

input:

999 473550
911 727
845 326
406 762
558 324
508 19
442 731
847 88
296 794
968 224
258 264
530 637
45 413
892 21
306 988
13 926
715 889
737 114
918 180
898 179
160 897
498 92
845 633
406 219
521 27
713 273
78 797
342 422
874 558
975 819
728 399
140 880
306 280
141 686
461 589
722 221
552 962
138 690
9...

output:

-1

result:

ok single line: '-1'

Test #67:

score: 0
Accepted
time: 110ms
memory: 5216kb

input:

999 448601
431 509
616 555
962 478
229 642
110 484
72 705
269 310
437 253
997 125
172 900
758 995
372 318
229 746
982 786
850 387
350 916
687 263
792 752
716 905
22 724
768 476
583 131
91 635
887 295
401 638
121 125
256 687
690 259
508 515
757 173
121 743
856 601
226 759
186 22
11 676
556 513
799 80...

output:

1

result:

ok single line: '1'

Test #68:

score: 0
Accepted
time: 109ms
memory: 5232kb

input:

999 448600
901 368
870 290
710 854
440 465
917 746
366 520
843 877
33 11
968 125
420 48
571 458
926 536
265 101
318 426
993 679
465 191
586 520
378 544
907 61
947 349
987 912
446 66
547 133
726 149
113 332
151 682
79 564
767 490
968 32
997 960
639 732
559 304
819 127
937 251
402 885
877 63
807 492
6...

output:

-1

result:

ok single line: '-1'

Test #69:

score: 0
Accepted
time: 96ms
memory: 5936kb

input:

999 398701
640 317
590 400
243 569
181 632
243 939
757 122
169 218
485 95
182 741
268 572
171 858
894 594
350 621
256 357
437 388
860 972
642 764
863 567
641 873
788 37
334 816
768 244
829 332
874 214
899 66
856 468
393 441
815 34
260 53
580 372
709 35
371 518
647 502
264 857
77 7
501 454
948 651
90...

output:

1

result:

ok single line: '1'

Test #70:

score: 0
Accepted
time: 101ms
memory: 5832kb

input:

999 398700
384 354
98 486
763 431
530 960
683 377
551 425
283 727
330 490
18 990
163 686
386 473
973 548
914 854
130 566
105 299
799 151
130 721
285 217
571 456
801 651
936 198
834 873
456 329
775 218
939 44
796 757
135 412
558 708
791 847
917 265
56 810
23 688
23 238
303 446
817 189
659 839
779 583...

output:

-1

result:

ok single line: '-1'