QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#459981#8787. Unusual Caseucup-team2307#AC ✓553ms24200kbC++203.2kb2024-06-30 18:36:372024-06-30 18:36:38

Judging History

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

  • [2024-06-30 18:36:38]
  • 评测
  • 测评结果:AC
  • 用时:553ms
  • 内存:24200kb
  • [2024-06-30 18:36:37]
  • 提交

answer

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

using ll = long long;
#define int ll
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pii = pair<int, int>;
using vi = vector<int>;
#define fi first
#define se second
#define pb push_back

mt19937 rng(time(0));
vector<int> g[100500];
set<pair<int, int> > st;
int n = 10000;
int m = 200000;

void gen()
{
    st.clear();
    while (st.size() < m)
    {
        int a = rng()%n;
        int b = rng()%(n-1);
        if (b>=a) b++;
        if (b<a) swap(a, b);
        st.insert({a, b});
    }
    for (int i=0; i<n; i++)
        g[i].clear();
    for (auto [x, y] : st)
        g[x].pb(y), g[y].pb(x);
}

int p[100500];
int get(int v)
{
    if (v == p[v])
        return v;
    return p[v] = get(p[v]);
}
void un(int u, int v)
{
    u = get(u);
    v = get(v);
    p[u] = v;
}
bool ised(int v, int u)
{
    if (v > u)
        swap(v, u);
    return st.count({v, u});
}

int Q;
vector<int> ham()
{
    int v = 0;
    for (int i=1; i<n; i++)
        if (g[i].size() < g[v].size())
            v = i;
    vector<bool> used(n);
    int cnt = 1;
    used[v] = 1;
    int v0 = v;
    vector<int> nt(n, -1);
    vector<int> bd(n, -1);

    while (cnt < n)
    {
        int u = -1;
        for (int i : g[v])
            if (!used[i])
                if (u == -1 || g[i].size() < g[u].size())
                    u = i;
        if (u==-1)
        {
            int r = g[v][rand()%g[v].size()];
            int to = nt[r];
            nt[v] = r;
            nt[r] = v;

            v = to;
            while (v != r)
            {
                swap(nt[v], bd[v]);
                v = bd[v];
            }
            v = to;
            nt[v] = -1;

            continue;
        }
        nt[v] = u;
        bd[u] = v;
        v = u;
        used[v]=1;
        cnt++;
//        cout<<Q<<" "<<cnt<<endl;
    }
    vector<int> ans = {v0};
    for (int i=1; i<n; i++)
    {
        int v = nt[v0];
        ans.pb(v);
        v0 = v;
    }
    return ans;
}

void rm(int x, int y)
{
    for (int i=0; i<int(g[x].size()); i++)
        if (g[x][i] == y)
        {
            g[x].erase(g[x].begin()+i);
            break;
        }
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    cin.exceptions(cin.failbit);
    int k=8;

    cin>>n>>m>>k;
    for (int i=0; i<m; i++)
    {
        int x, y;
        cin>>x>>y;
        x--;y--;
        if (x>y) swap(x, y);
        g[x].pb(y);
        g[y].pb(x);
        st.insert({x, y});
    }

//    while (true)
    {
//        gen();
        for (Q=1; Q<=k; Q++)
        {
            auto ans = ham();
            for (int i=0; i+1<n; i++)
            {
                int x = ans[i];
                int y = ans[i+1];
                if (x > y)
                    swap(x, y);
                if (!st.count({x, y}))
                    exit(3);
                st.erase({x, y});
                rm(x, y);
                rm(y, x);
            }
            for (int i : ans)
                cout<<i+1<<" ";
            cout<<endl;
        }
//        cout<<"OK"<<endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

result:

ok OK (n = 5, m = 9)

Test #2:

score: 0
Accepted
time: 481ms
memory: 22400kb

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 3500 9074 3775 6428 5473 8614 8136 6586 2067 3318 9641 5347 858 851 2510 4606 3088 3062 1746 8783 3135 3193 2174 439 9952 6629 2588 8017 8200 1563 7225 5245 5395 1077 1431 6986 4636 4164 4009 1339 523 4050 2953 5873 9604 4768 5944 2457 4716 1046 749 3928 7917 5605 3759 3541 705 2036 6352 1660 4...

result:

ok OK (n = 10000, m = 200000)

Test #3:

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

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 1002 1131 3104 3289 7469 5248 9412 2473 6476 9625 9689 1527 1453 6561 3577 8659 7277 3185 2713 6285 8722 7174 3280 8151 4349 7865 4002 5751 6871 1523 7884 7565 6548 4045 1239 146 7084 9357 5092 9555 8630 2123 8995 26 9218 2073 6858 5764 1918 3911 2957 2901 4067 2463 7213 8055 9486 5107 4242 542...

result:

ok OK (n = 10000, m = 200000)

Test #4:

score: 0
Accepted
time: 443ms
memory: 22128kb

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 4966 2318 979 1846 3913 9441 687 4672 6210 962 40 1330 3982 4499 1506 934 7680 7660 8840 3641 8438 2205 8238 4688 757 879 4382 2776 7012 6462 2898 9837 1804 7023 2573 8455 3195 3057 1924 6689 5771 2284 9053 4594 373 5841 652 8152 4590 7112 47 4377 7741 6366 1131 4730 2321 6962 4370 7687 1679 13...

result:

ok OK (n = 10000, m = 200000)

Test #5:

score: 0
Accepted
time: 455ms
memory: 22140kb

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 7887 9246 2515 8377 3360 8219 5980 1455 9978 5301 8528 7547 8491 149 1110 3295 7821 778 7727 6243 2857 8249 4205 5277 4354 7560 7034 9771 6369 225 1799 9863 6042 3518 5023 395 1858 3667 4533 2692 3153 1195 4161 2427 7751 1350 5505 9352 7464 7383 3455 1639 4936 9206 6901 2139 9678 1096 7225...

result:

ok OK (n = 10000, m = 200000)

Test #6:

score: 0
Accepted
time: 491ms
memory: 23928kb

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 2876 9328 2901 7739 1125 368 6378 3033 1224 5177 883 2729 517 1499 3812 1486 8945 9066 660 4963 842 9625 4876 9666 1127 9679 4866 7210 1580 6652 5623 2053 293 3145 5964 4405 9059 1144 927 5053 4418 772 5224 5532 3878 6160 2099 4128 3508 924 9326 2293 4548 1084 7339 2503 6715 2502 9874 5358...

result:

ok OK (n = 10000, m = 200000)

Test #7:

score: 0
Accepted
time: 466ms
memory: 24200kb

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 5866 9432 4528 339 3642 7493 5239 6173 8977 2727 9602 636 9823 4026 8580 3446 1879 9575 1976 2607 2370 6496 3853 9776 3528 5326 4577 4514 1493 692 4644 7470 9325 6801 6750 3526 6538 1187 8976 3566 6630 51 4632 5995 2291 4219 8092 4865 4115 3906 3383 7528 1066 9547 1515 3599 4084 1496 1101 3362 2...

result:

ok OK (n = 10000, m = 200000)

Test #8:

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

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 6671 6357 9917 2426 6587 7895 2449 3067 461 233 7508 7678 8694 8207 9769 2714 7075 3007 7557 3813 1833 7457 6035 1340 253 574 3398 7852 7220 202 3403 2381 7651 324 7837 104 3233 2518 1978 1319 5122 1938 5474 5746 4090 9348 7742 23 5322 4169 3770 7144 6195 5721 4042 1426 668 9151 3188 9474 3168 ...

result:

ok OK (n = 10000, m = 200000)

Test #9:

score: 0
Accepted
time: 496ms
memory: 22048kb

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 330 7521 9934 8507 4625 1336 775 6816 7784 9945 1453 5829 4753 2213 1175 5429 2684 7070 227 6711 3531 7178 2633 1618 2884 6035 5382 2255 2242 3460 2327 9935 1919 3343 567 2558 1949 2791 5187 5607 5417 3475 2236 5036 9426 3323 3130 1833 8279 9601 1343 949 1755 9197 9150 4898 3060 6014 6137 2750 ...

result:

ok OK (n = 10000, m = 200000)

Test #10:

score: 0
Accepted
time: 495ms
memory: 23984kb

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 2775 1898 594 197 1930 6115 5241 1766 4982 7836 8984 6882 5057 1604 490 6458 1176 8933 6871 1779 4404 5030 2758 9040 252 9730 2933 4056 9398 7083 4210 8829 5906 3046 7628 9008 1073 8124 1665 149 6788 7959 1349 7225 101 5113 7287 6776 4885 1373 5165 1907 5603 6737 7176 9099 6542 4177 879 141 851...

result:

ok OK (n = 10000, m = 200000)

Test #11:

score: 0
Accepted
time: 470ms
memory: 22068kb

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 1185 2444 9444 7220 8903 8947 5188 7934 2108 7189 1838 8712 7259 1692 6906 9550 4595 4597 5629 6801 2463 2604 3281 3032 4772 114 5529 5149 7007 6504 399 5568 2245 7522 5646 2440 4324 5214 9365 7340 7948 3938 7750 4500 7644 5260 3226 1789 6065 7520 8784 2438 8689 7823 2143 8886 5851 4564 6634 21...

result:

ok OK (n = 10000, m = 200000)

Test #12:

score: 0
Accepted
time: 457ms
memory: 22132kb

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 8147 1203 2349 3520 2804 7768 404 132 1447 4845 287 9683 596 5251 2880 606 3930 7039 9219 2562 3470 678 7692 842 714 4124 738 3891 7711 8885 2980 4585 1930 9337 7952 1919 7992 5992 7636 5765 9726 3389 5918 5540 9052 2714 2810 7025 2976 2581 2634 9644 2050 4580 1823 4650 8246 5993 5179 7019 3521...

result:

ok OK (n = 10000, m = 200000)

Test #13:

score: 0
Accepted
time: 440ms
memory: 22128kb

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 8027 3807 2558 510 9207 4736 5714 5786 2532 1477 3735 4732 2786 8657 6305 4680 724 4911 2790 5292 4985 9895 7061 1637 2295 8921 4374 2088 9099 4766 9406 5007 5041 9695 6174 202 3816 3928 6086 1407 4128 8586 5828 2149 760 6359 4619 6998 5946 7780 3338 4620 2757 937 6943 6309 1833 4098 7935 4574 ...

result:

ok OK (n = 10000, m = 200000)

Test #14:

score: 0
Accepted
time: 488ms
memory: 23964kb

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 5703 152 5723 3500 4319 3177 1589 424 3731 7354 2382 2107 2621 6244 1717 1255 6053 9237 6701 6471 7653 1361 2897 5027 6277 7634 7284 8292 8717 2558 1897 8209 1019 7603 1704 8270 58 9124 199 5764 5181 9982 8807 5798 2681 4970 1171 5615 1185 9050 3968 7025 9859 2632 3111 5249 9435 6726 1661 7012 ...

result:

ok OK (n = 10000, m = 200000)

Test #15:

score: 0
Accepted
time: 475ms
memory: 23952kb

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 3604 1062 5418 7644 5556 3153 4122 6909 474 6520 364 863 2607 5022 9673 7549 5713 6082 4054 6392 4429 2908 1918 2483 7875 5533 2411 8405 6657 2525 7323 8116 5062 5166 1204 4465 1837 8201 1157 7339 5707 3438 8967 3109 7236 9038 1847 6901 783 6193 7757 6067 6207 2996 8270 8954 5729 8898 6426...

result:

ok OK (n = 10000, m = 200000)

Test #16:

score: 0
Accepted
time: 466ms
memory: 23948kb

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 6537 3023 9617 5915 7424 2823 8011 9894 9951 8762 6192 6566 9782 7070 9087 5233 5633 8887 568 1568 5505 8362 8776 7131 7181 5108 1561 4711 3412 1804 6882 5854 8161 5355 8209 547 9401 6359 6491 7818 8320 637 7080 8295 9763 1239 1452 5946 5286 6631 8637 3779 9979 873 1216 9421 7576 8795 8787 4019...

result:

ok OK (n = 10000, m = 200000)

Test #17:

score: 0
Accepted
time: 456ms
memory: 22164kb

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 9518 580 3409 4469 3888 7540 9544 7323 2879 3371 7690 4923 1024 6921 9083 5610 4854 7922 2266 1774 3919 5371 2552 7857 1022 1230 1928 1437 4209 8986 1243 9781 738 5792 6404 9637 3090 5834 8823 8454 8218 6631 639 635 8465 7707 1058 628 7638 425 1710 2011 6787 1021 8496 9815 1347 2837 6592 3133 1...

result:

ok OK (n = 10000, m = 200000)

Test #18:

score: 0
Accepted
time: 543ms
memory: 22064kb

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 2960 9274 8135 8984 8661 9424 7613 3079 3855 6360 5489 9507 686 4524 5349 6895 1701 7040 6595 903 8952 4894 6142 2708 6471 2772 8951 3956 3831 5015 2927 4140 161 5141 7742 4208 8508 7446 7400 3382 917 5417 4688 5770 4943 1741 7397 3627 8176 9883 6268 6259 6710 737 3560 7152 3752 5913 1263 6094 9...

result:

ok OK (n = 10000, m = 200000)

Test #19:

score: 0
Accepted
time: 500ms
memory: 23892kb

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 2114 3918 4405 2125 6449 3419 2907 3111 3083 9473 3428 7670 9472 3978 83 5549 9994 2117 5851 8429 1442 3690 2558 6822 6358 9380 7817 1399 197 3839 6243 6508 5752 9046 6652 9342 6567 2688 3506 5900 1468 4236 260 68 7872 2674 6287 3497 918 5159 1202 7630 6643 9070 5332 7211 2323 7890 6749 3563 28...

result:

ok OK (n = 10000, m = 200000)

Test #20:

score: 0
Accepted
time: 490ms
memory: 22196kb

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 9463 5313 2499 9151 1429 6824 4513 1394 4540 1316 2910 6582 3358 2572 9036 3374 8910 2913 8285 2283 6045 4770 645 6338 5197 8474 357 9052 78 8793 7683 9752 1760 6286 4792 1474 9189 9372 1585 7520 7481 3194 9640 5692 1489 8628 6311 6244 5205 2875 5561 5825 7072 3437 4313 387 8697 3591 3951 93 63...

result:

ok OK (n = 10000, m = 200000)

Test #21:

score: 0
Accepted
time: 495ms
memory: 22372kb

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 637 6981 8579 38 8794 2196 8823 1306 2440 1703 3500 7565 7102 2743 539 1650 8241 1566 5373 9046 2698 6317 6127 813 9529 8283 3946 877 3311 9324 4134 3497 4827 8154 1203 4323 3206 9886 6824 5046 8000 9616 6876 7327 230 8557 6899 1348 1534 4077 1029 9054 1213 3451 1874 1085 6447 6552 4582 9250 37...

result:

ok OK (n = 10000, m = 200000)

Test #22:

score: 0
Accepted
time: 475ms
memory: 22140kb

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 407 2826 8810 8469 8268 418 68 1920 9288 7303 5686 4486 9880 2615 7848 6051 3405 8228 4276 9998 2267 7851 8414 4772 2923 5793 3178 7405 7776 7123 560 7761 4406 7737 1965 1622 4620 9326 5821 3511 1788 1655 6074 686 8136 1028 6929 4452 7650 8094 9898 6200 9726 5354 8931 8607 4890 6474 4545 828 51...

result:

ok OK (n = 10000, m = 200000)

Test #23:

score: 0
Accepted
time: 478ms
memory: 23888kb

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 8110 1106 3864 2246 6108 808 4182 4391 1332 9535 487 3870 4620 199 4545 6480 9495 8458 3403 6701 3108 9811 2744 9450 6632 4917 1671 3544 9910 8627 3686 7744 5356 2531 3843 380 2925 8926 7988 1816 9992 1244 3431 9718 2087 9106 5282 5969 3682 9308 403 3193 3336 4149 4822 8316 2376 3144 8654 534 5...

result:

ok OK (n = 10000, m = 200000)

Test #24:

score: 0
Accepted
time: 468ms
memory: 22060kb

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 4562 9102 9226 3634 367 2617 9207 197 6846 882 9815 1696 7421 3092 1149 7106 3639 3614 500 7630 8189 7236 1216 8170 2765 7573 5781 4704 4872 5055 8918 2677 5650 8885 2078 2153 5823 5740 8837 6102 9275 9739 2446 561 9726 8666 666 7599 6088 8404 5312 3424 2737 3218 3658 7847 7914 768 5009 8350 735...

result:

ok OK (n = 10000, m = 200000)

Test #25:

score: 0
Accepted
time: 527ms
memory: 22176kb

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 3455 3879 2659 9590 8845 3190 8678 7487 377 606 8440 4569 3024 6768 2255 945 5772 2669 3061 3807 8608 1059 5868 3660 2301 3615 6628 5540 9237 7770 481 2752 5432 4020 9286 5896 1407 9330 1017 3602 8247 3264 8071 5975 7511 7611 5838 866 9862 7081 1444 7960 3353 3436 2047 814 6604 5181 2157 775 513...

result:

ok OK (n = 10000, m = 200000)

Test #26:

score: 0
Accepted
time: 478ms
memory: 22120kb

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 9561 5408 9985 9185 2357 5039 421 6214 1222 5850 6253 5844 5345 4431 3558 8033 2539 9006 7153 3755 8315 981 2923 1788 3819 3675 8973 805 4622 3056 3905 5429 9468 6700 659 9265 2269 5272 5225 4288 3411 3764 8775 5818 2818 9978 5169 3828 1826 3385 5148 7078 1687 4596 1399 6001 247 3841 5417 7691 ...

result:

ok OK (n = 10000, m = 200000)

Test #27:

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

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 3894 938 6981 5583 885 6620 2068 1638 667 4280 2893 9583 1966 8688 3264 5284 8974 2275 8525 8712 7251 9341 983 578 5825 5223 5612 9015 4649 8594 2351 6816 1878 9990 4061 1660 5416 4259 7334 7535 69 9185 6251 7652 3283 5891 48 3618 5131 5542 1031 4472 87 6296 881 9914 4666 4851 1029 5488 2306 72...

result:

ok OK (n = 10000, m = 200000)

Test #28:

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

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 8435 176 7504 7490 5984 4072 7691 8641 9477 9888 5709 6286 8168 3589 3593 182 2447 7233 416 3205 884 4999 5825 8795 5933 4756 1610 316 2274 4395 9161 8461 7094 989 2404 7491 7833 9521 4850 1286 9233 3999 1747 5758 2830 7565 453 1322 498 4124 9928 6580 2839 783 315 7650 6646 6605 513 5934 5671 5...

result:

ok OK (n = 10000, m = 200000)

Test #29:

score: 0
Accepted
time: 458ms
memory: 22116kb

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 9121 2940 507 6855 2521 6920 9283 7189 7627 8469 350 7940 2174 9279 7156 6786 4132 1614 780 2304 8629 3213 689 4356 5924 8447 4718 2541 9922 1634 1065 3348 5655 5308 4995 8350 7298 8588 8476 8319 5272 331 2984 9551 2831 2336 8770 7885 2071 649 9888 775 5743 873 8599 5367 3901 1897 9639 5986 491...

result:

ok OK (n = 10000, m = 200000)

Test #30:

score: 0
Accepted
time: 525ms
memory: 22396kb

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 840 3968 2990 1269 8398 4704 7766 2993 3605 4142 9112 9204 3431 5955 3133 3465 7575 2434 9606 9343 1379 1541 451 6220 3446 7041 9135 242 8423 1642 6449 5831 7064 2764 4851 7116 3635 5197 3720 8224 14 2038 4607 577 2142 8317 4452 3614 8614 8736 6531 9416 3406 5814 867 4405 7708 5115 9513 3088 25...

result:

ok OK (n = 10000, m = 200000)

Test #31:

score: 0
Accepted
time: 553ms
memory: 22108kb

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 4922 5022 422 1753 3499 4204 5522 7605 987 7227 709 158 7255 614 882 6823 9857 1186 1895 6688 3528 1858 1636 3501 7556 1530 3059 4108 1829 7767 9551 3779 917 3537 9023 5083 1061 2864 9360 7877 3773 7668 6985 1022 2803 3250 1264 7762 9093 2107 2524 665 7727 2794 1480 9467 353 2162 3065 2712 7800...

result:

ok OK (n = 10000, m = 200000)

Extra Test:

score: 0
Extra Test Passed