QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#426398#6329. Colorful GraphCryingAC ✓1362ms22304kbC++142.3kb2024-05-31 10:07:202024-05-31 10:07:21

Judging History

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

  • [2024-05-31 10:07:21]
  • 评测
  • 测评结果:AC
  • 用时:1362ms
  • 内存:22304kb
  • [2024-05-31 10:07:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 7010;
int n,m,match[MAXN],cnt;
vector<int> e[MAXN];

bitset<MAXN> to[MAXN];
int qu[MAXN*2],hd,rr,pre[MAXN*2];
bitset<MAXN> f[MAXN],vis,tmp[MAXN];

int dfs(int u){
    tmp[u] = f[u] & vis;
    for(int v = tmp[u]._Find_first();v<=n;v=tmp[u]._Find_next(v)){
        vis[v] = 0;
        if(!match[v])return match[v] = u;
        else if(dfs(match[v]))return match[v] = u;
        tmp[u] &= vis;
    }
    return 0;
}

int fa[MAXN],ans[MAXN],col;
int find(int x){return (fa[x]==x)?x:(fa[x]=find(fa[x]));}

int main(){
    //freopen("color.in","r",stdin); freopen("color.out","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0);

    cin>>n>>m;
    for(int i=1,u,v;i<=m;i++){
        cin>>u>>v;
        e[u].push_back(v);
    }
    iota(fa+1,fa+1+n,1);
    for(int i=1;i<=n;i++){
        to[i][i] = 1; hd = rr = 0; qu[rr++] = i;
        while(hd<rr){
            int u = qu[hd++];
            for(auto v : e[u])if(!to[i][v]){
                to[i][v] = 1;
                qu[rr++] = v;
            }
        }
    }
    for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++){
        if(to[i][j] && to[j][i])f[i][j] = 1;
        else if(to[i][j])f[i][j] = 1;
        else if(to[j][i])f[j][i] = 1;
    }
    //
    for(int i=1;i<=n;i++){
        vis.set();
        hd = rr = 0; memset(pre,0,sizeof pre); qu[rr++] = i;
        int to = -1;
        while(hd<rr){
            int u = qu[hd++];
            if(u<=n){
                tmp[u] = f[u] & vis;
                for(int v=tmp[u]._Find_first();v<=n;v=tmp[u]._Find_next(v)){
                    vis[v] = 0; pre[v+n] = u;
                    if(!match[v]){
                        to = v+n;
                        goto END;
                    }else qu[rr++] = v+n;
                }
            }else qu[rr++] = match[u-n],assert(match[u-n]),pre[match[u-n]] = u;
        }
        END:;
        if(to != -1){
            for(;to;to=pre[to])if(to > n)match[to-n] = pre[to];
            cnt++;
        }
    }
    for(int i=1;i<=n;i++)if(match[i])fa[find(i)] = find(match[i]);
    for(int i=1;i<=n;i++)if(find(i)==i)ans[i] = ++col;
    for(int i=1;i<=n;i++)ans[i] = ans[find(i)];
    //
    for(int i=1;i<=n;i++)cout<<ans[i]<<" ";

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

1 1 1 2 2 

result:

ok AC

Test #2:

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

input:

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

output:

1 1 2 1 2 

result:

ok AC

Test #3:

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

input:

8 6
6 1
3 4
3 6
2 3
4 1
6 4

output:

1 1 1 1 2 1 3 4 

result:

ok AC

Test #4:

score: 0
Accepted
time: 266ms
memory: 22260kb

input:

7000 6999
4365 4296
2980 3141
6820 4995
4781 24
2416 5844
2940 2675
3293 2163
3853 5356
262 6706
1985 1497
5241 3803
353 1624
5838 4708
5452 3019
2029 6161
3849 4219
1095 1453
4268 4567
1184 1857
2911 3977
1662 2751
6353 6496
2002 6628
1407 4623
425 1331
4445 4277
1259 3165
4994 1044
2756 5788
5496 ...

output:

1 1 1 1749 3 2 3 1749 1 2 1750 1750 4 5 1750 5 1749 6 1 5 1750 1748 8 8 7 7 8 11 8 9 1750 7 10 11 495 8 9 12 12 13 10 7 14 495 15 8 16 13 17 18 1669 19 12 19 14 15 13 20 7 21 16 19 122 19 17 22 122 19 18 23 24 14 25 13 26 20 122 21 1664 122 19 23 22 18 24 25 26 122 19 23 24 45 122 23 45 45 22 18 27 ...

result:

ok AC

Test #5:

score: 0
Accepted
time: 220ms
memory: 22188kb

input:

7000 6999
4832 1603
5984 6985
5355 3687
6007 2170
5984 3486
3267 2189
538 2123
4343 4553
5855 6168
5984 257
4239 2304
5984 2063
3298 1869
5984 6353
5984 2018
5984 5387
5984 3382
3164 3978
2690 2816
4810 2638
5984 3773
5984 1634
5984 2786
5984 3671
5984 5140
2943 5721
5984 414
1105 4060
3093 796
5984...

output:

2331 2331 2331 2332 7 2332 39 70 7 40 42 39 70 2 2 1 7 39 70 1 2 24 8 13 7 70 3 4 16 5 6 24 8 13 3 4 9 16 10 11 5 12 17 6 21 7 14 8 9 41 40 15 28 19 27 16 10 11 12 13 17 21 14 39 20 22 41 18 40 25 15 28 19 27 16 17 20 22 29 24 30 23 18 34 70 25 35 41 19 42 26 47 27 20 21 40 37 28 29 30 22 23 31 24 3...

result:

ok AC

Test #6:

score: 0
Accepted
time: 209ms
memory: 22292kb

input:

7000 6999
1649 5337
1701 3344
4394 2172
3330 39
5932 1141
5381 5340
5453 3300
125 2172
6810 5263
804 2172
6635 2172
676 4740
3015 1183
1710 5769
611 5915
3419 1581
2094 2172
4508 2172
6604 2433
6113 1466
1604 696
1518 1123
1287 2940
4825 2172
5130 4524
2693 2172
106 2172
5157 2172
3693 2172
5198 217...

output:

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

result:

ok AC

Test #7:

score: 0
Accepted
time: 280ms
memory: 22272kb

input:

7000 6999
2896 6321
881 2623
5058 2623
4833 2623
4669 2623
4781 5007
1447 2623
4781 4768
4781 3834
2758 4792
797 5055
3784 2623
4781 5510
6606 3040
597 3459
4136 2037
1291 3989
4781 837
4781 4379
5637 2053
1642 2665
4781 4664
4781 952
4924 2511
4781 4201
4781 2352
4781 5362
3901 197
137 2623
2706 19...

output:

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

result:

ok AC

Test #8:

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

input:

6999 6998
1269 3969
1269 2429
1269 2609
1269 2515
1269 6166
1269 6614
3108 1269
2105 1269
4670 1269
578 1269
4661 1269
1421 1269
2576 1269
6152 1269
1269 6636
3011 1269
305 1269
5189 1269
1683 1269
6861 1269
1269 5798
1499 1269
282 1269
914 1269
80 1269
677 1269
701 1269
1269 359
6521 1269
1269 1754...

output:

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

result:

ok AC

Test #9:

score: 0
Accepted
time: 28ms
memory: 17900kb

input:

7000 0

output:

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

result:

ok AC

Test #10:

score: 0
Accepted
time: 696ms
memory: 22244kb

input:

7000 6999
3138 1903
3285 5919
6182 1430
1164 961
1577 6445
1390 3384
935 5723
6614 6387
4799 2877
3915 5128
5366 5455
2287 3941
2053 2326
4022 6993
488 2922
4327 4701
4674 3221
1666 4773
4356 3232
3888 937
4318 6942
577 1299
4491 1938
5154 1254
790 5532
4286 5478
2918 6725
2853 304
2554 5207
5140 77...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok AC

Test #11:

score: 0
Accepted
time: 655ms
memory: 22248kb

input:

7000 6999
33 3147
5877 4807
3116 4168
1651 2456
624 1740
6440 3058
6414 489
1023 2523
706 93
5523 598
4211 6063
3570 6840
6566 2971
6614 1907
5893 4389
4022 2527
5096 2345
4682 2134
188 5597
695 4285
1344 3832
3534 879
6574 6252
3759 3444
2167 85
5630 6600
3158 4404
6389 689
4871 6719
4295 6008
3437...

output:

68 28 49 49 40 40 49 67 49 15 49 15 49 1 15 5 49 68 1 15 27 57 28 49 1 15 57 49 1 15 57 49 2 1 15 19 48 7 57 49 2 44 11 1 3 15 11 58 57 5 49 2 1 15 54 60 58 57 59 48 11 48 7 49 2 1 15 20 50 54 60 28 58 57 53 59 53 20 28 49 68 24 2 1 60 55 15 54 22 58 28 57 59 49 52 40 4 2 60 1 42 15 54 28 38 58 41 5...

result:

ok AC

Test #12:

score: 0
Accepted
time: 797ms
memory: 22292kb

input:

7000 6999
1247 5150
3318 2013
5686 1615
6145 6521
5717 94
2787 3443
2648 4875
5332 5934
1897 1651
4640 2183
1750 6964
148 5228
745 2814
474 1165
496 6735
180 3412
2723 3374
6200 4361
497 5328
1928 5998
5648 1261
5090 4723
1715 706
2499 897
6569 6204
6039 2787
2882 5044
5767 4256
975 1877
1857 4453
6...

output:

242 1 242 69 242 244 4 242 268 244 130 22 268 242 244 22 242 244 245 242 244 245 242 244 245 242 161 244 130 2 245 242 200 244 2 245 195 242 268 200 244 2 215 245 246 14 242 200 244 221 232 3 2 245 246 247 242 93 104 200 149 151 244 3 2 22 245 246 20 132 247 268 20 242 200 248 244 3 4 68 2 245 246 2...

result:

ok AC

Test #13:

score: 0
Accepted
time: 1362ms
memory: 22304kb

input:

7000 6999
2349 199
5295 2831
6143 2006
3212 3198
6956 3807
732 4838
5069 1027
5744 3479
6 5301
5687 4452
4201 1151
1353 4884
548 3506
6094 4799
4950 6939
5234 817
652 1314
979 6984
5771 1851
398 1322
2294 4298
847 3929
6833 183
2904 6745
4797 3874
94 315
4282 582
6591 5037
962 147
799 908
2593 5547
...

output:

1 1 350 1 824 438 405 864 666 183 438 1 706 506 847 824 727 847 2 302 840 810 820 3 525 1 825 4 276 824 447 249 741 303 647 558 810 424 701 437 5 820 438 703 1 5 598 825 824 6 585 428 7 8 145 9 208 665 10 387 647 810 800 758 849 597 66 374 397 506 820 737 1 825 558 824 66 9 506 387 647 810 203 861 1...

result:

ok AC

Test #14:

score: 0
Accepted
time: 1270ms
memory: 22236kb

input:

7000 6999
3409 1629
2076 6412
4997 1078
6320 626
4501 1104
4173 1774
5507 2375
2299 5115
4321 127
1192 6635
1909 3398
2972 499
862 5024
421 2931
861 1536
902 3813
659 4514
1843 3035
3669 1228
1724 1880
34 706
133 3468
6116 585
5073 1461
5667 3405
715 4834
6915 3007
1736 6108
3264 2870
2393 6474
2108...

output:

475 1280 1 357 1280 2 2130 1854 760 3 5 4 1280 5 6 400 1442 1283 2214 1157 1854 7 1287 709 8 1280 9 10 11 12 1140 13 62 14 97 216 1357 1471 15 1410 2049 1323 296 170 1283 14 292 509 16 92 620 449 1297 163 1854 2453 885 292 17 18 1290 1287 2145 19 1421 20 2453 21 620 22 732 2421 23 1469 752 24 1280 1...

result:

ok AC

Test #15:

score: 0
Accepted
time: 37ms
memory: 22220kb

input:

7000 7000
2048 5882
6801 2408
3225 2608
1441 5079
497 6253
557 5589
2535 6257
4800 2595
4713 1286
4759 6636
4303 4296
6195 2048
6994 2987
1249 3044
1036 10
6472 2076
1996 1086
1279 1486
6100 369
4797 3437
2493 4576
2944 5601
197 5582
5488 5035
4023 659
2651 5024
2257 5710
1001 3941
446 4815
687 702
...

output:

1 2313 2 3 4 5 1621 6 7 375 8 310 9 1614 2722 2083 10 11 600 168 778 12 547 2850 13 1815 314 2670 14 1051 31 15 383 1309 1317 16 2094 17 2684 18 19 238 20 868 805 21 22 478 1124 2104 23 1342 24 2073 979 1197 25 2485 444 788 26 2565 1138 27 625 28 980 1907 319 1155 29 478 1504 2453 30 1502 31 2324 32...

result:

ok AC

Test #16:

score: 0
Accepted
time: 47ms
memory: 22280kb

input:

6993 7000
6927 2941
6385 1428
6914 2553
2474 4268
2068 1640
2298 6960
6201 1806
4912 59
4407 5504
1595 6868
6378 2515
3713 3724
2995 2589
2314 2932
4042 431
6322 4178
5947 6850
6192 735
3802 1043
4982 1575
311 6496
5006 3191
6473 3084
2387 4706
6632 5901
5113 3066
5248 1274
5671 717
1311 4261
1960 3...

output:

1520 927 1 2413 1602 2 2346 3 1799 4 1118 437 2488 505 5 6 901 7 1337 1071 8 9 647 465 1542 1893 649 1051 2769 656 10 11 12 263 13 110 1358 1121 14 1051 15 16 1777 551 22 399 992 17 18 2595 19 1369 20 240 21 22 23 213 2461 180 305 1596 187 3 24 1465 734 25 26 2625 27 588 28 2565 29 362 30 31 32 938 ...

result:

ok AC

Test #17:

score: 0
Accepted
time: 64ms
memory: 22152kb

input:

6930 7000
3746 2945
3523 6758
4109 1106
2732 5415
2423 844
3702 6309
6503 5362
5997 6294
5688 1396
4842 1764
4780 4521
1254 826
37 4653
2138 2358
6345 1223
1385 2341
5261 5867
4815 2918
4209 696
4235 2314
3680 2919
5605 5155
6643 3391
2691 1418
6289 2093
1970 1804
828 5237
4025 1111
1164 5519
5889 2...

output:

1 1519 2 2521 983 113 3 4 2684 2870 1960 317 2404 905 5 1787 6 1961 1204 2277 2267 7 1676 2715 8 9 2782 893 1016 10 1586 11 12 510 1927 1459 13 2578 2268 175 1091 14 762 15 151 2306 16 2242 726 1506 1955 17 1982 18 19 20 21 22 2838 94 1106 23 98 1993 1003 24 2350 1055 413 641 25 2772 26 266 27 104 6...

result:

ok AC

Test #18:

score: 0
Accepted
time: 92ms
memory: 22008kb

input:

6300 7000
5921 5466
723 5843
1084 3134
3865 5742
5492 2885
328 4408
6055 4074
3702 2240
1342 2353
295 734
553 48
4454 2980
1248 4460
5023 19
2784 441
105 844
6048 1773
4840 5260
3910 1292
5578 2864
4978 3116
6182 4962
2575 1661
5030 435
5861 4709
5033 358
1746 5816
5877 3921
2678 5679
1784 33
207 59...

output:

1820 1 2066 1916 1964 2 123 1589 3 130 1233 4 2284 5 6 7 8 9 92 190 597 10 1477 11 2359 12 918 627 2141 1401 415 941 1100 631 2195 13 1936 506 1168 724 1124 1998 2267 249 718 14 1524 1208 202 867 705 1739 15 13 1948 16 17 1028 1361 1230 345 2106 18 19 20 21 22 1937 131 558 855 23 24 906 25 2077 20 2...

result:

ok AC

Test #19:

score: 0
Accepted
time: 139ms
memory: 15152kb

input:

2800 7000
218 2670
1436 2268
38 2781
55 783
549 1627
660 1609
2268 2645
1376 1395
2747 71
785 1451
1096 2633
2655 2557
1569 307
16 56
1993 2751
1154 2760
478 2452
1841 2764
155 1781
215 1432
1788 2548
193 2665
167 1038
2425 2314
439 1615
269 1187
1222 245
1638 2016
2352 1511
2333 1564
1667 2576
1751...

output:

1 1 1 1 12 1 12 2 1 12 2 1 12 2 1 12 2 1 129 12 2 1 129 26 12 2 1 129 26 12 8 3 1 129 26 249 3 1 129 26 3 1 129 26 191 1 129 26 1 4 129 17 1 12 129 1 12 129 1 12 129 5 1 6 12 129 169 171 168 93 12 129 7 93 12 8 129 7 93 12 8 129 7 93 12 8 129 7 93 229 8 9 129 7 10 93 8 3 129 245 26 13 41 8 3 129 26 ...

result:

ok AC

Test #20:

score: 0
Accepted
time: 28ms
memory: 22212kb

input:

7000 7000
4828 3840
4148 2678
1645 2954
5516 1204
4664 285
904 1978
1434 1688
1902 5205
1324 4512
1722 1246
6724 5227
524 196
937 6286
6609 4724
5408 5610
4405 2463
5493 1567
2625 2894
2378 3685
5399 6872
6475 6546
5697 1265
1811 1314
2347 3005
6245 271
2414 434
3492 6948
4447 599
793 6107
464 5353
...

output:

1 2285 2153 3395 360 531 1933 1383 2 3 1194 1243 1568 2463 4 2302 2684 569 5 1064 1353 6 2608 7 1389 1389 1261 1442 8 9 3323 946 10 1940 3267 11 12 2078 13 303 14 1879 15 16 898 17 18 2589 19 1566 1047 20 21 2462 22 23 3384 24 2546 25 26 2205 299 2306 2110 227 27 2135 28 1506 29 30 31 32 2134 33 606...

result:

ok AC

Test #21:

score: 0
Accepted
time: 31ms
memory: 22224kb

input:

6993 7000
1576 5558
2853 3183
212 2572
1001 75
3386 6483
401 22
489 6768
6520 1684
6439 6188
3810 6414
4088 1924
371 1666
2822 410
5664 1676
1043 1365
384 2688
4179 6357
6466 4630
2829 4371
116 6817
1535 6172
751 5740
499 2484
2013 4576
6556 670
6177 3847
5344 4280
6103 1055
496 4934
6639 217
6606 4...

output:

2485 1 2 1236 3 802 483 1526 4 1029 5 6 7 8 3095 3378 3487 2560 3634 1610 9 2684 585 3427 2202 1686 10 1039 359 11 12 1662 1107 13 14 2693 509 3246 699 15 1584 2989 16 592 1608 17 18 19 2912 1989 20 369 3543 21 22 23 386 2796 399 777 24 25 26 2626 1689 126 189 27 2524 3065 977 28 29 1214 448 30 31 3...

result:

ok AC

Test #22:

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

input:

6930 7000
2378 5636
2953 3870
897 2126
112 1756
3302 5114
4591 5593
5408 4899
1204 6313
6254 2214
5360 6680
2354 5865
5959 5969
1628 5317
6396 1006
2402 1767
1921 3373
3758 312
2167 5711
4119 6585
19 3951
1714 1206
3754 4376
4516 307
6312 165
5721 2470
4828 4842
4520 4310
1922 4946
2006 3856
1218 58...

output:

980 1 3082 2 3 1920 4 2936 338 5 40 3525 1005 773 6 7 8 1499 9 10 2995 3172 11 329 12 2902 2342 2877 1534 13 14 15 2898 1401 1138 1457 16 2830 17 18 19 20 3553 21 1438 844 22 23 24 25 3579 3514 520 26 1063 413 27 28 29 30 2459 572 747 31 925 2281 32 2386 33 34 65 35 1092 271 36 2313 37 38 39 1011 36...

result:

ok AC

Test #23:

score: 0
Accepted
time: 27ms
memory: 21652kb

input:

6300 7000
1562 45
1716 2699
5291 4828
5063 4588
5888 4130
5901 6109
1476 921
3390 5892
5425 3782
824 5679
2278 6102
6146 5556
4874 2115
2842 2803
1963 5131
3736 2611
320 5272
758 5667
4087 228
5139 760
1812 2968
2897 6117
277 387
336 1322
4319 4597
608 4481
6182 3050
4333 3570
401 1662
3085 3197
537...

output:

1 2 872 1365 66 1683 2687 3 47 4 1980 5 6 1418 1035 7 1275 2133 2234 8 2160 9 10 11 704 12 1588 13 2923 2673 2203 421 208 2163 1819 1025 14 15 1810 656 16 519 17 18 536 1036 1413 324 19 650 20 861 2611 21 31 3120 22 23 1385 24 25 244 2243 1593 1426 1697 26 27 415 28 316 29 1226 2794 1389 30 31 32 26...

result:

ok AC

Test #24:

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

input:

2800 7000
931 1154
1783 1159
2515 1596
1734 1277
825 430
938 208
288 684
970 2075
618 2411
2690 500
223 2162
2093 2765
172 1029
832 1571
89 2333
2301 981
1354 1094
1989 137
2340 1804
2600 1249
1714 2343
1043 2738
1375 1239
804 2578
424 1572
568 1945
2233 297
1890 519
1475 944
2732 1123
2012 927
2232...

output:

226 33 514 1 305 2 682 3 222 4 68 686 376 183 5 504 262 734 266 284 24 471 718 6 825 9 494 570 288 335 7 8 714 9 681 513 732 336 233 10 58 367 612 540 11 266 12 364 263 289 512 13 367 73 229 14 513 201 197 15 744 16 563 364 227 17 18 104 689 58 685 244 718 19 478 399 41 65 788 272 563 20 580 78 117 ...

result:

ok AC

Test #25:

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

input:

52 41
18 31
2 5
22 32
1 50
50 29
9 32
44 27
45 17
26 24
18 30
28 25
38 28
5 47
49 38
23 50
8 3
16 24
29 46
7 52
30 38
33 32
39 32
3 18
50 44
1 35
49 37
18 24
29 6
20 39
40 45
33 28
51 52
26 40
38 43
52 45
39 40
42 34
6 45
32 19
20 52
34 28

output:

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

result:

ok AC

Test #26:

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

input:

291 56
117 283
21 277
128 22
245 45
8 223
150 129
16 15
224 163
288 76
218 238
25 233
100 262
244 101
76 207
286 80
164 238
165 283
133 251
23 235
22 280
65 205
8 30
66 76
232 90
251 287
80 62
58 218
285 225
247 199
149 34
219 16
286 221
174 248
20 58
169 69
229 119
178 216
152 147
148 189
116 207
7...

output:

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

result:

ok AC

Test #27:

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

input:

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

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 

result:

ok AC

Test #28:

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

input:

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

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 

result:

ok AC

Test #29:

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

input:

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

output:

1 1 1 1 1 1 1 1 2 1 2 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 

result:

ok AC

Test #30:

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

input:

6 8
5 1
1 5
6 5
4 1
4 3
2 4
5 3
3 4

output:

1 1 1 1 1 2 

result:

ok AC

Test #31:

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

input:

7000 6999
6253 1991
6253 4600
1137 6253
1764 6253
6253 908
6253 2205
6253 213
6253 4399
6300 6253
4601 6253
6253 4884
6937 6253
6253 4070
2646 6253
1007 6253
6552 6253
6253 2115
6253 922
6223 6253
6253 2496
3522 6253
2050 6253
6253 763
6803 6253
6253 3847
2816 6253
6253 6297
6253 471
6253 3211
3203 ...

output:

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

result:

ok AC