QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#487289#8787. Unusual Caseucup-team4435#AC ✓627ms28068kbC++207.7kb2024-07-22 19:50:422024-07-22 19:50:42

Judging History

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

  • [2024-07-22 19:50:42]
  • 评测
  • 测评结果:AC
  • 用时:627ms
  • 内存:28068kb
  • [2024-07-22 19:50:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
namespace hamil {
    template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
    template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
#define ll long long
    namespace LCT {
        vector<vi> ch;
        vi fa, rev;
        void init(int n) {
            ch.resize(n + 1);
            fa.resize(n + 1);
            rev.resize(n + 1);
            for (int i = 0; i <= n; i++)
                ch[i].resize(2),
                        ch[i][0] = ch[i][1] = fa[i] = rev[i] = 0;
        }
        bool isr(int a)
        {
            return !(ch[fa[a]][0] == a || ch[fa[a]][1] == a);
        }
        void pushdown(int a)
        {
            if(rev[a])
            {
                rev[ch[a][0]] ^= 1, rev[ch[a][1]] ^= 1;
                swap(ch[a][0], ch[a][1]);
                rev[a] = 0;
            }
        }
        void push(int a)
        {
            if(!isr(a)) push(fa[a]);
            pushdown(a);
        }
        void rotate(int a)
        {
            int f = fa[a], gf = fa[f];
            int tp = ch[f][1] == a;
            int son = ch[a][tp ^ 1];
            if(!isr(f))
                ch[gf][ch[gf][1] == f] = a;
            fa[a] = gf;

            ch[f][tp] = son;
            if(son) fa[son] = f;

            ch[a][tp ^ 1] = f, fa[f] = a;
        }
        void splay(int a)
        {
            push(a);
            while(!isr(a))
            {
                int f = fa[a], gf = fa[f];
                if(isr(f)) rotate(a);
                else
                {
                    int t1 = ch[gf][1] == f, t2 = ch[f][1] == a;
                    if(t1 == t2) rotate(f), rotate(a);
                    else rotate(a), rotate(a);
                }
            }
        }
        void access(int a)
        {
            int pr = a;
            splay(a);
            ch[a][1] = 0;
            while(1)
            {
                if(!fa[a]) break;
                int u = fa[a];
                splay(u);
                ch[u][1] = a;
                a = u;
            }
            splay(pr);
        }
        void makeroot(int a)
        {
            access(a);
            rev[a] ^= 1;
        }
        void link(int a, int b)
        {
            makeroot(a);
            fa[a] = b;
        }
        void cut(int a, int b)
        {
            makeroot(a);
            access(b);
            fa[a] = 0, ch[b][0] = 0;
        }
        int fdr(int a)
        {
            access(a);
            while(1)
            {
                pushdown(a);
                if (ch[a][0]) a = ch[a][0];
                else {
                    splay(a);
                    return a;
                }
            }
        }
    }
    vector<vi> used;
    unordered_set<int> caneg;
    void cut(int a, int b) {
        LCT::cut(a, b);
        for (int s = 0; s < 2; s++) {
            for (int i = 0; i < used[a].size(); i++)
                if (used[a][i] == b) {
                    used[a].erase(used[a].begin() + i);
                    break;
                }
            if (used[a].size() == 1) caneg.insert(a);
            swap(a, b);
        }
    }
    void link(int a, int b) {
        LCT::link(a, b);
        for (int s = 0; s < 2; s++) {
            used[a].pb(b);
            if (used[a].size() == 2) caneg.erase(a);
            swap(a, b);
        }
    }
    vi work(int n, vector<pi> eg, ll mx_ch = -1) {
        // mx_ch : max number of adding/replacing  default is (n + 100) * (n + 50)
        // n : number of vertices. 1-indexed.
        // eg: vector<pair<int, int> > storing all the edges.
        // return a vector<int> consists of all indices of vertices on the path. return empty list if failed to find one.

        LCT::init(n);
        if (mx_ch == -1) mx_ch = 1ll * (n + 100) * (n + 50); //default
        used.resize(n + 1);
        caneg.clear();
        for (int i = 1; i <= n; i++) used[i].clear();

        vector<vi> edges(n + 1);
        for (auto v : eg)
            edges[v.fi].pb(v.se),
                    edges[v.se].pb(v.fi);

        for (int i = 1; i <= n; i++)
            caneg.insert(i);

        mt19937 x(chrono::steady_clock::now().time_since_epoch().count());
        int tot = 0;
        while (mx_ch >= 0) {
            //    cout << tot << ' ' << mx_ch << endl;
            vector<pi> eg;
            for (auto v : caneg)
                for (auto s : edges[v])
                    eg.pb(mp(v, s));

            shuffle(eg.begin(), eg.end(), x);
            if (eg.size() == 0) break;
            for (auto v : eg) {
                mx_ch--;
                int a = v.fi, b = v.se;
                if (used[a].size() < used[b].size()) swap(a, b);
                if (used[b].size() >= 2) continue;
                if (x() & 1) continue;
                if (LCT::fdr(a) == LCT::fdr(b)) continue;
                if (used[a].size() < 2 && used[b].size() < 2)
                    tot++;
                if (used[a].size() == 2) {
                    int p = used[a][x() % 2];
                    cut(a, p);
                }
                link(a, b);
            }
            if (tot == n - 1) {
                vi cur;
                for (int i = 1; i <= n; i++)
                    if (used[i].size() <= 1) {
                        int pl = i, ls = 0;
                        while (pl) {
                            cur.pb(pl);
                            int flag = 0;
                            for (auto v : used[pl])
                                if (v != ls) {
                                    ls = pl;
                                    pl = v;
                                    flag = 1;
                                    break;
                                }
                            if (!flag) break;
                        }
                        break;
                    }
                return cur;
            }
        }
        //failed to find a path
        return vi();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m, k;
    cin >> n >> m >> k;

    vector<pair<int, int>> init(m);
    for (auto &[u, v] : init) {
        cin >> u >> v;
        if (u > v) {
            swap(u, v);
        }
    }

    while (true) {
        vector<vector<int>> paths;
        vector<vector<pair<int, int>>> es;
        es.push_back(init);
        int notWork = 0;
        while (paths.size() < k) {
            auto res = hamil::work(n, es.back());
            if (!res.empty()) {
                paths.push_back(res);
                vector<pair<int, int>> rem;
                for (int i = 0; i < n; ++i) {
                    rem.push_back(minmax(res[i], res[(i + 1) % n]));
                }
                sort(rem.begin(), rem.end());
                vector<pair<int, int>> nxt;
                for (auto e : es.back()) {
                    if (!binary_search(rem.begin(), rem.end(), e)) {
                        nxt.push_back(e);
                    }
                }
                es.push_back(nxt);
            } else {
                notWork += 1;
                if (notWork == 5) {
                    paths.pop_back();
                    es.pop_back();
                }
            }
        }
        if (paths.size() == k) {
            for (auto f : paths) {
                for (int x : f) {
                    cout << x << " ";
                }
                cout << '\n';
            }
            return 0;
        }
    }


    return 0;
}

详细

Test #1:

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

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 4 5 2 
2 3 5 1 4 

result:

ok OK (n = 5, m = 9)

Test #2:

score: 0
Accepted
time: 618ms
memory: 28068kb

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:

2394 4633 1861 7624 7509 7878 6655 226 3313 1047 9497 5203 6837 5696 4817 4878 5304 5699 4366 1419 8402 4035 1249 8649 2717 6411 7595 3396 7773 1159 8523 3725 668 1452 443 3750 439 4086 2462 5300 6997 173 142 9647 7263 5930 6936 3394 5072 2081 608 3301 8778 4249 6593 5397 3417 4512 6239 1046 4426 51...

result:

ok OK (n = 10000, m = 200000)

Test #3:

score: 0
Accepted
time: 588ms
memory: 26504kb

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:

3451 198 5092 4098 5479 7446 7676 8444 9969 521 9532 9877 8175 56 6180 6548 7277 7799 5375 4557 9839 9794 6133 3726 2568 9416 8002 9928 6610 5234 6080 2852 4795 8112 2004 9440 3597 2208 8282 8960 3399 4516 3093 4874 2912 1808 4490 6107 497 7860 2342 6657 2719 9528 4746 9549 8396 1246 3341 8245 9071 ...

result:

ok OK (n = 10000, m = 200000)

Test #4:

score: 0
Accepted
time: 620ms
memory: 26256kb

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:

1323 8614 6231 6955 2548 6964 1324 325 1990 8648 4843 5641 1667 8127 6236 5724 9090 8120 6273 9411 8340 2858 4102 9740 9736 1650 6947 2072 3731 9629 1544 1874 8249 6310 5489 9456 56 6078 5704 8497 7091 2855 4716 7179 9486 7224 7445 6691 5009 9507 4506 7481 1245 3009 2586 2785 5500 8078 4444 2466 395...

result:

ok OK (n = 10000, m = 200000)

Test #5:

score: 0
Accepted
time: 573ms
memory: 27364kb

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:

1037 1877 6892 9802 8316 9479 4254 4500 8977 614 7698 7678 9885 4535 7620 9036 6036 5136 9828 5311 6870 4510 4681 7424 1460 4675 5810 4338 7650 7735 7706 1343 293 5867 6290 7382 7460 2986 8251 3699 6485 9638 7654 6299 5502 2493 567 6857 679 6557 1362 2694 1918 2940 2151 9915 1885 7330 2774 2018 8561...

result:

ok OK (n = 10000, m = 200000)

Test #6:

score: 0
Accepted
time: 599ms
memory: 26604kb

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:

1910 631 9811 8190 4278 7653 7561 4240 3337 8669 134 4192 5226 1732 2702 7510 8106 1071 9080 7808 3032 4231 8699 87 5831 1220 6643 5498 1830 4331 3421 4626 734 6140 8087 179 7201 1894 3126 8506 7251 4684 3568 5466 9532 4061 7155 4364 4677 3044 3900 4306 6971 8215 2567 3165 709 4339 2040 1010 3068 11...

result:

ok OK (n = 10000, m = 200000)

Test #7:

score: 0
Accepted
time: 581ms
memory: 27024kb

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:

288 3468 7492 4773 3727 3725 5508 5870 2976 6093 667 9780 5100 9128 58 3835 1779 8312 3446 4492 2095 1814 4354 7602 1002 7693 6538 5352 1753 7590 9277 8957 6784 7361 260 689 4959 4896 8044 100 1409 6930 338 2071 3635 6089 4337 3659 8392 8851 1307 7403 6240 9673 6588 835 7895 9651 8067 7811 2257 8662...

result:

ok OK (n = 10000, m = 200000)

Test #8:

score: 0
Accepted
time: 597ms
memory: 26708kb

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:

5087 5999 3223 2035 3633 233 1245 9170 1646 9895 1059 4670 150 2810 5945 2719 3798 8890 7709 7755 7390 468 2263 5531 4301 8845 6848 2203 9361 8362 4444 4649 6468 4304 2616 1490 9788 8559 6144 2326 1838 4565 2892 4633 3178 738 9906 3335 2402 403 2300 4926 4406 583 9979 6738 6879 1671 655 1389 4828 97...

result:

ok OK (n = 10000, m = 200000)

Test #9:

score: 0
Accepted
time: 586ms
memory: 26364kb

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:

93 8230 6599 9091 7852 6406 892 1388 5967 9036 1741 2200 9413 9022 3415 1640 3786 9255 5661 1529 7991 2499 5108 5136 8491 1931 2496 3285 2914 536 9203 4203 1988 9946 9006 7283 7068 6285 7874 867 1680 6925 4150 9343 5758 6753 6727 4452 8111 3808 486 5779 3295 9276 8278 1510 5571 5623 5665 3560 7339 8...

result:

ok OK (n = 10000, m = 200000)

Test #10:

score: 0
Accepted
time: 613ms
memory: 26528kb

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:

6384 521 5690 5902 4750 5217 3881 8852 3461 4744 3354 8187 3061 5051 4117 3020 650 4026 4501 6050 108 5907 7886 3426 2809 9788 948 7089 734 4145 3057 5908 8155 8056 7175 6610 4460 5439 7077 6973 6906 7038 6149 596 8951 4378 1177 2441 3443 5916 1438 7594 805 5437 4090 6734 9972 6698 4063 6796 2352 78...

result:

ok OK (n = 10000, m = 200000)

Test #11:

score: 0
Accepted
time: 588ms
memory: 27228kb

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:

6122 9179 1107 3035 8522 2523 4878 9017 4722 8715 23 7788 7249 8617 5440 6681 3028 6268 9756 139 1667 9474 2126 6753 4778 2441 1762 5626 7564 7997 7224 3923 6838 4725 2193 2895 7979 1746 1084 6014 4575 78 6762 1414 4715 9241 4266 3722 9047 5423 1077 876 3186 5879 1641 7504 7245 6544 4423 9341 5974 6...

result:

ok OK (n = 10000, m = 200000)

Test #12:

score: 0
Accepted
time: 591ms
memory: 26552kb

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:

1845 5385 5748 785 4255 4737 2377 4407 6372 2813 2184 6072 2782 6415 2036 8819 1415 331 8068 5579 9013 301 1260 3534 8784 7337 8196 6777 6847 2552 4596 7634 5379 9637 8339 1212 8693 4259 4460 3688 9436 8117 6537 3420 2860 1077 8810 2527 8494 8504 3792 9647 7344 5600 1898 6119 7240 9573 4350 4120 911...

result:

ok OK (n = 10000, m = 200000)

Test #13:

score: 0
Accepted
time: 558ms
memory: 26276kb

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:

4301 2392 2451 7427 8617 5059 7455 9991 374 6333 7172 5756 4341 560 7784 3164 6709 8087 8382 9791 8803 5670 3880 6309 1833 8845 3586 6986 8708 8571 3512 4593 4117 101 6684 4863 2574 7365 5406 5748 4685 6543 6382 6851 797 8528 619 5885 9614 5420 9144 5000 6548 4943 3877 2454 5933 7497 8022 4705 4574 ...

result:

ok OK (n = 10000, m = 200000)

Test #14:

score: 0
Accepted
time: 579ms
memory: 27048kb

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:

5320 3030 9091 7213 590 1097 5878 6795 5113 8860 4431 3286 4797 707 2196 5530 6975 3591 7791 864 5182 1115 8775 8753 4035 9527 2660 9528 6639 4379 627 6843 9981 3521 3190 4529 486 9610 1941 2251 4260 1347 4445 8517 2806 4956 1793 9105 776 5270 7100 8784 8742 3076 2646 2964 1108 746 3542 91 5662 8148...

result:

ok OK (n = 10000, m = 200000)

Test #15:

score: 0
Accepted
time: 572ms
memory: 26720kb

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:

2233 81 3656 5400 5437 4006 6516 6362 4424 5376 9244 1241 7266 908 1260 7189 6575 2363 4087 6150 8900 6247 5839 8164 4921 3600 5324 3051 230 6438 1259 2317 7092 8378 3389 7435 3468 5112 7808 2433 960 5352 4868 4302 407 8324 133 9879 6032 3166 9952 2104 697 2222 4667 1550 7685 8533 5572 8764 729 9792...

result:

ok OK (n = 10000, m = 200000)

Test #16:

score: 0
Accepted
time: 627ms
memory: 27816kb

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:

1485 8463 4268 8325 3447 7241 7266 1953 6862 6932 9955 8413 6991 5550 4983 3645 2122 8603 1527 5935 3159 5180 8812 9386 2521 1150 3669 795 3139 6012 5996 5716 356 4334 7108 2436 8132 4443 583 4110 6470 9320 6821 608 5407 7743 860 7000 4575 3767 7577 4820 8626 36 7343 1838 7197 1422 704 2375 8370 308...

result:

ok OK (n = 10000, m = 200000)

Test #17:

score: 0
Accepted
time: 593ms
memory: 27180kb

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:

1666 9816 7421 8369 7983 3604 8187 1502 9752 9350 3787 6568 2544 2308 7748 1940 2448 9168 6423 2559 3233 3933 9179 6090 9064 9440 3139 9435 1637 3489 4816 6434 4017 6210 6163 1837 4587 9314 6268 1299 480 1971 9060 3503 3671 3970 4010 8932 1041 4573 1693 1062 5675 4305 6859 3903 8026 7660 5860 1108 8...

result:

ok OK (n = 10000, m = 200000)

Test #18:

score: 0
Accepted
time: 591ms
memory: 27196kb

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:

4079 7967 5104 7519 5284 5767 6730 3426 4554 5882 8022 4861 1284 7524 1699 529 4017 7440 9711 8845 6951 6073 6187 4457 5951 5302 4888 8591 6618 8146 2044 2094 9478 99 3726 4472 7736 1872 8745 5889 9830 6471 8184 6147 7066 6896 3879 310 6322 1956 3354 1128 7599 6545 4376 5124 2512 9709 6333 6547 825 ...

result:

ok OK (n = 10000, m = 200000)

Test #19:

score: 0
Accepted
time: 585ms
memory: 26344kb

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:

7086 214 5496 1375 3509 2038 2630 4018 9692 3968 5470 9077 1740 9975 2901 6405 6485 599 7587 1439 2042 4752 2547 6052 6380 9487 9156 5787 2068 8485 68 1133 567 3067 7345 913 1009 2983 3624 8922 9 6847 706 4478 5990 9802 3630 1419 1365 5199 691 9773 3525 378 3356 4513 7537 8550 8457 9065 8729 6185 38...

result:

ok OK (n = 10000, m = 200000)

Test #20:

score: 0
Accepted
time: 571ms
memory: 26340kb

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:

79 3418 7975 2841 6850 2506 4220 3598 1746 9654 6327 4228 9292 6573 1948 6433 3381 387 6671 7072 3081 1047 7952 4440 8930 6711 323 6934 7260 215 9634 8627 3297 8522 7132 3234 3395 5154 4658 9886 7409 6451 2384 1707 1400 1158 2512 8783 8331 8275 4813 6206 1056 2579 5807 3338 9910 7109 7932 3628 7316 ...

result:

ok OK (n = 10000, m = 200000)

Test #21:

score: 0
Accepted
time: 608ms
memory: 26324kb

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:

4821 540 2052 2594 7238 5828 4738 9947 8304 2055 4879 4080 2213 5556 6709 9886 5293 6671 7629 3375 8916 9503 4190 3341 1054 9998 7480 1626 9681 8631 9121 3252 2575 5766 3648 9854 585 356 2577 6913 126 4356 36 2287 6341 3783 2979 5198 3523 6455 8554 3511 3561 2000 1588 3572 5880 929 5396 491 1036 736...

result:

ok OK (n = 10000, m = 200000)

Test #22:

score: 0
Accepted
time: 587ms
memory: 26416kb

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:

6214 6277 4364 88 3947 4806 396 4435 7484 5756 8156 9546 7055 6732 8494 525 9447 3521 3895 1780 4972 8538 5083 5097 8586 8063 7588 100 133 9464 2920 6714 7087 1530 2016 6836 9176 2232 3244 2885 2970 7273 2848 3652 9335 9129 9751 9776 2252 5566 1572 4537 3392 5788 3189 5892 1909 9499 8742 4662 354 24...

result:

ok OK (n = 10000, m = 200000)

Test #23:

score: 0
Accepted
time: 601ms
memory: 27240kb

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:

2490 6772 4157 1205 6626 1199 1660 3320 2124 2443 9885 6221 2391 5149 8258 1732 5175 5298 640 7307 6762 4987 5301 4565 7320 1046 1904 7662 9667 1568 3486 3820 6958 1142 5428 1093 7641 429 4861 8152 665 2185 2846 9936 3836 9397 8337 8539 3311 6344 3024 2451 3945 3943 3381 4445 8460 7084 8291 1196 869...

result:

ok OK (n = 10000, m = 200000)

Test #24:

score: 0
Accepted
time: 576ms
memory: 26480kb

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:

5011 2262 5902 6908 8495 8433 2258 2823 2598 1699 6377 4175 8545 3761 8897 1763 6600 5032 1749 2999 7342 7310 7527 5005 7497 8553 4994 9244 1153 5707 9176 8426 7766 5530 7785 2762 2942 1754 9346 4985 2867 3590 6846 4224 4427 905 7241 1545 8237 8030 1224 6042 1277 9811 1346 1091 6873 4867 2893 9429 9...

result:

ok OK (n = 10000, m = 200000)

Test #25:

score: 0
Accepted
time: 615ms
memory: 26680kb

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:

3784 4135 8765 7606 3702 2843 9287 2124 8268 2429 3408 6043 7945 83 7508 1649 6881 7528 9308 2959 8686 5183 829 795 7350 7679 1366 6680 4631 7688 6075 1934 7378 7121 7144 6108 8125 2456 802 1321 8491 7862 5686 6551 9508 508 4509 7997 3041 5119 8303 6695 5723 2092 846 6312 7787 1196 9116 2446 6071 21...

result:

ok OK (n = 10000, m = 200000)

Test #26:

score: 0
Accepted
time: 577ms
memory: 26388kb

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:

255 7462 902 6959 9346 3905 8099 5859 4088 3353 5231 6029 9046 8390 4369 9758 7655 3028 4243 34 2717 6383 3441 7196 4704 2294 1102 1096 5798 4537 5467 400 8412 9361 326 4118 8455 1040 7207 2106 2229 9538 7669 8045 2008 2721 9074 8318 4007 7302 7667 6812 7024 4989 5535 6444 468 5242 8988 5423 6715 57...

result:

ok OK (n = 10000, m = 200000)

Test #27:

score: 0
Accepted
time: 585ms
memory: 27012kb

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:

987 378 3512 7510 3442 9039 4805 1874 3437 5108 4738 4222 5914 1221 2896 5181 6754 5650 7636 1422 7716 1504 8134 1008 3446 451 9430 8456 87 3492 9596 137 1416 2658 1516 9973 6698 1396 4736 2905 8542 5278 989 3476 2894 7112 9635 540 2480 9436 1235 1944 423 9628 3971 8117 5488 2306 9441 3659 475 8468 ...

result:

ok OK (n = 10000, m = 200000)

Test #28:

score: 0
Accepted
time: 599ms
memory: 27060kb

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:

811 8765 7161 2258 8949 1042 5742 2526 8517 6326 3486 7532 3122 4951 3831 8318 7818 8731 9976 8316 8665 2203 2266 886 1628 1328 5991 2661 278 9839 7568 4348 2786 9531 6960 1114 8377 5739 2904 9557 5044 5296 9434 3810 1762 8450 6766 3912 3855 2441 7359 3415 2988 832 5315 9203 1831 6540 5950 8282 9454...

result:

ok OK (n = 10000, m = 200000)

Test #29:

score: 0
Accepted
time: 597ms
memory: 27292kb

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:

5868 1478 9984 1730 2278 7108 8549 616 5383 3407 434 3457 7408 5586 2759 8712 5684 3154 9205 5134 7672 7023 9703 6597 2692 6954 7069 8653 1374 4104 4514 5245 4712 6737 6953 8003 5584 2605 9772 4932 1591 1863 6392 8266 4677 8055 9300 1193 8305 7882 9071 2667 6508 902 481 8615 1328 3368 2837 202 41 40...

result:

ok OK (n = 10000, m = 200000)

Test #30:

score: 0
Accepted
time: 599ms
memory: 26240kb

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:

7269 9519 843 8066 1852 6229 3776 5408 2618 4385 4698 6667 5935 5184 4141 224 3774 2962 7440 7866 8173 4274 3938 5625 2321 2113 5732 6594 8724 7947 2898 5950 33 7078 9481 5576 6064 245 3071 5954 4633 4963 9555 5257 5565 7754 1975 6322 2094 254 820 3369 3500 1447 3581 560 264 1991 7047 5661 2489 6259...

result:

ok OK (n = 10000, m = 200000)

Test #31:

score: 0
Accepted
time: 580ms
memory: 26548kb

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:

1331 8554 5281 2133 8218 2896 9579 5990 3600 3441 8230 4941 7375 7178 3180 1992 4981 305 1822 5698 2548 4576 8806 1791 8430 9250 1399 3648 8761 8926 7489 2794 8556 1465 1623 558 3525 8137 6965 5865 9827 5804 4035 7912 3985 1608 4476 3097 928 8163 2985 9270 6457 8250 9060 7292 1738 595 1461 4592 4273...

result:

ok OK (n = 10000, m = 200000)

Extra Test:

score: 0
Extra Test Passed