QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#667098#8787. Unusual Caseucup-team134AC ✓2121ms223224kbC++177.0kb2024-10-22 21:02:562024-10-22 21:03:00

Judging History

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

  • [2024-10-22 21:03:00]
  • 评测
  • 测评结果:AC
  • 用时:2121ms
  • 内存:223224kb
  • [2024-10-22 21:02:56]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ld long double
#define li __int128

using namespace std;

mt19937 rng(time(NULL));
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;
                }
            }
        }
    }
    vi out, in;
    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.  
        out.resize(n + 1), in.resize(n + 1);
        LCT::init(n);
        for (int i = 0; i <= n; i++) in[i] = out[i] = 0;
        if (mx_ch == -1) mx_ch = 1ll * (n + 100) * (n + 50); //default
        vector<vi> from(n + 1), to(n + 1);
        for (auto v : eg)
            from[v.fi].pb(v.se), 
            to[v.se].pb(v.fi);
        unordered_set<int> canin, canout;
        for (int i = 1; i <= n; i++)
            canin.insert(i), 
            canout.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 : canout)
                for (auto s : from[v])
                    if (in[s] == 0) {
                        assert(canin.count(s));
                        continue;
                    }
                    else eg.pb(mp(v, s));
            for (auto v : canin)
                for (auto s : to[v])
                    eg.pb(mp(s, v));
            shuffle(eg.begin(), eg.end(), x);
            if (eg.size() == 0) break;
            for (auto v : eg) {
                mx_ch--;
                if (in[v.se] && out[v.fi]) continue;
                if (LCT::fdr(v.fi) == LCT::fdr(v.se)) continue;
                if (in[v.se] || out[v.fi]) 
                    if (x() & 1) continue;
                if (!in[v.se] && !out[v.fi]) 
                    tot++;
                if (in[v.se]) {
                    LCT::cut(in[v.se], v.se);
                    canin.insert(v.se);
                    canout.insert(in[v.se]);
                    out[in[v.se]] = 0;
                    in[v.se] = 0;
                }
                if (out[v.fi]) {
                    LCT::cut(v.fi, out[v.fi]);
                    canin.insert(out[v.fi]);
                    canout.insert(v.fi);
                    in[out[v.fi]] = 0;
                    out[v.fi] = 0;
                }
                LCT::link(v.fi, v.se);
                canin.erase(v.se);
                canout.erase(v.fi);
                in[v.se] = v.fi;
                out[v.fi] = v.se;
            }
            if (tot == n - 1) {
                vi cur;
                for (int i = 1; i <= n; i++) 
                    if (!in[i]) {
                        int pl = i;
                        while (pl) {
                            cur.pb(pl), 
                            pl = out[pl];
                        }
                        break;
                    } 
                return cur;
            }
        }
        //failed to find a path
        return vi();
    }
}

int n,m,k;
vector<vector<int>> ans;
void solve(vector<pair<int,int>> ed){
	if(sz(ans)==k){
		for(auto p:ans){
			for(auto d:p){
				printf("%i ",d);
			}
			printf("\n");
		}
		exit(0);
	}
	auto an=hamil::work(n,ed);
	if(sz(an)==0)return;
	map<pair<int,int>,int> rm;
	for(int i=0;i<sz(an)-1;i++){
		rm[{min(an[i],an[i+1]),max(an[i],an[i+1])}]=1;
		rm[{max(an[i],an[i+1]),min(an[i],an[i+1])}]=1;
	}
	vector<pair<int,int>> ned;
	for(auto p:ed){
		if(!rm[p]){
			ned.pb(p);
		}
	}
	ans.pb(an);
	solve(ned);
	ans.pop_back();
}
int main()
{
	ios;
	cin >> n >> m >> k;
	vector<pair<int,int>> ed;
	for(int i=0;i<m;i++){
		int x,y;
		cin >> x >> y;
		ed.pb({x,y});
		ed.pb({y,x});
	}
	while(1)
	solve(ed);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

4 2 5 3 1 
2 3 4 5 1 

result:

ok OK (n = 5, m = 9)

Test #2:

score: 0
Accepted
time: 1866ms
memory: 218720kb

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:

3497 2834 2939 6649 5315 1142 3092 3136 7623 9661 1674 3436 7415 982 9602 4997 9736 1892 4545 535 6989 9135 9498 5294 7480 6250 6725 4079 1846 7344 8062 1486 6815 9613 6994 6125 8367 7115 8365 3283 980 3582 3230 1244 2765 9314 9540 1133 6515 3874 1340 2724 8003 4852 6638 7735 5624 6717 3422 9666 471...

result:

ok OK (n = 10000, m = 200000)

Test #3:

score: 0
Accepted
time: 1664ms
memory: 223224kb

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:

9240 9093 6649 995 792 5514 4104 4254 7387 2519 4019 7980 3770 4032 9526 1350 1196 1469 921 7110 3934 9512 1786 8644 3239 5371 2083 8687 8882 7804 8896 2788 6003 3987 1044 7504 5679 3922 9348 1924 9276 8905 2024 6488 8626 2525 5881 243 5984 7400 9053 9860 8091 5936 8899 4795 326 6345 2026 4451 7230 ...

result:

ok OK (n = 10000, m = 200000)

Test #4:

score: 0
Accepted
time: 1968ms
memory: 219052kb

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:

813 6186 1937 5600 9495 3239 595 6528 4822 7628 2450 7632 5433 7383 617 2900 673 8361 8609 1103 821 5002 3440 4059 1371 8936 3258 648 5640 500 6139 7368 3608 7677 5447 5422 8626 7665 8027 1351 234 982 3097 9034 3748 4649 5031 6936 4639 4540 7481 8832 2575 2351 7517 1080 9100 3549 5747 9088 2167 4174...

result:

ok OK (n = 10000, m = 200000)

Test #5:

score: 0
Accepted
time: 1986ms
memory: 219512kb

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:

2284 1620 4428 1827 9312 9505 8030 45 7191 265 9610 9262 6805 4203 9354 9814 1775 3289 5829 4491 4637 3985 6507 4494 1667 5138 7675 3680 7150 434 7938 8022 6904 3284 438 7501 9130 1354 7538 7940 1575 5636 3896 9613 4362 6237 5582 3437 6109 3809 7148 595 229 7142 3746 6309 7960 7797 4942 1829 7511 20...

result:

ok OK (n = 10000, m = 200000)

Test #6:

score: 0
Accepted
time: 1789ms
memory: 218228kb

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:

1850 5923 8286 3051 8814 3048 981 4635 2387 203 720 7088 5671 6116 878 9389 3911 5475 1401 6768 215 4850 7253 9484 7085 3435 1650 7819 1611 2118 9843 9887 8608 5999 6705 1252 3637 5138 3462 2642 1631 6677 152 3960 1935 7581 1848 2955 1414 9059 6634 5703 5341 4527 5242 8278 5225 1748 5885 7642 4972 4...

result:

ok OK (n = 10000, m = 200000)

Test #7:

score: 0
Accepted
time: 1674ms
memory: 219056kb

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:

1632 4560 5393 7276 1037 580 4607 8331 8078 3073 1495 9042 3286 8783 6953 7347 9237 9708 8906 169 934 7621 6315 4702 342 1853 5254 5995 3970 6275 1786 5205 9805 9452 1570 5319 3517 9 7900 3056 4293 925 5586 595 5210 2667 2598 6720 8613 6964 3123 652 2460 742 4399 9159 6920 3880 1082 8192 128 9936 93...

result:

ok OK (n = 10000, m = 200000)

Test #8:

score: 0
Accepted
time: 1903ms
memory: 218724kb

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:

8838 483 1827 3272 9340 2049 9969 5447 2692 5310 4758 7305 6690 5566 5801 9961 8880 3194 8722 4866 9131 7387 9781 5454 240 2162 5782 3338 8289 7794 5991 3100 8869 6246 6294 5684 3711 6162 8629 4732 444 4469 286 5543 5200 1582 2966 3875 5391 8533 172 2691 6668 8895 5403 7147 6464 5023 9356 7949 4743 ...

result:

ok OK (n = 10000, m = 200000)

Test #9:

score: 0
Accepted
time: 1980ms
memory: 218732kb

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:

7714 4027 2291 6306 8878 9474 798 176 6680 7562 8486 7522 6560 7044 4067 6123 7760 79 2251 3861 3174 8381 1598 5150 6438 6286 1728 5919 2407 5743 3660 9487 3864 6741 9048 2689 6381 450 6548 2278 4999 4719 6523 6909 561 5100 7979 6752 3391 108 302 9507 7837 3545 9168 6572 2473 3962 7864 4236 414 8344...

result:

ok OK (n = 10000, m = 200000)

Test #10:

score: 0
Accepted
time: 1727ms
memory: 218912kb

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:

197 7473 3673 9468 7472 8934 8534 2147 7792 7418 810 9546 8585 7538 4286 361 5047 5429 5225 9319 3852 3313 660 7320 2356 3717 5015 8510 4359 5809 7611 6631 2961 5502 6121 5244 4918 2040 5097 944 998 500 3955 5605 249 1940 471 496 9307 6940 924 3716 7637 4128 5108 737 3910 6785 1986 3999 761 4479 596...

result:

ok OK (n = 10000, m = 200000)

Test #11:

score: 0
Accepted
time: 1860ms
memory: 217864kb

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:

9896 5784 8536 3989 2440 5440 3539 1717 4996 5548 8161 3642 4012 5226 483 8838 2696 9177 9253 2689 7396 5219 6349 9114 9813 4917 9380 5031 1074 6088 7758 8181 5364 5285 5710 5485 5201 2173 1439 280 9936 5883 4841 1298 8393 5241 7159 4179 6307 2361 1489 2023 1761 8048 4424 8269 761 6252 6548 6193 597...

result:

ok OK (n = 10000, m = 200000)

Test #12:

score: 0
Accepted
time: 1963ms
memory: 217728kb

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:

4404 9657 9815 5881 6830 8502 5628 8093 4685 8356 5808 846 9933 9941 6106 4540 6527 7302 4178 4286 2109 1790 8222 8157 8596 2203 8818 7417 4046 5637 3449 7409 33 7017 7592 9658 2596 5027 6862 1708 5284 4571 829 4559 1542 1379 301 5222 51 3538 3377 6976 917 8374 9897 7799 1665 4880 9226 7176 8468 245...

result:

ok OK (n = 10000, m = 200000)

Test #13:

score: 0
Accepted
time: 1761ms
memory: 222048kb

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:

2201 7944 8958 5337 8630 177 9574 4715 4401 4318 6883 6280 1194 7883 8152 884 8503 9764 8180 6967 3510 2650 2906 5222 9336 5362 8693 2758 8133 1626 4644 646 4814 6078 4225 8325 8077 6071 4612 8362 8964 8696 9206 838 7227 7375 6771 2903 7704 1469 2398 8655 8790 9061 9139 1006 9953 3129 1059 1096 2199...

result:

ok OK (n = 10000, m = 200000)

Test #14:

score: 0
Accepted
time: 1940ms
memory: 221956kb

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:

7560 5755 2979 7564 9701 8131 1526 2718 1107 5787 9811 553 235 9731 1830 7992 9664 1812 6896 6809 1256 5931 8318 9871 9381 9146 4726 732 1432 2026 5528 6 2549 1302 4821 5884 9592 9634 5139 1564 291 2700 5427 2921 5873 3405 4068 6017 1974 9306 249 2296 1527 1834 4476 1908 588 4556 4070 1883 5157 9986...

result:

ok OK (n = 10000, m = 200000)

Test #15:

score: 0
Accepted
time: 1801ms
memory: 221472kb

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:

7045 4749 720 3816 118 1290 1195 1987 4044 3154 7391 5907 6656 4823 8319 9482 7500 9180 5778 7337 9353 6091 5597 7421 7295 3704 3326 3757 5485 8540 449 3561 7760 1258 9566 4697 9081 3079 2955 6948 4319 2857 82 5004 1548 9077 2194 6248 8063 1231 3826 6779 7145 3578 723 6144 2912 7702 4820 9797 4571 6...

result:

ok OK (n = 10000, m = 200000)

Test #16:

score: 0
Accepted
time: 1854ms
memory: 217460kb

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:

9901 5560 6141 2909 2243 3720 4158 4572 436 4780 2683 8954 6969 473 3487 6183 4815 9978 6522 6387 7720 3694 6290 2719 4695 2449 6499 3713 5256 2501 1524 2322 9450 8224 7395 2931 1264 9204 3666 6013 6333 8395 5513 665 1322 3430 2870 5508 9175 6934 5479 6224 9619 4145 6390 398 8320 5651 2386 2159 403 ...

result:

ok OK (n = 10000, m = 200000)

Test #17:

score: 0
Accepted
time: 1775ms
memory: 218572kb

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:

1479 6983 6289 7637 561 823 7085 2002 1184 1031 3404 8069 5420 8247 2991 9835 4113 8995 2631 5394 8168 6442 6577 5292 2373 4047 3877 601 4060 5032 2521 4580 1953 8592 1128 9028 6992 5886 5625 8177 9256 8263 668 7320 3916 4816 8593 8993 9289 5307 683 1411 7335 7014 5823 4794 3939 7502 8468 3540 6526 ...

result:

ok OK (n = 10000, m = 200000)

Test #18:

score: 0
Accepted
time: 1939ms
memory: 218228kb

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:

9063 7607 8356 1080 4325 8461 3280 6350 2652 1925 4172 2690 471 6195 6424 219 7294 4941 2268 3501 5933 8640 7733 1355 4756 9256 1243 1063 1083 9639 8824 4673 5025 7535 8978 8660 4767 6833 4918 1686 6713 7984 5438 9043 2330 1023 1747 9773 6573 5463 825 9825 1187 3749 5419 1877 3516 4643 5385 4389 664...

result:

ok OK (n = 10000, m = 200000)

Test #19:

score: 0
Accepted
time: 1940ms
memory: 218956kb

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:

4856 2059 4351 8543 1151 477 1850 7563 7096 3644 1337 8870 5190 5789 3956 5389 8399 2243 9071 6041 1003 6932 9699 1256 277 5713 5287 7344 8459 3703 8028 8615 7360 7584 2734 4643 428 1249 9853 9790 8987 9001 8695 1037 8547 5375 1701 729 4715 9322 2412 7507 3963 5873 3093 5714 9125 5442 814 1935 2594 ...

result:

ok OK (n = 10000, m = 200000)

Test #20:

score: 0
Accepted
time: 1720ms
memory: 218600kb

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:

1433 3453 6617 7680 4087 1277 2361 8565 8185 638 8773 8473 2807 7265 87 6278 1491 5467 8338 9478 5938 6017 1917 4362 2127 3168 481 8687 6085 2636 6378 7828 8840 5164 8522 5975 6711 9876 9467 6381 5071 1154 3460 7510 206 9879 899 2721 6052 1612 2876 3918 8132 1931 2639 7085 6933 4936 3425 1879 581 91...

result:

ok OK (n = 10000, m = 200000)

Test #21:

score: 0
Accepted
time: 2121ms
memory: 218528kb

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:

5165 5767 5091 1039 5019 5604 6210 388 8448 3238 9807 4044 5445 1600 4439 6549 2734 1555 5709 6556 3974 4754 564 8988 4057 5215 2870 105 4469 4145 306 3285 9217 8548 8997 7428 573 8 348 4740 8142 5505 6311 1631 5409 7946 5867 5960 207 5621 7450 152 2878 5086 8482 5092 2053 4516 4734 2910 7374 8757 4...

result:

ok OK (n = 10000, m = 200000)

Test #22:

score: 0
Accepted
time: 1784ms
memory: 219400kb

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:

1557 9220 9654 3285 8060 3339 9632 986 5786 5970 5233 8467 7589 9142 8716 8227 1969 1494 2556 5752 8835 3554 2603 1413 8273 4529 2189 3373 5609 8802 4270 9539 2310 7309 6785 9780 7435 2510 3745 7466 2457 9931 1878 4726 3441 2044 5025 6925 3231 5367 5542 122 4584 627 3489 6871 1324 3709 1923 1065 139...

result:

ok OK (n = 10000, m = 200000)

Test #23:

score: 0
Accepted
time: 1859ms
memory: 219608kb

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:

5782 2436 9167 4504 7968 2036 2542 2988 5235 2852 9519 1644 8628 262 2370 9941 3321 455 3236 9235 8861 575 193 4730 6596 691 6832 772 5043 1792 6297 7724 9529 2622 1160 8676 7204 8416 5566 729 2879 6945 6244 4125 6918 3669 9191 8931 9523 3346 456 5332 8425 3302 1692 1825 4271 5571 5147 5970 2294 432...

result:

ok OK (n = 10000, m = 200000)

Test #24:

score: 0
Accepted
time: 1838ms
memory: 219632kb

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:

6014 784 7192 3936 4678 8098 4927 702 3620 6791 6571 1870 6125 9046 9730 342 6006 3813 6701 6833 9467 3138 2835 1126 7517 2369 5449 4065 1147 2658 5317 1831 3718 2710 8086 1746 6903 705 2129 8814 4813 2476 5235 8955 4164 9661 1844 5279 4446 3594 5955 1745 1221 6686 5082 4732 4101 8539 4041 2761 8382...

result:

ok OK (n = 10000, m = 200000)

Test #25:

score: 0
Accepted
time: 1735ms
memory: 218832kb

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:

3989 9682 1335 440 2006 2696 7066 2340 9955 6027 8015 5340 7421 2973 2339 69 6144 9266 8581 6715 9800 9306 1877 4860 2774 3052 4683 895 637 2865 4931 9051 4826 7656 5481 166 1011 507 9151 2149 4587 3911 4298 9755 1390 8618 6831 9392 3568 6531 5936 467 871 204 6779 4571 6813 5740 9575 638 5465 4481 6...

result:

ok OK (n = 10000, m = 200000)

Test #26:

score: 0
Accepted
time: 1825ms
memory: 222612kb

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:

2923 627 2860 2372 5110 2397 2849 1345 1899 4194 4671 600 3610 4601 2304 6101 771 9391 7340 8404 2172 2733 6758 8613 1269 9394 4336 9275 506 5458 4574 8983 1522 753 3588 9625 6502 2135 9427 8333 783 374 1101 9693 4596 9613 5023 2490 1359 8222 6529 2133 7449 9635 857 7287 447 4291 1181 5534 3880 5042...

result:

ok OK (n = 10000, m = 200000)

Test #27:

score: 0
Accepted
time: 1966ms
memory: 219304kb

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:

1282 1765 8306 5994 6538 5993 5741 7299 2569 2396 2609 6907 6564 1950 2942 4831 5937 3023 5358 9374 527 5042 5152 9279 7977 6921 5058 6459 2419 4951 5108 4395 5547 5644 4474 6035 7370 3273 5253 2814 5778 2150 7807 232 5251 9690 5196 6403 6587 2513 3908 2092 6514 624 4125 7915 8574 6362 7550 6277 908...

result:

ok OK (n = 10000, m = 200000)

Test #28:

score: 0
Accepted
time: 1762ms
memory: 218120kb

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:

3364 3231 1565 9488 8812 9786 7407 8661 7950 7529 4583 6835 6603 9503 7926 6281 6111 2014 128 3303 6932 1300 9519 8985 2828 41 3482 2550 3158 6721 1411 6337 6883 5557 7813 4828 5858 5772 594 1009 3389 2693 9158 9723 2711 3564 6895 1837 1394 4228 1374 9404 2947 4639 9052 1798 9222 5668 1542 582 8953 ...

result:

ok OK (n = 10000, m = 200000)

Test #29:

score: 0
Accepted
time: 1926ms
memory: 219208kb

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:

8293 5975 2455 1904 1591 3446 2775 7983 7754 616 5383 6575 4459 6734 6714 6786 290 3366 6709 5908 4731 6129 9572 3248 5103 955 6877 5134 1307 7427 134 2604 3528 5892 8479 1696 3462 4747 4741 5345 8818 8243 2324 2282 2863 1768 9778 3468 1337 4203 383 8963 7768 9738 8902 5790 3013 4329 4307 7660 5394 ...

result:

ok OK (n = 10000, m = 200000)

Test #30:

score: 0
Accepted
time: 1817ms
memory: 217328kb

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:

5963 4458 7239 6256 1861 110 153 9950 5323 4252 3176 9313 7536 7570 1188 1865 5564 9571 2194 8092 5321 7013 9864 9316 7204 5293 261 4301 8511 5634 691 98 7284 2622 1708 1842 7116 8352 9160 7085 7492 2120 287 9700 319 6804 8637 2516 8096 7326 7293 2841 7151 6948 1699 2029 5977 2108 529 6438 4282 3995...

result:

ok OK (n = 10000, m = 200000)

Test #31:

score: 0
Accepted
time: 1981ms
memory: 219208kb

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:

5115 822 5365 6807 8895 1406 8338 4655 6248 2770 5084 7335 4993 9728 2143 6872 8323 1313 256 486 1816 9778 2279 1666 3282 7479 3155 30 8997 9410 4899 3518 1942 3956 9255 8229 5713 501 6496 2498 2250 1569 1106 1 3747 7190 3599 937 3228 6886 7028 3109 2151 7325 5732 3790 964 8723 7304 9224 8773 7879 6...

result:

ok OK (n = 10000, m = 200000)

Extra Test:

score: 0
Extra Test Passed