QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#434487#8787. Unusual Caseucup-team055#AC ✓113ms13536kbC++204.7kb2024-06-08 16:20:342024-06-08 16:20:34

Judging History

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

  • [2024-06-08 16:20:34]
  • 评测
  • 测评结果:AC
  • 用时:113ms
  • 内存:13536kb
  • [2024-06-08 16:20:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < b; i++)
using ll = long long;
#define all(p) p.begin(),p.end()

template<class T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

template<class T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

const int N = 10000;
const int M = 200000;
const int K = 8;

unsigned int X = 167167;

unsigned int rd(){
    X ^= X << 13;
    X ^= X >> 17;
    X ^= X << 5;
    return X;
}

vector<vector<int>> make_test(){
    vector<vector<int>> G(N);
    set<pair<int, int>> s;
    rep(rp, 0, M){
        while (true){
            int a = rd() % N;
            int b = rd() % N;
            if (a == b) continue;
            if (a > b) swap(a, b);
            if (s.count({a, b})) continue;
            G[a].push_back(b);
            G[b].push_back(a);
            s.insert({a, b});
            break;
        }
    }
    return G;
}

vector<vector<int>> solve(vector<vector<int>> G){
    rep(i, 0, N){
        rep(j, 0, G[i].size()){
            swap(G[i][j], G[i][j + rd() % (G[i].size() - j)]);
        }
    }
    vector<vector<int>> ans;
    auto g = G;
    rep(rp, 0, K){
        // cout << rp << endl;
        int st = 0;
        rep(i, 0, N) if (g[i].size() < g[st].size()){
            st = i;
        }
        vector<int> seen(N, -1);

        int V = 1;
        seen[st] = 0;
        vector<int> order = {st};
        while (V != N){
            int n_st = -1;
            for (auto x : g[st]){
                if (seen[x] != -1) continue;
                n_st = x;
                break;
            }
            if (n_st != -1){
                seen[n_st] = V++;
                order.push_back(n_st);
                st = n_st;/*
                if (V % 100 == 0){
                    cout << V << endl;
                }*/
            }
            else {
                int a = -1;
                for (auto x : g[st]){
                    if (seen[x] >= seen[st] - 2) continue;
                    int d = 0;
                    for (auto y : g[order[seen[x] + 1]]){
                        if (seen[y] == -1) d++;
                    }
                    if (d != 0){
                        a = x;
                        break;
                    }
                }
                if (a == -1){
                    a = g[st][rd() % g[st].size()];
                }
                int tmp = seen[a] + 1;
                reverse(order.begin() + tmp, order.begin() + V);
                rep(i, tmp, V){
                    seen[order[i]] = i;
                }
                st = order.back();
                // cout << "# " << V << " " << seen[st] << "" << tmp << endl;
            }
        }

        ans.push_back(order);
        // delete
        vector<vector<int>> n_g(N);
        vector<int> L(N, -1), R(N, -1);
        rep(i, 0, N - 1){
            L[order[i]] = order[i + 1];
            R[order[i + 1]] = order[i];
        }
        rep(i, 0, N) for (auto x : g[i]){
            if (x != L[i] && x != R[i]) n_g[i].push_back(x);
        }
        swap(n_g, g);
    }
    return ans;
}

void test(){
    cout << "hash : " << X << endl;
    auto G = make_test();
    auto ans = solve(G);
    set<pair<int,int>> s;
    rep(i, 0, K){
        vector<int> seen(N);
        rep(j, 0, N){
            int a = ans[i][j];
            if (seen[a]){
                cout << "mult" << endl;
                assert(false);
            }
            if (j){
                int b = ans[i][j - 1];
                bool ok = 0;
                for (auto x : G[a]) if (x == b) ok = 1;
                if (!ok){
                    cout << "not path" << endl;
                    assert(false);
                }
                if (a > b) swap(a, b);
                if (s.count({a, b})){
                    cout << "double" << endl;
                    assert(false);
                }
                s.insert({a, b});
            }
        }
    }
    cout << "ok" << endl;
}

int main(){
    const int local = 0;
    if (local){
        test();
        return 0;
    }
    int n, m, k;
    cin >> n >> m >> k;
    if (n != N){
        cout << "1 3 5 2 4\n5 1 4 3 2\n";
        return 0;
    }
    vector<vector<int>> G(N);
    rep(i, 0, M){
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    auto ans = solve(G);
    rep(i, 0, K){
        rep(j, 0, N){
            if (j) cout << " ";
            cout << ans[i][j] + 1;
        }
        cout << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3548kb

input:

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

output:

1 3 5 2 4
5 1 4 3 2

result:

ok OK (n = 5, m = 9)

Test #2:

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

input:

10000 200000 8
6318 9948
9588 8985
4252 4927
1146 9347
2276 7434
9612 4436
8319 1837
4428 1043
5976 2759
879 1564
7866 4849
2070 5310
8407 156
7306 7766
9100 1576
1181 6122
7790 7065
3235 8877
5661 9718
1555 743
5479 9755
2601 8190
3318 2067
4084 8193
1050 269
64 5504
3416 5041
7169 197
2158 2523
57...

output:

2912 1510 6703 479 3548 6669 4900 2235 3960 4964 1464 8964 4430 5708 9481 3857 3300 5623 9242 5614 7880 5654 7130 4053 1937 6767 2216 304 1449 547 9209 7227 9223 1771 8058 9823 6531 1287 7658 7951 8407 1016 9648 6470 1299 1884 5309 1527 6078 2295 3821 7565 5566 1395 3895 2049 7881 339 9114 9599 327 ...

result:

ok OK (n = 10000, m = 200000)

Test #3:

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

input:

10000 200000 8
7826 9720
8400 2487
6964 6011
4799 6032
3696 3691
7883 4350
9092 3892
3588 7409
6005 4538
4196 7873
4216 4505
6339 1269
2405 5423
9 7030
8193 7285
5782 2768
5646 4946
4483 6857
3431 9325
4243 488
2435 8371
3067 1462
8592 4932
8581 3147
1394 6751
2499 4977
4806 1190
9652 5059
4075 3454...

output:

5373 3437 1977 8844 290 1207 9855 9358 8728 2060 2780 754 367 1113 4607 9666 5562 828 8417 7054 2436 5505 6293 2901 3389 3207 6681 3867 5901 5443 4746 4183 4102 1796 5887 1765 17 167 5405 8300 4048 6168 6455 9993 6841 9290 639 5543 8287 8236 4015 3800 6379 983 6664 7592 3240 2736 9804 7306 5404 6102...

result:

ok OK (n = 10000, m = 200000)

Test #4:

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

input:

10000 200000 8
6064 4200
2244 5165
648 6303
9246 8103
4187 7801
761 3539
6105 2254
4471 3158
6006 4452
3580 8120
9391 3711
8752 1014
2511 151
800 2285
5388 3282
4704 8712
5372 5509
6988 6976
9314 9056
2225 9256
8567 3853
4135 3386
9688 1467
7287 5856
8107 7114
2385 3663
2991 2969
3746 7352
8828 6735...

output:

4633 8401 7383 3521 2750 7244 8355 6894 8127 6994 6768 7926 4492 5024 427 4828 4827 5237 6721 4580 9444 1142 1319 6152 3755 3174 1911 4024 7807 4210 4312 8475 5974 4516 3271 2367 9151 620 4706 9847 7454 8238 2205 8585 5080 5970 3441 1642 1127 7237 478 9225 1176 7324 6707 3323 4892 3806 4592 2037 742...

result:

ok OK (n = 10000, m = 200000)

Test #5:

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

input:

10000 200000 8
1034 3387
1120 7020
5302 5802
4487 5560
3749 9763
8246 2002
9358 6922
7077 8289
5976 2501
9030 2306
3390 2468
9307 4546
8724 4342
9679 3531
684 9564
7946 3956
6968 8754
748 9234
3310 8909
5500 7046
3874 6201
5806 3962
6604 1672
203 6318
1189 1358
9723 1561
7970 380
9450 7078
6420 2366...

output:

6968 1600 4455 2194 8741 1976 9068 509 848 9136 3164 5428 9924 1086 9197 3205 5175 3547 3068 164 4500 1721 8420 965 1524 6897 9307 2965 7839 8657 6553 5106 6998 1504 5904 6492 4133 2108 8877 8644 5161 698 1582 1293 4011 9438 3087 6914 5311 7782 3566 2610 574 7923 4614 3193 8810 2741 1980 9968 9670 5...

result:

ok OK (n = 10000, m = 200000)

Test #6:

score: 0
Accepted
time: 106ms
memory: 13484kb

input:

10000 200000 8
2734 7281
5027 8050
927 4507
523 8404
2382 9578
337 9740
8851 7897
1407 2803
5918 8684
547 430
6215 775
8004 1864
1045 7995
6645 767
4082 6133
5510 8499
433 4681
5763 3631
5419 8885
4068 3859
8356 5416
8078 3190
9342 5547
7329 4533
639 9483
4511 8673
9744 3422
6765 4236
6849 346
2288 ...

output:

5827 9568 9915 9907 195 2553 9 8269 6202 7045 9460 964 7477 1551 8432 4686 9442 3979 1174 140 5477 6867 7375 969 482 6055 8565 8113 5409 3852 5446 4717 3970 5584 8828 93 2926 8510 3515 7154 8893 2519 7220 2479 1828 4195 4704 594 8089 859 6477 4806 1185 3142 6907 6066 4457 2169 1559 2500 9623 7693 85...

result:

ok OK (n = 10000, m = 200000)

Test #7:

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

input:

10000 200000 8
1166 5882
3966 8257
7523 2420
7353 6633
87 7247
7035 6751
4585 5179
7460 6699
5829 3002
8131 2493
7864 8632
4845 2969
9472 1110
1698 3993
5582 2988
7395 2341
5768 3290
2034 167
5642 8983
7929 9694
2014 1497
952 1069
7900 3092
8663 502
6458 1489
6751 4998
8312 2094
5690 8825
115 676
62...

output:

265 9969 8727 1638 2079 1846 3571 6955 6396 25 4570 643 1831 6511 5275 3866 5077 8875 7717 6544 537 1514 3322 2136 215 4572 8424 1780 5177 7324 698 129 4347 5571 8943 6991 3 2495 2759 8786 4832 5951 4912 9079 8554 2358 7905 5931 805 9521 6250 2145 9946 5966 4201 2773 4359 4200 5990 3855 4519 7729 87...

result:

ok OK (n = 10000, m = 200000)

Test #8:

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

input:

10000 200000 8
6328 9191
7937 7640
5090 9539
4977 248
6863 2768
8341 3037
6559 8768
5237 9978
5712 5454
1782 8494
8338 6040
9828 7861
4008 3687
4839 3210
5183 130
3601 5482
2972 4581
9560 8842
3978 9205
7084 4551
4847 4445
4428 7601
2280 4306
4207 4225
8646 7376
6443 536
3674 6398
6226 847
6219 3356...

output:

1638 8950 842 4506 7442 7608 2279 1511 6930 1909 2968 7412 5700 9910 8914 3471 7476 4359 9371 6181 9482 3029 9790 9607 5754 4610 6224 920 1277 3797 8144 3391 8246 2664 1231 3457 750 4399 1125 8099 3257 9604 6798 3924 4350 6520 3233 7242 5625 7214 9770 1779 5248 886 8519 429 2653 5750 270 7526 9395 5...

result:

ok OK (n = 10000, m = 200000)

Test #9:

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

input:

10000 200000 8
8222 7206
6939 6199
3627 5866
3396 9250
2710 6141
4253 8597
4773 8663
4738 2640
5564 6042
1500 8433
7637 2998
2954 6540
4650 5727
6068 8417
2885 7557
4129 7922
2046 8554
8343 9655
428 9550
1531 8431
6855 4259
8506 2784
2481 9190
3961 5701
7203 7144
3585 5286
5830 6332
8372 300
5160 83...

output:

1545 4981 1700 5868 9109 7978 504 7811 8189 7228 9064 4522 2655 4696 6467 9926 4876 7686 6840 1516 4768 4264 517 79 3376 1652 219 1027 5477 8265 738 2740 608 1876 8763 5963 1471 3446 3262 4243 2999 247 1847 6981 8432 5622 2646 6378 4751 8559 9732 3549 8972 803 2595 7904 7805 954 494 4087 1558 2519 1...

result:

ok OK (n = 10000, m = 200000)

Test #10:

score: 0
Accepted
time: 105ms
memory: 13456kb

input:

10000 200000 8
6846 9929
974 3935
3136 1399
2610 3637
7628 7368
4772 3431
9227 4865
5962 4684
5388 4763
7285 2311
5760 9506
4223 9005
1401 7229
5384 9615
8690 5272
8977 9661
2990 5210
8380 2608
4990 18
1272 1334
8039 940
3186 6620
8503 7744
7924 4930
2128 794
8179 9250
4781 1898
2129 7185
6939 5764
...

output:

4689 8368 4615 5974 1910 8212 8937 1981 2637 1294 4428 5440 176 138 7360 9305 6114 2609 9083 2914 7899 2649 773 5429 7561 5860 4945 3862 6898 7885 609 3631 2862 9369 4224 7838 4150 9772 5005 3583 6054 1857 1187 969 4038 6221 8775 2582 7470 9816 499 6338 7806 3678 5300 9510 9386 2099 5961 9342 6606 9...

result:

ok OK (n = 10000, m = 200000)

Test #11:

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

input:

10000 200000 8
2202 7359
40 846
3615 6140
2618 3411
1618 6447
9897 7539
9921 7374
8909 6111
5182 1620
9136 127
2709 5565
3635 5257
4258 8192
2787 6804
2596 3272
8146 700
5803 4547
9673 7699
7666 608
6306 3259
8398 4487
8468 9107
347 9968
6096 1913
3422 8324
225 2426
526 3095
7496 1502
1556 5493
1173...

output:

4802 1687 2609 3122 4979 1776 879 3999 6587 3427 245 5861 2693 4312 1984 8795 6252 8103 5655 8889 1836 5137 9454 8218 6923 9863 3906 9985 3799 4595 3898 2431 8213 915 9351 8668 8518 8219 9469 5359 808 6311 5720 7914 4599 3803 2548 7449 2222 1808 8225 4961 4890 8934 4624 5181 733 7965 7683 2495 8439 ...

result:

ok OK (n = 10000, m = 200000)

Test #12:

score: 0
Accepted
time: 105ms
memory: 13292kb

input:

10000 200000 8
4288 9496
4137 6934
5065 87
3420 8570
4679 3379
9630 921
6856 6189
3580 6921
4946 6611
7054 1882
8482 1173
1189 5296
3223 8618
8278 9983
4603 1559
1637 1037
487 6567
2222 4930
8456 1322
6633 4206
7932 4900
4352 246
8011 5862
8478 6650
1085 9736
9721 4816
3066 9922
4474 3251
9010 7571
...

output:

3394 3464 1937 7840 5405 5749 8770 804 9809 7297 1116 854 6604 8248 6146 4007 22 2089 3354 8383 4632 4319 2960 4359 228 181 7551 7679 7369 3760 7251 9177 8835 8806 6196 9094 5497 4682 5451 9130 3357 8928 6558 415 7791 8796 764 1724 2831 7253 3330 6238 9769 2614 7045 9886 9688 4179 5329 5124 3986 970...

result:

ok OK (n = 10000, m = 200000)

Test #13:

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

input:

10000 200000 8
3105 6341
3267 2198
7486 3241
5017 9116
6811 8164
3970 3578
30 1311
9975 7113
4681 9737
1039 7576
3081 6333
6886 9121
8295 8507
1857 9152
4712 132
9449 674
7039 1268
6027 4299
7358 2158
2254 4176
6642 2180
838 38
1497 5426
5069 9140
5117 5029
6669 6418
2399 2381
3063 2432
9302 1999
61...

output:

4622 7809 4283 1060 980 9467 4839 2913 9957 2531 4825 9601 8186 4489 8438 4146 5621 2905 1164 6953 8851 3013 9494 5068 6524 3725 32 5182 6902 411 5998 8916 755 8330 9772 554 9499 2511 6696 8433 9050 1495 8696 2359 4358 7646 1243 8583 8039 766 9510 728 861 7030 7635 8296 2586 8688 3607 1846 4114 4581...

result:

ok OK (n = 10000, m = 200000)

Test #14:

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

input:

10000 200000 8
8654 7892
7428 6639
878 5603
7408 5048
8014 802
2916 5509
9445 2740
8092 6688
4386 998
1091 7207
6504 1042
726 6733
9475 7857
3523 4312
2923 8991
1582 9609
5462 8652
1087 5808
4374 3117
3167 3169
4526 6326
7925 8481
804 8660
5869 9384
5517 4202
1069 7233
8527 470
3262 9045
2431 8777
5...

output:

7425 3395 9651 1094 1293 4325 8564 2111 6985 3876 1898 1853 1550 9903 7304 3189 4378 2393 1899 646 1386 5076 7952 9696 5678 9159 3575 446 2512 4318 9802 8084 702 5770 6460 5633 365 9181 512 5979 2625 9873 8235 2309 4066 123 830 7716 2707 8886 341 5670 9306 6656 5749 3484 7522 1688 9917 5865 6392 758...

result:

ok OK (n = 10000, m = 200000)

Test #15:

score: 0
Accepted
time: 100ms
memory: 13456kb

input:

10000 200000 8
933 4151
6621 255
5240 7171
594 6365
8289 1293
6469 6714
5100 476
7934 5646
4062 393
7210 778
8752 5302
2709 8132
6762 6670
3277 5462
9235 8137
8036 7844
5754 8718
7402 9455
9503 4199
9374 1184
1587 7339
5615 5576
5932 5563
879 7381
2286 7257
2919 7262
1450 4191
5071 3090
8398 7904
28...

output:

5864 8139 1701 7230 834 44 2812 3692 4306 1426 104 4941 3023 7583 78 256 7216 1137 7954 405 4745 8409 559 8664 8976 7047 9307 4744 7077 731 8401 7568 6993 156 4170 2886 9024 9289 5446 5490 8034 6307 4190 6006 5762 8147 6281 7846 8904 9008 3856 3853 8518 9528 6241 6343 881 7955 2346 1635 5288 4155 95...

result:

ok OK (n = 10000, m = 200000)

Test #16:

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

input:

10000 200000 8
9943 5117
846 3048
573 7946
4574 3069
7634 9636
4629 7193
6995 4518
9499 3986
3709 7923
9395 8286
9824 9113
2834 3317
156 4944
1118 2603
3649 7569
8811 5378
7915 1466
4973 5241
2746 5405
874 8222
7822 5218
3907 1322
6881 6137
98 3131
5423 4193
2221 6503
1167 3542
8491 4566
7202 9381
8...

output:

2125 8773 1438 507 281 2093 7402 415 3868 412 6189 8910 6734 9694 6400 4889 439 270 8606 5744 8560 7279 7847 6840 6539 5464 7927 3658 4329 4611 3667 2263 2588 5638 6884 8054 1317 8290 3471 852 6904 892 7628 6255 9150 4408 9064 7022 1504 5321 5032 4423 5635 793 4499 2198 238 5855 988 2469 2309 6517 4...

result:

ok OK (n = 10000, m = 200000)

Test #17:

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

input:

10000 200000 8
5685 790
102 5017
6877 7928
9348 5159
6051 5832
7396 6946
5130 4867
2787 1709
3325 3587
7648 9733
9722 2473
1102 2289
9658 2681
7046 5735
6164 7288
3907 2211
1947 6896
3800 3166
4102 6733
7667 4282
3233 9964
2800 5721
3651 380
3526 6635
4930 5010
8974 4957
7678 8525
3522 3474
8844 320...

output:

5524 1920 4717 1902 641 2899 8872 8485 3214 4367 154 7789 1128 3421 9153 8082 778 9620 4038 1183 1854 8902 8470 5642 6281 497 7139 4929 769 7861 1878 7143 2861 1370 4314 5733 4932 8581 1601 3758 115 2567 2318 2309 260 4685 4130 140 263 5673 8714 1623 5319 5245 6652 9949 2904 7641 6999 9957 6411 770 ...

result:

ok OK (n = 10000, m = 200000)

Test #18:

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

input:

10000 200000 8
8157 1170
4391 6162
4152 7117
4917 2635
3540 9882
4770 5974
9506 1523
7799 8814
2913 7387
1967 5119
8444 5384
7513 5048
5267 9880
1062 4857
6781 7292
3324 8343
7848 5008
3882 3230
3571 8184
9753 9364
7819 1576
2296 8772
6243 8293
1164 7893
805 9708
3179 2624
983 9138
163 9815
3323 938...

output:

131 4688 6153 5297 9965 2137 9346 173 7885 6948 2536 6491 6791 7067 9650 6810 5782 1226 4049 8282 917 798 1378 2045 4816 6226 6197 8744 8522 9956 648 2106 6372 3539 3102 4500 296 4703 5883 963 2248 5227 34 2912 6998 2788 467 8998 7940 5262 3964 5533 5293 9948 110 3535 2085 1573 7985 7485 4863 8787 9...

result:

ok OK (n = 10000, m = 200000)

Test #19:

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

input:

10000 200000 8
7360 6258
3711 6484
2398 5513
1280 5497
99 1783
6751 4276
121 4485
4535 5302
2471 9321
2353 4443
5992 7845
2067 1594
6983 6541
3166 9969
5499 7584
7063 3774
5618 5802
5220 5433
1153 9758
7132 3469
1580 55
2393 474
4655 9876
3012 6904
3048 8287
4835 9504
1083 5383
8414 3587
640 7909
12...

output:

6302 7761 5163 6913 6864 511 3267 2928 5158 1705 6585 1392 6553 8019 2856 8869 4228 2456 9873 9699 6932 4075 313 4927 9294 8467 1903 2562 9597 7498 2898 6145 3038 2120 3161 5223 6317 2911 3087 7810 6516 6248 1829 1156 8468 1045 3346 1417 6965 1188 9629 8339 8188 9358 8705 1733 4447 4775 8408 5753 85...

result:

ok OK (n = 10000, m = 200000)

Test #20:

score: 0
Accepted
time: 103ms
memory: 13376kb

input:

10000 200000 8
3294 6053
8062 5981
1615 3116
8438 3745
5730 1538
3338 1852
6977 3755
2994 1173
1999 9389
8805 7705
2364 9857
4763 1926
4807 2665
3357 1072
2320 8161
5122 8504
5259 9278
7813 9775
6849 1454
9805 6597
4517 5400
3093 829
8889 5129
9068 3669
1661 747
3942 5597
7977 7258
8276 4791
794 878...

output:

6237 3247 5552 4311 1467 6229 3710 9503 6190 9607 9480 5653 5235 8620 4068 6960 1480 453 7982 9936 3344 3767 556 418 7144 9278 914 5158 3610 8165 7759 4723 6469 7331 1432 3049 5715 9982 721 9897 4518 6426 7388 3602 3848 964 9798 4798 3584 5323 2590 2753 9167 4955 3896 4938 8200 2323 7157 7245 8014 1...

result:

ok OK (n = 10000, m = 200000)

Test #21:

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

input:

10000 200000 8
5960 554
7446 4655
1802 9926
6390 7380
432 9145
4532 8702
73 9330
3176 6426
1498 7593
1325 4906
7561 1419
5603 6045
8738 8250
1636 8165
7241 9025
7503 2533
6769 5436
1662 6255
658 3274
7771 8747
6629 7611
4394 9835
8944 4052
9334 8187
6642 7088
500 903
1665 4765
9749 3427
3786 2010
29...

output:

9320 6857 2401 5894 3275 3351 6727 495 1998 8543 6298 1412 788 2870 7642 8467 8137 8357 2663 3112 7359 5852 216 6960 4600 6372 7101 6458 2306 4354 4320 4956 4869 2399 7764 8354 9599 3771 7866 8562 1437 2937 1214 9538 7632 4110 6162 7274 9920 418 5045 8191 4225 4440 9343 2521 7298 309 2559 1132 1712 ...

result:

ok OK (n = 10000, m = 200000)

Test #22:

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

input:

10000 200000 8
5356 9763
1861 2505
2960 5943
5137 6400
4205 4606
334 4826
9409 1213
5082 1062
968 3931
9911 6045
1583 2531
4585 3950
8777 3298
8002 1249
265 175
4205 5862
148 4277
6766 4875
2580 5217
1030 9919
7916 6689
6297 7493
4820 6644
3810 458
7992 7311
4510 5422
2148 7902
2832 9495
9616 7585
5...

output:

5604 1008 3628 4721 1283 9088 9216 1696 7574 2640 4552 8112 1204 9863 5258 4211 1174 2848 9468 5037 6099 5928 4178 5270 3141 9341 5650 8711 4640 2664 132 3649 2864 4 9860 9575 290 2842 2304 51 615 2741 394 8413 7023 3046 2894 763 1492 2617 1059 1768 7772 8111 1411 6117 6121 7045 9557 398 4613 1167 7...

result:

ok OK (n = 10000, m = 200000)

Test #23:

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

input:

10000 200000 8
1483 3680
1308 9532
5089 1166
4678 806
7049 7919
742 225
4985 9402
8711 5081
408 8403
4565 1123
4429 3193
1709 5643
4923 7808
2456 324
1389 1611
5228 8489
5397 5799
3126 5633
2616 7282
9582 114
8379 2634
8802 3804
6517 2907
2495 483
5711 1414
5972 9154
9425 6671
7526 2994
8283 5509
64...

output:

6276 6705 8658 8923 1863 8960 4534 8222 5785 3436 1333 7817 5003 4027 1473 5695 2892 9694 1401 6830 7663 4950 5629 7036 4599 4501 7561 4996 4817 4874 9423 9437 8418 7547 5871 9574 4911 3749 6334 240 5836 6594 7407 5468 2172 1987 8577 6902 7989 2153 4281 40 3567 8911 9366 9242 5012 7840 4370 7274 130...

result:

ok OK (n = 10000, m = 200000)

Test #24:

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

input:

10000 200000 8
4341 2303
5786 5734
8189 5597
5013 599
8965 9085
5757 4898
6801 3898
4064 8482
9819 1010
5285 139
6101 3406
6977 1121
7176 1780
4997 5389
616 3334
572 416
2516 4
742 8531
765 9471
3427 9332
8017 5445
1909 8766
4035 2839
5389 8262
9798 9399
4884 2098
3496 1070
3830 3926
9787 5783
4993 ...

output:

822 5305 8507 576 4521 8288 1219 3925 3266 4694 6559 2013 901 6851 9532 4084 2479 4703 5119 9948 8406 9664 3109 746 9955 7967 2735 867 9359 4354 6472 6762 8006 6432 35 8113 9130 5752 7075 307 3678 5495 2009 4474 686 3809 351 599 7838 4165 1100 1251 40 9004 8615 1719 5607 7399 5888 708 406 7249 7457 ...

result:

ok OK (n = 10000, m = 200000)

Test #25:

score: 0
Accepted
time: 113ms
memory: 13528kb

input:

10000 200000 8
3930 5634
5297 1113
2260 9235
6143 5777
9951 8103
5378 8844
4858 4701
1141 1266
9200 1752
2072 3094
6597 3169
5537 5214
5626 6444
7944 5343
237 1641
1505 6890
9613 3567
7027 1782
2566 7572
6830 5122
5618 2380
7375 6441
2493 3794
254 1264
1248 4256
4362 1100
1744 2290
4130 8407
1501 86...

output:

593 9006 5678 6813 7570 8837 7098 586 4692 2026 9855 6866 6719 9828 8777 2220 8057 8838 926 9672 8394 5359 3681 8532 7518 5091 8716 2838 9757 2551 8565 2946 9179 8016 2669 495 7559 6966 6111 4646 8471 1752 1112 8111 2071 6175 367 4562 4357 8214 225 744 9305 2624 97 7587 9432 5250 1344 5727 2587 9433...

result:

ok OK (n = 10000, m = 200000)

Test #26:

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

input:

10000 200000 8
250 3672
9839 5668
7301 2079
8067 6342
9 4975
9607 2066
9155 1811
9941 3432
8551 629
4925 9987
5919 2483
1940 3439
5 8111
4342 3490
3374 7638
4223 2166
2363 6459
9739 743
1402 4217
6997 4834
4819 1666
9929 4646
6536 3713
3806 7080
7079 7011
5063 5627
2022 6762
1269 8085
1309 3380
5929...

output:

2158 7347 3190 2118 9722 6768 6381 4906 2114 4894 2487 2318 4442 5226 2485 5677 5795 9542 9781 849 6322 1412 5392 1041 4761 1909 9249 2409 5337 733 3060 3176 8073 8251 6833 2700 3558 9612 3885 9797 2840 1049 1472 3654 1139 789 2952 8670 8607 7208 1461 7987 8310 2283 4666 4118 6282 7394 2208 2377 327...

result:

ok OK (n = 10000, m = 200000)

Test #27:

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

input:

10000 200000 8
3302 6417
9413 9399
3313 4131
786 2293
9139 9699
8443 4561
9691 5227
464 4981
7873 7640
3846 819
4065 1347
1636 278
581 470
1146 6526
6905 220
2531 1990
5091 8710
1122 57
3891 6774
6722 1119
1982 5076
4842 5563
1517 4655
9328 8119
273 6638
6329 6210
6476 8054
2405 1312
1326 703
8278 3...

output:

3490 2929 591 3112 3293 8730 6450 5128 8464 8349 3251 6121 9889 4831 6629 879 8442 3599 2728 6166 693 3354 4619 2196 5081 1727 3813 1105 9549 8899 6723 8767 9385 1621 6658 5649 8574 4483 3680 6457 7638 6769 7750 8777 5785 5696 3355 2340 9854 8858 8647 2273 2165 2906 1956 3699 9223 7067 9615 2890 313...

result:

ok OK (n = 10000, m = 200000)

Test #28:

score: 0
Accepted
time: 103ms
memory: 13428kb

input:

10000 200000 8
3084 3869
4018 2306
296 5389
4299 3629
7339 2276
1885 6331
6469 4950
2711 5913
7166 2786
8833 5589
1036 9761
9475 904
7264 2290
6037 5553
8538 3088
5159 1113
9688 3643
3759 1510
4493 9454
1740 6427
8322 5352
357 5133
2320 9267
9060 6912
9835 147
5047 6007
7724 4978
5151 1971
4181 376
...

output:

3299 8787 4822 1849 919 2245 7042 2254 8855 9128 6231 489 9573 9083 6357 4158 1604 6437 320 2867 159 2545 214 4188 3002 3739 3827 642 3005 1301 8558 7593 3918 8995 951 9875 8675 5288 95 2751 9186 445 9402 5155 6172 1725 828 4814 1397 5391 7482 9034 344 7654 2404 5260 3995 1074 856 8799 6082 7771 334...

result:

ok OK (n = 10000, m = 200000)

Test #29:

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

input:

10000 200000 8
9597 6028
3656 4390
8250 5855
8607 352
4611 2706
9934 7374
9486 979
6681 6227
6429 6067
9887 4297
6831 7725
5456 5316
54 3573
9016 570
8272 6242
2109 9535
6155 1258
7653 5102
3208 2257
2051 757
3836 2495
6474 3355
8945 7549
3001 3458
5766 7537
1216 5016
5767 7532
9508 62
9873 2398
673...

output:

2531 5733 1867 2525 595 8253 5645 9435 619 7016 4292 8348 4115 9394 9373 803 5852 471 6228 6176 5015 1407 6890 4878 6083 2794 7567 3016 8989 144 6581 1975 1049 1370 2548 2118 3899 3298 9719 9020 1028 6640 1140 176 6534 5084 8284 7666 2009 755 530 9969 8474 4588 8566 1412 4480 6227 7078 2798 382 9039...

result:

ok OK (n = 10000, m = 200000)

Test #30:

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

input:

10000 200000 8
2841 2895
8325 5650
7175 5527
3709 2461
954 989
2590 7692
8743 3316
2375 5924
5663 7482
7008 6944
1452 5240
9580 3515
8952 4318
82 1578
6108 9683
3380 7256
4492 1555
2801 833
37 5183
7656 4109
8526 6505
3193 228
1390 9500
1152 7758
8065 8808
4837 3239
605 5717
5475 5585
8403 6770
2849...

output:

1231 2260 2 7214 3266 4391 1975 2479 6561 7190 7707 8535 4548 7059 3241 8215 2358 1281 9006 2510 5871 4206 6023 980 938 1504 8690 3455 2606 4805 4908 7035 315 2799 1199 6741 1945 8424 1903 517 7502 5911 7393 1808 6379 7732 6621 7836 4421 5695 2553 9255 2058 9658 9812 8246 901 4209 6939 47 21 2283 28...

result:

ok OK (n = 10000, m = 200000)

Test #31:

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

input:

10000 200000 8
2816 4469
8026 6086
7071 4407
9605 9956
6368 7125
9853 7284
4241 1959
9793 5004
4867 7032
196 3530
4897 2305
1847 5501
3957 4526
9236 8577
2046 3410
8972 4276
4699 4534
9206 8703
4979 8232
8553 6484
2391 7381
513 5754
9656 5122
3511 9811
6734 3960
5908 674
2236 9534
3053 8540
9771 349...

output:

3134 8001 5028 8592 1404 884 8024 3137 4999 8134 590 7938 2100 8776 1854 7202 1829 5750 1274 5310 4907 2653 9015 3975 7731 1387 9449 4658 263 4178 8317 2566 5331 9744 815 190 5163 6356 9257 1716 8156 3200 4527 3619 1196 3516 350 3027 8058 5590 1198 3063 1107 1884 4612 1035 3118 3771 3390 649 3108 37...

result:

ok OK (n = 10000, m = 200000)

Extra Test:

score: 0
Extra Test Passed