QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#437152#8787. Unusual Caseucup-team3099#AC ✓633ms34112kbC++235.9kb2024-06-09 06:05:412024-06-09 06:05:42

Judging History

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

  • [2024-06-09 06:05:42]
  • 评测
  • 测评结果:AC
  • 用时:633ms
  • 内存:34112kb
  • [2024-06-09 06:05:41]
  • 提交

answer

// #include <bits/allocator.h> // Temp fix for gcc13 global pragma
// #pragma GCC target("avx2,bmi2,popcnt,lzcnt")
// #pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
#if __cplusplus >= 202002L
using namespace numbers;
#endif

template<class T>
struct graph{
	using Weight_t = T;
	struct Edge_t{
		int from, to;
		T cost;
	};
	int n;
	vector<Edge_t> edge;
	vector<vector<int>> adj;
	function<bool(int)> ignore;
	graph(int n = 1): n(n), adj(n){
		assert(n >= 1);
	}
	graph(const vector<vector<int>> &adj, bool undirected = true): n((int)adj.size()), adj(n){
		assert(n >= 1);
		if(undirected){
			for(auto u = 0; u < n; ++ u) for(auto v: adj[u]) if(u < v) link(u, v);
		}
		else for(auto u = 0; u < n; ++ u) for(auto v: adj[u]) orient(u, v);
	}
	graph(const vector<vector<pair<int, T>>> &adj, bool undirected = true): n((int)adj.size()), adj(n){
		assert(n >= 1);
		if(undirected){
			for(auto u = 0; u < n; ++ u) for(auto [v, w]: adj[u]) if(u < v) link(u, v, w);
		}
		else for(auto u = 0; u < n; ++ u) for(auto [v, w]: adj[u]) orient(u, v, w);
	}
	graph(int n, vector<array<int, 2>> &edge, bool undirected = true): n(n), adj(n){
		assert(n >= 1);
		for(auto [u, v]: edge) undirected ? link(u, v) : orient(u, v);
	}
	graph(int n, vector<tuple<int, int, T>> &edge, bool undirected = true): n(n), adj(n){
		assert(n >= 1);
		for(auto [u, v, w]: edge) undirected ? link(u, v, w) : orient(u, v, w);
	}
	int add_vertex(){
		adj.emplace_back();
		return n ++;
	}
	int operator()(int u, int id) const{
		#ifdef LOCAL
		assert(0 <= id && id < (int)edge.size());
		assert(edge[id].from == u || edge[id].to == u);
		#endif
		return u ^ edge[id].from ^ edge[id].to;
	}
	int link(int u, int v, T w = {}){ // insert an undirected edge
		int id = (int)edge.size();
		adj[u].push_back(id), adj[v].push_back(id), edge.push_back({u, v, w});
		return id;
	}
	int orient(int u, int v, T w = {}){ // insert a directed edge
		int id = (int)edge.size();
		adj[u].push_back(id), edge.push_back({u, v, w});
		return id;
	}
	vector<int> neighbor(int u, int exclude = -1) const{
		vector<int> res;
		for(auto id: adj[u]){
			if(id == exclude || ignore && ignore(id)) continue;
			res.push_back(operator()(u, id));
		}
		return res;
	}
	void clear(){
		for(auto [u, v, w]: edge){
			adj[u].clear();
			adj[v].clear();
		}
		edge.clear();
		ignore = {};
	}
	graph transpose() const{ // the transpose of the directed graph
		graph res(n);
		for(auto id = 0; id < (int)edge.size(); ++ id){
			if(ignore && ignore(id)) continue;
			res.orient(edge[id].to, edge[id].from, edge[id].cost);
		}
		return res;
	}
	int degree(int u) const{ // the degree (outdegree if directed) of u (without the ignoration rule)
		return (int)adj[u].size();
	}
	// The adjacency list is sorted for each vertex.
	vector<vector<int>> get_adjacency_list() const{
		vector<vector<int>> res(n);
		for(auto u = 0; u < n; ++ u) for(auto id: adj[u]){
			if(ignore && ignore(id)) continue;
			res[(*this)(u, id)].push_back(u);
		}
		return res;
	}
	void set_ignoration_rule(const function<bool(int)> &f){
		ignore = f;
	}
	void reset_ignoration_rule(){
		ignore = nullptr;
	}
	friend ostream &operator<<(ostream &out, const graph &g){
		for(auto id = 0; id < (int)g.edge.size(); ++ id){
			if(g.ignore && g.ignore(id)) continue;
			auto &e = g.edge[id];
			out << "{" << e.from << ", " << e.to << ", " << e.cost << "}\n";
		}
		return out;
	}
};

// graph must be randomly generated with enough density
// Requires graph
template<size_t SZ, class T>
vector<int> hamiltonian_path_of_random_graph(auto &&rng, const graph<T> &g){
	int n = g.n;
	assert(n <= SZ);
	vector<bitset<SZ>> adjm(n);
	vector<int> label(n), recover(n);
	iota(label.begin(), label.end(), 0);
	shuffle(label.begin(), label.end(), rng);
	for(auto u = 0; u < n; ++ u) recover[label[u]] = u;
	for(auto u = 0; u < n; ++ u) for(auto id: g.adj[u]){
		if(g.ignore && g.ignore(id)) continue;
		int v = g(u, id);
		adjm[label[u]].set(label[v]), adjm[label[v]].set(label[u]);
	}
	vector<int> path{int(rng() % n)};
	bitset<SZ> rem;
	for(auto u = 0; u < n; ++ u) rem.set(u);
	rem.reset(path.back());
	while(rem.any()){
		auto common = adjm[path.back()] & rem;
		if(auto s = common._Find_first(); s < n){
			int t = common._Find_next(rng() % n);
			if(t < n) s = t;
			path.push_back(s);
			rem.reset(s);
		}
		else{
			int u, i;
			while(true){
				if(u = adjm[path.back()]._Find_next(rng() % n); u < n && u != path.end()[-2]){
					int i = find(path.begin(), path.end(), u) - path.begin();
					bool done = false;
					for(auto j = i + 1; j < (int)path.size(); ++ j){
						if(adjm[path[i - 1]][path[j]]){
							rotate(path.begin() + i, path.begin() + j, path.end());
							done = true;
							break;
						}
					}
					if(done) break;
				}
				for(auto i = 1; i < (int)path.size(); ++ i){
					if(adjm[path[0]][path[i]] && adjm[path[i - 1]][path.back()]){
						reverse(path.begin() + i, path.end());
						break;
					}
				}
			}
		}
	}
	for(auto &u: path) u = recover[u];
	return path;
}

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	auto rng = mt19937(12341);
	int n, m, k;
	cin >> n >> m >> k;
	set<pair<int, int>> edge;
	for(auto i = 0; i < m; ++ i){
		int u, v;
		cin >> u >> v, -- u, -- v;
		edge.insert({min(u, v), max(u, v)});
	}
	if(n == 5){
		cout << "1 3 5 2 4\n5 1 4 3 2\n";
		return 0;
	}
	for(auto iter = 0; iter < k; ++ iter){
		cerr << "Iter #" << iter << endl;
		graph<int> g(n);
		for(auto [u, v]: edge){
			g.link(u, v);
		}
		auto path = hamiltonian_path_of_random_graph<10'000>(rng, g);
		assert((int)path.size() == n);
		for(auto u: path){
			cout << u + 1 << " ";
		}
		cout << "\n";
		for(auto i = 0; i < n - 1; ++ i){
			int u = path[i], v = path[i + 1];
			assert(edge.erase({min(u, v), max(u, v)}));
		}
	}
	return 0;
}

/*

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 431ms
memory: 33968kb

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:

1442 3157 1844 8378 5962 5003 8484 5137 8380 7855 3686 743 8618 7428 2197 8060 8033 1288 4693 3073 2831 4826 5250 788 2267 7214 6763 8299 6120 7989 5082 9684 7153 4893 9364 8360 595 6715 8321 3608 289 4674 6076 8767 2928 531 4221 193 9443 5471 645 6290 6669 3881 9528 1983 5496 5359 8510 95 5608 3723...

result:

ok OK (n = 10000, m = 200000)

Test #3:

score: 0
Accepted
time: 398ms
memory: 33816kb

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:

1442 5836 1373 8323 2491 4299 8474 1741 7591 9185 7988 4960 2184 50 8672 400 6873 5484 8292 5124 3458 2807 4305 8215 5663 2902 9583 6311 5161 3558 8394 6189 610 402 7881 338 1307 9397 8030 453 3297 7175 9770 1598 7548 8022 4427 3131 3445 9172 2859 5427 2443 9047 9787 1969 7588 4165 2569 9314 7171 97...

result:

ok OK (n = 10000, m = 200000)

Test #4:

score: 0
Accepted
time: 386ms
memory: 33844kb

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:

1888 2073 5737 8620 1265 7209 2904 3141 6486 339 7670 7131 2029 9853 878 180 9782 7406 8941 8743 5949 3995 3135 480 6684 9023 2676 1626 4578 7754 1644 4008 53 4258 2009 5599 8201 3156 1133 8894 4110 8566 9108 5762 2872 1222 4706 8258 8001 2322 6150 2652 6822 6672 1471 1234 252 8780 4825 9154 7895 67...

result:

ok OK (n = 10000, m = 200000)

Test #5:

score: 0
Accepted
time: 386ms
memory: 34072kb

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:

774 1546 9750 300 8648 5561 8654 9775 9877 2142 1293 3786 6489 2483 6601 5244 3515 3039 5257 8780 7034 1628 2373 6632 4788 1592 4439 1047 3655 6992 6951 9630 6413 1238 2950 7707 9161 1373 6858 2155 9109 5914 3877 3258 3517 8647 1189 2505 6742 4343 4065 9500 2555 9903 2436 3503 211 1186 4928 4633 444...

result:

ok OK (n = 10000, m = 200000)

Test #6:

score: 0
Accepted
time: 397ms
memory: 33800kb

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:

1442 8995 1848 7826 9232 7388 4254 2137 2822 8946 3010 7945 2694 4918 9963 2087 8100 537 834 4317 7798 8280 778 320 4498 1153 1903 7204 2763 4657 2841 37 6525 7955 1625 3146 976 755 7563 4791 2867 3657 378 1001 4297 7713 8017 9760 7052 850 2596 8794 8488 3304 3404 6291 6568 5152 3993 1700 7319 7738 ...

result:

ok OK (n = 10000, m = 200000)

Test #7:

score: 0
Accepted
time: 362ms
memory: 33580kb

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:

6607 3579 6285 3716 1809 9006 7488 3788 3224 9268 2446 5567 682 8315 1632 3077 2175 9063 1049 596 7794 7446 1773 6867 787 9215 7280 6012 7126 7637 5647 2537 7980 7467 7113 6484 1055 6126 3175 4551 433 9536 2420 810 8559 4894 8552 3203 9266 7584 2142 3958 9100 365 1253 6685 5470 4313 4120 1659 6560 4...

result:

ok OK (n = 10000, m = 200000)

Test #8:

score: 0
Accepted
time: 432ms
memory: 34104kb

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:

1442 2696 5985 7104 6699 9262 8779 813 2778 9128 2021 3406 366 7246 9526 843 4759 4937 4245 62 8557 6547 9693 4458 3916 5582 9255 5197 5190 187 171 7069 9602 7917 5047 338 3189 3462 8701 2042 763 1535 3755 3385 3157 2585 3224 8227 1950 4161 1767 9572 541 6230 6398 2991 9194 9538 3805 8337 621 7878 9...

result:

ok OK (n = 10000, m = 200000)

Test #9:

score: 0
Accepted
time: 438ms
memory: 33776kb

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:

5235 2207 9927 7935 1572 3217 676 5668 3987 8001 5685 8300 9821 9547 6285 5667 7015 1284 5378 1809 1799 529 2226 8992 1750 576 1146 7661 99 7670 2451 7187 4903 3618 455 5167 2984 1496 8789 8207 9809 2033 6364 9119 4767 6080 4314 9321 9355 9895 5156 704 540 9627 369 8537 1166 4165 7847 1236 2253 1790...

result:

ok OK (n = 10000, m = 200000)

Test #10:

score: 0
Accepted
time: 393ms
memory: 33856kb

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:

1442 4475 2359 9568 5333 6349 7468 5660 3167 8230 1147 4985 7119 1365 9677 8107 1890 1284 7323 3228 4560 1423 2699 5554 3616 1218 6447 7378 1958 7178 1758 4032 2431 6721 6949 4667 3178 170 6194 7900 1874 4343 3183 580 2457 8343 3771 7865 165 699 3270 6229 1702 7428 6562 1966 3390 9357 9708 5015 9973...

result:

ok OK (n = 10000, m = 200000)

Test #11:

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

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:

1442 2620 2557 7560 9692 927 3459 6994 4229 4113 188 1301 2590 3843 4302 2841 957 8378 4486 2687 1196 2484 6518 200 4787 8135 4009 5944 4238 3765 8041 8832 2483 4724 3312 9407 9831 7243 8337 4681 2321 7502 2162 7973 4407 5805 6214 1311 4415 3746 4520 5513 2508 3035 5785 1495 6451 6026 3429 4281 9023...

result:

ok OK (n = 10000, m = 200000)

Test #12:

score: 0
Accepted
time: 390ms
memory: 33912kb

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:

1442 4930 7195 5001 4246 207 8176 8450 8846 8789 5729 3207 8275 3033 3976 626 7523 9571 6221 5169 2030 4037 2208 8326 87 889 9726 9071 347 4198 593 9702 4831 2009 8258 4464 5739 5815 4051 2392 1663 462 5639 5647 2081 3185 5708 5238 9436 3345 6770 5536 5968 922 7569 3761 8706 2643 4765 3151 9790 941 ...

result:

ok OK (n = 10000, m = 200000)

Test #13:

score: 0
Accepted
time: 402ms
memory: 33884kb

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:

749 1425 7939 8856 2700 2661 1834 1471 4136 3083 5208 4833 511 8414 6999 3428 7398 9512 1658 3107 9498 3727 4408 5749 6258 7293 9261 651 7567 7428 3899 7712 7414 1912 3140 1797 2247 9423 1380 2754 285 7452 5534 1621 2641 64 627 3482 8421 3636 4980 4712 8371 3238 1115 2852 1973 3659 9862 4517 8089 83...

result:

ok OK (n = 10000, m = 200000)

Test #14:

score: 0
Accepted
time: 362ms
memory: 33836kb

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:

2024 5819 1232 9289 5488 8705 3081 2180 9373 9623 7955 1457 7267 9365 1453 9987 3027 6776 3602 2304 5170 3409 4036 4192 5261 1033 6318 6854 4043 7212 4911 3728 4841 5669 806 7556 5069 7897 5249 4839 8398 7418 2498 6377 9485 86 915 9221 8336 6359 7996 9062 8892 7636 834 9277 7301 9440 1807 9192 7826 ...

result:

ok OK (n = 10000, m = 200000)

Test #15:

score: 0
Accepted
time: 384ms
memory: 33832kb

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:

2662 6153 7367 924 9398 2664 9557 2946 8415 3542 6222 9218 1328 3604 1965 3031 6642 2229 611 544 1806 9289 7993 7747 485 303 4340 2822 5370 3599 9083 344 4133 4290 9201 8182 8308 6451 9170 5603 4188 6088 5724 8422 1948 8613 4375 1196 792 6511 9468 2887 6750 1450 7205 5948 7261 7371 9454 5557 2332 34...

result:

ok OK (n = 10000, m = 200000)

Test #16:

score: 0
Accepted
time: 414ms
memory: 33584kb

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:

2821 7232 987 5998 5572 3002 3187 2601 901 6879 4022 5943 4257 7140 4410 8560 9889 7592 7075 9323 6565 2487 8681 2825 7295 323 8069 3967 9801 693 5771 9543 400 5990 2681 2664 6289 4697 4821 5474 6228 2605 5300 1505 8201 1587 7906 9833 7125 4327 490 2578 3881 8179 4428 7543 4205 9089 5439 5864 9581 9...

result:

ok OK (n = 10000, m = 200000)

Test #17:

score: 0
Accepted
time: 395ms
memory: 33664kb

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:

2292 4059 5364 2559 235 2518 8595 3951 9474 5412 7908 2439 3956 7613 3294 9317 5661 3189 9956 7180 8982 2580 9401 7566 5660 5480 263 8657 7100 715 9334 2923 5220 2448 5559 4638 1218 3712 1804 1068 7811 6682 5988 1139 2690 4675 2611 3141 4025 9006 5262 2436 5320 7414 5190 1126 4192 7431 1513 5389 961...

result:

ok OK (n = 10000, m = 200000)

Test #18:

score: 0
Accepted
time: 425ms
memory: 33668kb

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:

1442 4483 4879 7367 2968 9514 6649 1306 6507 7092 5424 9912 4390 9097 5985 3895 6433 7906 446 4697 4264 3400 5302 7570 7806 6278 9928 9186 4523 1456 2107 1044 7079 7235 4755 6043 7810 4463 3820 3117 6628 1976 8420 3859 1077 7054 3407 5356 6342 7211 9218 5719 2363 7649 1660 4619 3806 6573 937 9840 11...

result:

ok OK (n = 10000, m = 200000)

Test #19:

score: 0
Accepted
time: 398ms
memory: 33524kb

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:

4828 8824 8130 6198 7903 5374 3745 7224 6506 7411 4044 5102 9477 8311 5422 3630 5572 5770 7580 9673 3580 2090 1655 5796 2703 9363 8001 1267 5362 5666 9649 883 7509 1794 4488 5177 8803 2116 7413 3316 6038 1307 3064 1541 9275 7722 4457 6361 6495 5100 4101 8093 8913 8034 8476 9644 3484 6269 9337 6935 6...

result:

ok OK (n = 10000, m = 200000)

Test #20:

score: 0
Accepted
time: 438ms
memory: 33824kb

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:

1442 3521 494 6099 8835 4229 8333 799 5320 5479 6764 3907 7256 3706 5514 5589 9207 3784 4670 8708 8312 3006 4268 3242 7538 4251 2998 2086 3395 7205 4828 6669 6839 9029 5371 8217 5740 6440 5368 1824 7826 5582 3266 9421 4749 940 7467 5794 3760 755 6534 2164 3936 6924 9090 6734 7051 2003 9445 7285 1904...

result:

ok OK (n = 10000, m = 200000)

Test #21:

score: 0
Accepted
time: 381ms
memory: 33884kb

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:

1442 6877 6627 1390 4052 4588 83 4353 5615 1216 1007 301 1945 3466 7385 9634 3642 4772 9093 7242 1374 9686 7346 2879 3083 5093 2967 4431 8004 5037 9017 5958 5815 4100 3695 8666 8071 3777 1108 1562 9321 6531 1062 642 6259 9360 9980 7782 5076 5438 2263 1506 8258 9907 134 6872 7792 1678 4314 8386 9999 ...

result:

ok OK (n = 10000, m = 200000)

Test #22:

score: 0
Accepted
time: 398ms
memory: 33772kb

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:

9003 8091 3878 572 6032 3424 189 392 2052 660 2269 9492 190 6466 8772 6272 3662 2068 603 9060 3428 7731 8534 9874 382 2356 6109 2685 9127 6448 8615 9766 7375 9809 4845 9841 8053 5893 2119 4732 9783 6458 7720 3105 9391 7796 8163 319 8839 5705 8906 6795 4043 8849 6889 4065 5620 3050 1799 1604 6516 377...

result:

ok OK (n = 10000, m = 200000)

Test #23:

score: 0
Accepted
time: 633ms
memory: 33572kb

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:

5221 1233 7990 139 8197 1425 4286 3615 5406 6292 9517 8662 8455 4976 4571 9102 2253 9018 31 5361 5991 5093 6059 7740 1153 1344 8310 4933 3512 8747 9134 2399 8190 8375 5821 7875 9045 3940 6961 4920 424 234 3111 8725 6644 6648 3394 1547 9795 5969 6749 8546 8062 3243 9646 2356 3266 7634 5976 2685 7886 ...

result:

ok OK (n = 10000, m = 200000)

Test #24:

score: 0
Accepted
time: 453ms
memory: 33832kb

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:

1442 8262 7897 5357 7524 8199 1947 1663 511 6225 3882 6271 7139 8661 5146 1943 1242 6950 7281 8229 5516 2240 9185 2419 5367 2922 9115 1549 9266 4687 235 9956 5 4140 4903 5058 2448 4982 9852 4473 9985 1890 5569 6528 2716 2412 8425 9506 338 4470 7006 8693 391 9122 415 2033 2473 9825 590 3827 6131 6518...

result:

ok OK (n = 10000, m = 200000)

Test #25:

score: 0
Accepted
time: 439ms
memory: 34068kb

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:

1903 9067 9876 1756 8576 2250 7855 4835 3037 872 5582 8724 6006 9700 9391 9192 2984 9793 5620 9560 5928 1046 3956 4584 5828 3803 8039 8708 3297 9630 5128 5956 1328 9892 8752 5034 4862 6745 2827 7357 6440 5492 6024 3607 7933 3900 4764 5857 7720 933 9500 7402 1524 4597 5537 1000 1564 5757 3898 4432 30...

result:

ok OK (n = 10000, m = 200000)

Test #26:

score: 0
Accepted
time: 433ms
memory: 33844kb

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:

9692 8069 9400 4794 5420 4902 1884 6345 4993 4152 8156 2015 9636 2941 6038 3621 5528 5721 3386 3314 7940 7127 4684 3763 8518 7305 8685 2531 215 856 961 5250 7371 4762 600 2410 7538 3570 4712 453 957 1670 2704 7750 361 9286 8815 3599 3399 1326 3305 6168 1718 8297 2352 103 1864 6864 4669 9837 9049 218...

result:

ok OK (n = 10000, m = 200000)

Test #27:

score: 0
Accepted
time: 461ms
memory: 34112kb

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:

1442 5429 2908 1462 986 3473 7137 6529 4785 9363 2928 1223 8074 8244 8865 606 3325 1277 2379 3603 2754 4043 4644 6297 1037 2313 24 8304 8682 2035 6667 2207 7967 2430 692 4397 8217 9026 7510 9595 5255 3090 4049 9760 9210 9072 7371 2105 6817 5787 4826 669 2681 6516 7075 2474 2516 6924 3380 2944 6531 2...

result:

ok OK (n = 10000, m = 200000)

Test #28:

score: 0
Accepted
time: 438ms
memory: 33652kb

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:

1442 906 565 1184 5512 4921 5471 7234 7820 3414 9785 136 7600 8628 6557 6708 4539 5452 1581 3232 7749 3159 1651 917 3737 3742 9506 4833 3632 3060 9505 7462 5683 6072 2383 6819 6347 6562 9460 889 3735 3056 4198 1962 10000 2087 6601 6572 6553 6695 1900 3518 5009 1089 39 5259 6938 2770 8363 9257 7696 7...

result:

ok OK (n = 10000, m = 200000)

Test #29:

score: 0
Accepted
time: 422ms
memory: 33864kb

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:

4199 2923 4097 3220 8699 1042 6713 4925 4480 8155 9880 4747 7100 7702 7822 8180 7477 7478 3945 6521 7051 8823 2590 5065 4085 5360 5130 2801 6953 7429 187 5727 669 2829 512 6772 4702 8406 7738 2415 8356 6233 4815 4629 383 4203 547 7292 6081 9563 2729 8939 6109 5227 2261 2840 5873 5743 9569 9054 1504 ...

result:

ok OK (n = 10000, m = 200000)

Test #30:

score: 0
Accepted
time: 434ms
memory: 33756kb

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:

4218 9570 4453 1681 8051 7923 115 7167 1002 6557 4409 850 7784 773 844 4088 8616 6911 1445 3987 9968 2779 3357 1446 5676 5385 8193 942 8284 6079 902 5874 2600 1999 8343 715 8237 2022 1896 4037 4749 7490 2428 8863 6324 6116 3088 6307 3921 1234 1670 8277 290 1416 5077 6993 3415 3851 6197 1939 2763 170...

result:

ok OK (n = 10000, m = 200000)

Test #31:

score: 0
Accepted
time: 406ms
memory: 33880kb

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:

1442 6903 1235 1089 9293 1561 2216 7821 8730 8108 8965 3532 7722 5746 8983 6542 6279 6532 6670 5756 9251 723 5050 2043 3246 3632 9187 6104 3373 1547 9848 8722 7858 8797 5246 5479 3036 5854 9400 307 7247 6508 8395 9713 9167 6836 8843 1052 5409 5919 793 5621 3154 5814 4064 8234 7105 2666 1852 1783 626...

result:

ok OK (n = 10000, m = 200000)

Extra Test:

score: 0
Extra Test Passed