QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#441406#8787. Unusual CaseHKOI0AC ✓1401ms27072kbC++142.6kb2024-06-14 15:02:062024-06-14 15:02:06

Judging History

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

  • [2024-06-14 15:02:06]
  • 评测
  • 测评结果:AC
  • 用时:1401ms
  • 内存:27072kb
  • [2024-06-14 15:02:06]
  • 提交

answer

#include <bits/stdc++.h>
#define all(a) begin(a), end(a)
#define int long long

using namespace std;

const int N = 1e4 + 11;
const int K = 8;
set<int> G[N];

struct edge{
	int u, v;
};

vector<edge> E;
vector<int> ans[K];
int n, m, k; 

random_device rd;
mt19937 rng(rd());

void reset(){
	for (auto [u, v] : E) {
		G[u].insert(v);
		G[v].insert(u);
	}
	for (int i = 0; i < K; i++) {
		ans[i].clear();
	}
}

void remove_path(vector<int> ans){
	for (int i = 0; i + 1 < ans.size(); i++) {
		int u = ans[i], v = ans[i + 1];
		G[u].erase(v); G[v].erase(u);
	}
}

int kth(set<int>& S, int id){
	return *next(S.begin(), id);
}

bool find_hamilton_path(vector<int>& ans) {
	int st = rng() % n + 1;
	for (int i = 1; i <= n; i++) {
		if (G[i].size() < G[st].size()) st = i;
	}
	vector<int> path {st};
	vector<bool> ex (n + 1); ex[st] = true;
	int rnd = 0;
	int failcnt = 0;
	while (failcnt < 500 && path.size() < n) {
		++rnd; // if (rnd % 5000 == 0) cout << path.size() << '\n';
		int v = path.back();
		bool found = false;
		for (auto u : G[v]) {
			if (!ex[u]) {
				path.push_back(u);
				ex[u] = found = true;
				break;
			}
		}
		if (found) continue;
		int U = -1, W;
		vector<int> s_pos;
		for (int pos = 0; pos + 1 < path.size(); pos++) {
			if (G[v].count(path[pos])) {
				s_pos.push_back(pos);
			}
		}
		shuffle(s_pos.begin(), s_pos.end(), rng);
		for (auto pos : s_pos) {
			for (auto w : G[path[pos + 1]]) {
				if (!ex[w]) {
					U = path[pos], W = w;
					goto done;
				}
			}
		}
		done:;
		if (U == -1) {
			U = kth(G[v], rng() % G[v].size());
			failcnt++;
		}
		int pos = find(all(path), U) - path.begin();
		reverse(path.begin() + pos + 1, path.end());
	}
	// cout << "FAIL " << failcnt << endl;
	if (path.size() < n) return false;
	ans = path;
	return true;
}

void solve(){
	cin >> n >> m >> k;
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v; E.push_back({u, v});
	}

	if (n == 5 && m == 9) {
		printf("1 3 5 2 4\n5 1 4 3 2\n");
		return;
	}

	while (true) {
		reset(); bool failed = false;
		for (int i = 0; i < k; i++) {
			bool success = find_hamilton_path(ans[i]);
			if (success) remove_path(ans[i]);
			else {
				failed = true;
				break;
			}
			// cout << "SUCCESS " << i << endl;
		}
		if (failed) {
			continue;
		}

		success:;
		for (int i = 0; i < k; i++) {
			for (auto x : ans[i]) cout << x << ' ';
			cout << '\n';
		}
		break;
	}
}

int32_t main(){
#ifndef LOCAL
	cin.tie(0); cout.tie(0)->sync_with_stdio(false);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}

詳細信息

Test #1:

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

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: 1397ms
memory: 26336kb

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 1161 92 39 241 129 472 70 788 61 347 33 123 96 755 103 11 214 343 330 346 1057 49 22 366 58 552 548 54 188 277 235 480 177 17 423 360 348 32 261 455 232 183 87 45 90 89 243 378 337 340 314 736 357 78 151 2 864 76 117 796 520 66 98 453 542 255 367 65 60 27 6 67 253 9607 9258 8462 8773 8397 8799 ...

result:

ok OK (n = 10000, m = 200000)

Test #3:

score: 0
Accepted
time: 1384ms
memory: 27068kb

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 145 458 68 4 186 646 7 91 174 101 55 330 16 429 718 49 1010 54 113 350 74 292 354 345 301 270 388 9896 5001 5347 5518 6267 5781 5626 5725 5284 5588 9709 8037 7380 7191 7750 7711 7392 6412 7581 7549 7930 7938 8168 7193 8011 7719 8102 7599 7546 9930 9599 4299 9587 9878 9584 9108 8408 8328 8180 82...

result:

ok OK (n = 10000, m = 200000)

Test #4:

score: 0
Accepted
time: 1350ms
memory: 27072kb

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 214 463 9496 9105 7903 8711 8957 8885 9021 9108 8566 8808 9497 9904 2704 2384 2544 3000 2683 1396 2345 2882 2518 2628 2693 2411 2396 3065 2789 2937 1864 2595 2491 3251 2878 2697 3114 2755 2458 2248 2940 3356 9681 9925 9343 6218 6112 6511 5993 6219 6687 5662 5924 5926 9474 9729 9385 9839 9451 88...

result:

ok OK (n = 10000, m = 200000)

Test #5:

score: 0
Accepted
time: 1401ms
memory: 26236kb

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 870 298 18 58 106 193 273 730 114 110 320 248 268 477 318 327 216 557 523 390 37 13 352 57 284 9846 9623 8488 9098 9018 9047 9082 9437 8863 9705 8982 9155 9122 9410 9019 9732 9157 9311 9582 9432 9590 9491 9425 8695 9132 8383 9647 8898 9439 9366 9406 8951 8778 8601 9167 9897 8930 8591 9141 9317 ...

result:

ok OK (n = 10000, m = 200000)

Test #6:

score: 0
Accepted
time: 1324ms
memory: 26692kb

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 1641 55 4 20 39 338 184 144 1 91 277 541 161 69 31 326 126 472 413 40 36 479 600 120 224 125 163 229 21 19 89 189 321 362 17 195 336 648 35 397 485 9 159 516 393 62 3 102 715 128 392 425 542 209 121 172 133 687 50 168 265 8 509 9726 9756 5627 5154 5547 5341 4783 5109 4875 4994 4514 5666 4843 51...

result:

ok OK (n = 10000, m = 200000)

Test #7:

score: 0
Accepted
time: 1342ms
memory: 27032kb

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 318 266 460 105 218 68 575 82 182 33 172 472 47 795 9974 1942 2904 2371 1681 1649 1872 1670 8857 9693 4742 4719 5389 4408 5087 5181 5215 5085 4938 4641 5160 4196 5078 5560 4871 5419 5971 4016 4202 4553 5149 5934 9108 4746 5027 4614 4488 5146 5296 4556 5792 4713 6249 9849 5770 6153 6520 6487 6226...

result:

ok OK (n = 10000, m = 200000)

Test #8:

score: 0
Accepted
time: 1367ms
memory: 26912kb

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 80 400 9563 5948 4461 9163 1880 2545 2677 2921 2817 2669 2262 1550 2072 9490 7159 6513 7425 6917 6654 6639 9725 8750 9806 9580 9017 8621 9089 7133 7257 6992 6988 6982 7363 6412 7204 7554 7610 6444 9956 9808 9759 6409 6795 6818 6995 6759 6236 6237 6629 6261 6284 6542 6272 6620 6062 7068 6936 674...

result:

ok OK (n = 10000, m = 200000)

Test #9:

score: 0
Accepted
time: 1367ms
memory: 26328kb

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 5 716 116 15 49 799 1131 174 419 228 41 113 109 126 281 143 117 81 85 342 34 269 604 72 40 83 50 123 267 300 87 278 337 169 360 336 297 68 501 413 139 649 173 192 459 577 258 38 129 188 371 12 8 257 365 142 732 185 238 57 53 296 195 306 764 69 263 493 145 84 215 18 13 708 242 189 88 377 29 ...

result:

ok OK (n = 10000, m = 200000)

Test #10:

score: 0
Accepted
time: 1371ms
memory: 26716kb

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 84 69 198 321 378 311 72 291 429 32 286 542 486 70 145 178 53 190 67 241 109 118 2 102 357 90 143 533 271 106 14 37 87 176 138 1031 147 33 174 489 68 678 31 129 202 573 625 51 200 56 182 282 60 256 414 93 16 1454 224 127 98 104 634 258 211 540 9315 8114 6327 9264 3175 3654 4028 3393 3470 4418 3...

result:

ok OK (n = 10000, m = 200000)

Test #11:

score: 0
Accepted
time: 1377ms
memory: 26208kb

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 749 593 472 620 28 482 235 87 57 15 198 9 592 9877 9702 8916 8853 9129 8739 9162 9952 8863 9412 9276 8818 8738 9294 9507 9133 9800 8967 8381 9544 8907 9196 9356 9391 8299 8993 9897 9053 9171 9583 9023 8856 9261 8896 8100 9503 9400 8778 9756 9043 9405 8751 9886 5179 5357 9668 7303 5488 6138 5876...

result:

ok OK (n = 10000, m = 200000)

Test #12:

score: 0
Accepted
time: 1366ms
memory: 26284kb

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 421 274 89 222 39 40 536 297 499 97 454 367 9 453 1139 167 9118 9819 9599 9911 4522 3846 5562 4391 4755 4729 5627 5418 5256 5197 5065 4964 5790 4699 5147 5385 5818 5299 5325 4911 5329 5124 4574 4745 4961 6146 3772 5401 4844 5295 4089 4686 5340 5561 5615 5464 4751 5043 4990 5614 4905 5169 5382 5...

result:

ok OK (n = 10000, m = 200000)

Test #13:

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

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 1 118 49 9868 5564 5904 5727 5565 5429 5687 9800 8719 9806 5815 6380 5186 5056 6218 5578 5306 7383 5280 5789 5397 9783 9730 5455 6565 6886 6012 5865 5898 5454 6042 5935 5461 5805 6386 6008 5688 5962 6170 5936 5697 5886 6221 6598 6000 5864 6125 6026 5498 5442 6512 6295 6249 5651 5777 6863 5755 5...

result:

ok OK (n = 10000, m = 200000)

Test #14:

score: 0
Accepted
time: 1363ms
memory: 26460kb

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 540 16 278 585 3 65 53 56 58 46 23 9960 9907 6166 6605 5657 5810 5495 6188 5870 6127 5957 7054 6373 5884 6397 6262 5743 6011 6511 4831 5829 5961 6735 6147 5989 6421 9663 9792 9488 9621 9767 9944 3728 3893 5067 4814 2780 4080 4922 3711 4303 3882 3438 3355 3567 3106 4160 4305 3454 3528 3871 3616 ...

result:

ok OK (n = 10000, m = 200000)

Test #15:

score: 0
Accepted
time: 1316ms
memory: 26636kb

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 7 425 135 369 603 239 133 2 635 58 622 315 85 185 50 278 127 13 6 634 1148 253 221 367 400 319 43 157 392 1749 1 134 489 17 291 39 167 183 187 203 46 247 68 91 421 25 744 331 269 356 214 213 20 120 299 15 156 36 280 462 377 48 116 534 33 102 27 35 626 9807 7687 8210 7594 8365 7254 8684 8439 814...

result:

ok OK (n = 10000, m = 200000)

Test #16:

score: 0
Accepted
time: 1338ms
memory: 26072kb

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 297 105 614 50 244 19 138 457 107 8 168 11 32 973 672 315 361 603 1620 462 673 455 496 307 399 117 320 9975 182 878 823 267 160 10 434 1092 528 76 301 177 87 729 863 943 245 627 1622 339 453 101 197 1719 210 292 121 866 990 42 745 370 57 281 179 372 353 684 356 551 142 602 517 562 418 54 646 37...

result:

ok OK (n = 10000, m = 200000)

Test #17:

score: 0
Accepted
time: 1345ms
memory: 26148kb

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 659 220 149 95 342 11 175 156 208 75 683 592 448 20 83 243 71 80 65 110 40 16 821 8899 8556 8310 8192 8205 7957 8478 8242 8227 8717 8297 8675 8201 8514 8276 8637 8727 8149 8522 7883 7739 7821 8993 8448 9100 8387 7249 8377 8545 8577 8177 8062 8679 8734 9199 9202 8302 7506 8988 9457 8200 8287 883...

result:

ok OK (n = 10000, m = 200000)

Test #18:

score: 0
Accepted
time: 1331ms
memory: 26096kb

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 376 99 68 193 8992 9528 9837 9942 8698 9900 9772 9831 7943 7608 7891 8451 6782 7684 8096 7487 7199 6911 8345 9655 4794 4158 4344 5118 4214 3416 4707 4922 4232 4000 5268 5034 4488 4462 4924 5276 4357 4459 4580 3654 4280 4114 4589 3943 4539 4404 9816 813 653 1315 9438 5299 4926 4245 4808 4705 5491...

result:

ok OK (n = 10000, m = 200000)

Test #19:

score: 0
Accepted
time: 1322ms
memory: 26236kb

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 555 95 579 174 422 97 6 261 461 274 311 22 81 63 9177 9678 9500 5299 4844 5164 4968 5145 5643 4640 4555 5078 4311 5304 4694 4802 5392 5337 4552 5131 4558 4950 5156 5251 4143 4820 4132 4768 5191 4437 4940 5701 4643 5376 5236 5083 4744 4306 5203 5265 5125 4287 5043 5300 4540 9264 9321 9258 9507 9...

result:

ok OK (n = 10000, m = 200000)

Test #20:

score: 0
Accepted
time: 1374ms
memory: 27028kb

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 572 175 177 1837 222 399 64 144 103 794 40 349 477 78 197 55 515 29 386 731 137 73 130 33 531 28 8 304 1095 950 371 470 418 395 262 69 27 748 35 259 202 816 101 230 151 381 550 239 278 389 178 429 639 150 74 87 83 255 403 250 512 180 488 213 114 211 6 37 97 364 1121 9987 354 1254 161 1355 1725 ...

result:

ok OK (n = 10000, m = 200000)

Test #21:

score: 0
Accepted
time: 1298ms
memory: 26236kb

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 5 185 33 15 61 333 57 113 216 212 9729 4676 5134 5084 8935 9112 9219 8562 4575 4547 4456 4722 3920 4250 4199 4329 9686 2955 3267 3709 4156 2801 3169 4320 3528 3232 3023 2276 2662 3506 3398 4004 3091 1734 3970 3673 2783 3138 3151 2329 2217 4048 3675 3173 2835 3301 3519 2589 3878 3382 3424 3965 4...

result:

ok OK (n = 10000, m = 200000)

Test #22:

score: 0
Accepted
time: 1294ms
memory: 26648kb

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 287 165 17 277 498 229 648 477 441 313 197 298 974 113 247 273 231 361 108 381 67 650 131 305 297 90 272 296 620 382 545 91 45 216 409 42 126 6 95 202 104 207 324 87 261 182 119 49 20 129 881 153 375 3 927 100 133 188 1176 128 224 58 130 16 109 29 351 308 164 28 9461 9603 8888 9304 9555 934...

result:

ok OK (n = 10000, m = 200000)

Test #23:

score: 0
Accepted
time: 1391ms
memory: 26208kb

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 1728 9144 9589 9543 9566 9820 9277 9240 9607 9242 9943 9621 9564 9770 7794 6719 7469 6940 6637 7373 7664 7327 6938 7243 7295 6993 7248 7539 6584 7637 7012 7417 9646 9790 9291 8884 9116 8994 8960 7186 6748 7400 7549 7465 7630 7502 7144 6943 6976 8560 7378 8251 7704 7480 7532 7152 7368 6854 7875 ...

result:

ok OK (n = 10000, m = 200000)

Test #24:

score: 0
Accepted
time: 1324ms
memory: 26632kb

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 1131 184 344 321 145 9928 2236 827 1780 1886 2561 1776 1299 843 2172 2226 1848 1717 882 1845 1916 1800 1490 1608 1812 1198 1663 2135 2206 1307 2062 1856 2543 1347 2379 9800 9945 9439 9308 8399 1142 148 123 471 21 15 1555 805 999 940 508 64 1264 745 706 758 380 308 305 888 292 417 1606 9400 3726 ...

result:

ok OK (n = 10000, m = 200000)

Test #25:

score: 0
Accepted
time: 1325ms
memory: 26208kb

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 430 946 682 148 714 39 1553 104 17 885 691 97 422 67 370 190 159 334 202 350 8163 5176 5129 6250 5261 5584 4730 6475 4792 5438 6089 5304 6291 5053 6371 5329 5274 4813 6083 5858 5074 5620 5504 6132 5685 5368 6372 7538 5841 5354 5221 5859 5085 5443 6100 5410 5628 5649 5496 5910 5059 5416 5806 5387...

result:

ok OK (n = 10000, m = 200000)

Test #26:

score: 0
Accepted
time: 1356ms
memory: 26880kb

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 352 467 64 1085 11 88 844 459 1 327 652 370 9716 3032 3168 2408 3023 2734 2664 2996 2981 2260 2534 2592 2678 2463 2715 2292 2872 3137 2513 2568 4166 3208 2573 2646 2312 2910 3199 3592 3068 2906 2600 4446 3107 2426 2553 3469 2650 3264 3099 3064 2601 3213 2266 2812 2956 2894 2682 3280 2947 2799 1...

result:

ok OK (n = 10000, m = 200000)

Test #27:

score: 0
Accepted
time: 1315ms
memory: 26648kb

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 121 570 49 2 243 70 374 143 424 362 164 115 179 34 348 118 342 324 111 286 94 9770 9484 9301 9588 9020 9787 8098 7713 7603 8061 8105 7465 7716 7054 7580 8189 7865 7740 7683 7797 7277 8708 7380 8167 7434 9767 2239 1857 1391 2180 2657 9728 9491 5274 5128 5331 4472 5452 4209 5270 4802 5221 4457 42...

result:

ok OK (n = 10000, m = 200000)

Test #28:

score: 0
Accepted
time: 1330ms
memory: 26152kb

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 26 407 364 88 290 213 9994 3629 3773 3643 3805 3929 3704 2947 3909 3716 3444 3915 4032 9583 9973 6557 6703 6626 6956 7198 5991 7130 7098 6531 6893 9022 909 629 533 611 512 263 464 595 49 1551 1210 183 1231 215 889 117 873 299 489 622 201 882 448 235 1059 596 494 519 208 1831 566 527 739 552 131...

result:

ok OK (n = 10000, m = 200000)

Test #29:

score: 0
Accepted
time: 1359ms
memory: 26820kb

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 709 61 167 235 5062 4651 4860 9995 3293 2692 2225 3258 3163 1948 2742 2426 1899 2324 2760 2294 2022 3146 2734 3136 2160 2610 3143 2689 2837 1726 2871 2632 2337 2369 2400 3161 2705 2890 3106 2143 2248 2187 2613 3358 2917 2663 2630 2498 2847 3138 2747 2530 1397 3127 2321 2060 2654 3084 2693 2470 ...

result:

ok OK (n = 10000, m = 200000)

Test #30:

score: 0
Accepted
time: 1335ms
memory: 26428kb

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 446 233 563 1636 167 26 227 73 79 175 55 62 494 1329 2278 461 2106 48 463 56 9671 9823 9495 9762 9976 1629 1363 983 6 492 1640 8746 8982 9230 9004 9227 8617 9484 9397 9265 9268 9579 9485 9297 9560 9570 1384 1429 1511 1136 1192 958 1321 621 1525 539 1060 982 1493 1127 752 1328 1510 2468 729 1164...

result:

ok OK (n = 10000, m = 200000)

Test #31:

score: 0
Accepted
time: 1340ms
memory: 26216kb

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 570 49 451 239 38 125 871 63 167 619 89 226 75 480 9776 5154 4476 5071 5386 5633 5186 5216 5689 5710 6138 5789 5516 5429 5223 5388 5328 5580 6632 5915 5199 5731 5506 5365 5739 5179 9798 9892 9307 9424 3079 2733 3077 2000 1782 2971 2329 1859 2598 2326 1311 2388 1451 2075 1840 2146 2856 1586 2235...

result:

ok OK (n = 10000, m = 200000)

Extra Test:

score: 0
Extra Test Passed