QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#436054#8787. Unusual Caseucup-team3586#AC ✓2927ms33948kbC++234.3kb2024-06-08 23:06:312024-06-08 23:06:32

Judging History

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

  • [2024-06-08 23:06:32]
  • 评测
  • 测评结果:AC
  • 用时:2927ms
  • 内存:33948kb
  • [2024-06-08 23:06:31]
  • 提交

answer

//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
mt19937_64 rnd(1919810);
int n=10000,m=200000,k=8;
vector<int> G[10005];
int u[200005],v[200005];
bool used[200005];
bool vis[10005];
map<pii,int> Mp;
int ls[10005],rs[10005],siz[10005];
int fa[10005];
ull prior[10005];
bool tag[10005];
inline void pushdown(int x)
{
	if(tag[x])
	{
		tag[ls[x]]^=1;
		tag[rs[x]]^=1;
		tag[x]=0;
		swap(ls[x],rs[x]);
	}
}
inline void pushup(int x)
{
	fa[ls[x]]=fa[rs[x]]=x;
	siz[x]=siz[ls[x]]+siz[rs[x]]+1;
}
int merge(int x,int y)
{
	if(!x||!y) return x^y;
	if(prior[x]>prior[y])
	{
		pushdown(x);
		rs[x]=merge(rs[x],y);
		pushup(x);
		fa[x]=0;
		return x;
	}
	else
	{
		pushdown(y);
		ls[y]=merge(x,ls[y]);
		pushup(y);
		fa[y]=0;
		return y;
	}
}
void split(int x,int s,int &a,int &b)
{
	if(!x)
	{
		a=b=0;
		return ;
	}
	pushdown(x);
	if(s>=siz[ls[x]]+1)
	{
		a=x;
		split(rs[x],s-siz[ls[x]]-1,rs[a],b);
		pushup(a);
		fa[a]=fa[b]=0;
	}
	else
	{
		b=x;
		split(ls[x],s,a,ls[b]);
		pushup(b);
		fa[a]=fa[b]=0;
	}
}
int findr(int x)
{
	pushdown(x);
	if(rs[x]) return findr(rs[x]);
	return x;
}
int findr2(int x)
{
	pushdown(x);
	if(siz[x]<2) return 0;
	if(siz[rs[x]]>=2) return findr2(rs[x]);
	if(siz[rs[x]]==1) return x;
	return findr(ls[x]);
}
int rt;
inline int getpos(int x)
{
	vector<int> seq;
	seq.pb(x);
	while(seq.back()!=rt)
		seq.pb(fa[seq.back()]);
	rev(seq);
	for(auto xx:seq)
		pushdown(xx);
	int ret=0;
	ret+=siz[ls[x]];
	while(fa[x])
	{
		int tmp=x;
		x=fa[x];
		if(tmp==rs[x])
			ret+=siz[ls[x]]+1;
	}
	return ret;
}
int lst;
void print(int x)
{
	pushdown(x);
	if(ls[x]) print(ls[x]);
	cout<<x<<" ";
	if(rs[x]) print(rs[x]);
}
void printr(int x)
{
	pushdown(x);
	if(ls[x]) printr(ls[x]);
	cerr<<x<<" ";
	if(rs[x]) printr(rs[x]);
}
void clear(int x)
{
	pushdown(x);
	if(ls[x]) clear(ls[x]);
	if(lst!=-1)
		used[Mp[mp(x,lst)]]^=1;
	lst=x;
	if(rs[x]) clear(rs[x]);
}
int main()
{
	// freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// for(int i=1;i<=m;i++)
	// {
	// 	int u=rnd()%n+1;
	// 	int v=rnd()%n+1;
	// 	while(u==v) v=rnd()%n+1;
	// 	::u[i]=u;
	// 	::v[i]=v;
	// 	if(u==v||Mp[mp(u,v)])
	// 	{
	// 		used[i]=1;
	// 		continue;
	// 	}
	// 	Mp[mp(u,v)]=Mp[mp(v,u)]=i;
	// }
	cin>>n>>m>>k;
	for(int i=1;i<=m;i++)
	{
		cin>>u[i]>>v[i];
		if(u[i]==v[i]||Mp[mp(u[i],v[i])])
		{
			used[i]=1;
			continue;
		}
		Mp[mp(u[i],v[i])]=Mp[mp(v[i],u[i])]=i;
	}
	int Lst=0;
	for(int i=0;i<min(k,8);i++)
	{
		for(int j=1;j<=n;j++)
		{
			fa[j]=0;
			ls[j]=rs[j]=0;
			siz[j]=1;
			prior[j]=rnd();
			tag[j]=0;
		}
		for(int j=1;j<=n;j++)
			G[j].clear();
		memset(vis,0,sizeof(vis));
		for(int j=1;j<=m;j++)
			if(!used[j])
			{
				G[u[j]].pb(v[j]);
				G[v[j]].pb(u[j]);
			}
		int st=rnd()%n+1;
		rt=st;
		vis[st]=1;
		int Cnt=0;
		int Lst=-1;
		while(siz[rt]!=n)
		{
			tag[rt]^=1;
			Cnt++;
			int x=findr(rt);
			int x2=findr2(rt);
			shuffle(ALL(G[x]),rnd);
			if(Cnt>300000)
			{
				break;
			}
			bool fl=0;
			for(auto y:G[x])
			{
				if(!vis[y])
				{
					fl=1;
					Lst=-1;
					vis[y]=1;
					rt=merge(rt,y);
					fa[rt]=0;
					used[Mp[mp(x,y)]]^=1;
					break;
				}
				else if(y!=x2&&y!=Lst)
				{
					fl=1;
					Lst=y;
					int pos=getpos(y);
					int A,B;
					split(rt,pos+1,A,B);
					fa[A]=fa[B]=0;
					tag[B]=1;
					used[Mp[mp(x,y)]]^=1;
					rt=merge(A,B);
					fa[rt]=0;
					used[Mp[mp(findr(rt),y)]]^=1;
					break;
				}
			}
			if(!fl)
				break;
		}
		if(siz[rt]!=n)
		{
			lst=-1;
			clear(rt);
			i--;
			continue;
		}
		lst=-1;
		print(rt);
		cout<<'\n';
	}
	return 0;
}

詳細信息

Test #1:

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

input:

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

output:

2 4 1 5 3 
2 5 4 3 1 

result:

ok OK (n = 5, m = 9)

Test #2:

score: 0
Accepted
time: 2318ms
memory: 33720kb

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:

6518 3811 8520 4936 290 6408 7913 5360 5609 5681 745 7847 406 244 1767 8667 8373 5022 8427 6067 3912 3214 9510 3653 3068 6798 9632 7545 5449 9502 9167 4905 7323 762 3937 8315 2458 9414 538 2940 7691 3899 9370 3758 8249 4525 9497 5551 5098 8024 5524 2661 6292 9974 1229 5941 6241 2093 7221 4941 7228 3...

result:

ok OK (n = 10000, m = 200000)

Test #3:

score: 0
Accepted
time: 2283ms
memory: 33716kb

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:

1109 3948 8516 4688 8724 4465 624 419 2478 7179 4120 1809 9949 682 3384 9909 9426 2929 3258 7616 98 3973 5727 2006 1819 2462 2914 9288 779 5823 7947 1793 8022 817 1380 5565 9229 2904 8073 9320 6226 3369 2817 1050 4760 1723 6758 1705 4712 4463 3287 1913 4177 7625 5346 3335 8881 4026 9819 6684 2348 66...

result:

ok OK (n = 10000, m = 200000)

Test #4:

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

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:

663 98 416 863 7867 8336 5681 1006 7617 8179 1423 7859 6572 7182 7190 806 5886 3408 6904 9081 3555 3249 5987 7352 7654 2316 2436 4182 493 1732 548 581 1273 2660 8737 4161 3557 2050 8413 5805 7770 3746 5912 9865 7228 8088 5756 8911 3237 886 2927 8741 7701 4097 4518 7434 8046 8804 5120 4431 8166 8111 ...

result:

ok OK (n = 10000, m = 200000)

Test #5:

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

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:

4555 7641 4647 9492 1693 6656 7112 9801 107 9449 7153 1301 7746 6742 7221 2317 2157 7673 4381 767 6142 6832 5049 5005 3470 5971 3674 1046 5024 1165 3965 2246 5036 3291 3284 8369 6825 8118 1843 2719 9813 7104 1531 7909 3669 5433 1357 777 9954 7577 2273 81 4895 58 2632 8362 4959 355 2909 8052 5612 170...

result:

ok OK (n = 10000, m = 200000)

Test #6:

score: 0
Accepted
time: 2575ms
memory: 33696kb

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:

5052 7998 553 8027 3142 9155 8383 5390 815 9427 3176 5334 6562 2499 8130 3356 4142 5615 158 5224 818 5596 2739 9701 2815 6139 5439 7301 3707 9957 1841 7805 1895 8105 4376 6869 2453 3849 1075 4635 1916 6096 6486 2325 1243 4606 194 5583 7862 2968 6174 7312 3619 9522 8651 7506 2662 5707 7573 6218 1184 ...

result:

ok OK (n = 10000, m = 200000)

Test #7:

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

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:

2078 5339 3354 991 501 9842 2570 1128 2664 9891 5604 9200 4689 7927 6345 2123 7412 4900 6798 1603 3039 280 161 9063 1662 4183 3555 6682 7774 7042 8970 2214 784 6920 4590 1986 7579 6643 7199 9118 216 2196 41 6275 5935 2207 6407 8582 9436 8873 6675 5369 3968 5816 7062 6985 1020 8670 6497 8509 6615 112...

result:

ok OK (n = 10000, m = 200000)

Test #8:

score: 0
Accepted
time: 2068ms
memory: 33720kb

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:

9674 851 7124 8732 9853 6238 3270 2031 7726 3035 8604 5950 5209 1094 4354 5662 866 7589 3100 9488 4870 8820 4060 5043 6757 2934 3023 2341 8693 3213 8885 7621 7417 4410 572 982 1773 5737 3907 1228 9673 6224 7901 8684 1203 5186 892 5091 2179 7319 1563 7841 6890 1342 937 5300 3506 8931 9657 3827 5578 7...

result:

ok OK (n = 10000, m = 200000)

Test #9:

score: 0
Accepted
time: 2300ms
memory: 33900kb

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:

7513 9975 2494 5571 9915 8975 5894 4630 2170 9436 7855 1467 4433 3324 6461 4652 8062 8418 8678 414 7036 4533 8838 1273 2833 4761 5684 2717 3436 4410 9656 7126 804 8089 6290 8079 8297 9139 4838 6431 8309 9183 6989 580 3039 4416 5494 8441 8358 6358 1982 6018 3936 5809 2323 9177 899 7901 2495 2294 2619...

result:

ok OK (n = 10000, m = 200000)

Test #10:

score: 0
Accepted
time: 2268ms
memory: 33712kb

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:

766 4658 934 9626 6004 32 9727 1794 463 2075 4521 2633 5615 5242 223 1246 6114 3740 3665 3331 6353 4152 5795 7842 2143 1874 6351 2683 6889 3980 6095 5094 4929 676 9796 4766 9697 4391 9591 5684 3753 3210 1815 8218 232 3612 3572 4663 3697 1348 2193 2764 6861 1179 8254 5955 6151 3644 5296 7064 5731 185...

result:

ok OK (n = 10000, m = 200000)

Test #11:

score: 0
Accepted
time: 2108ms
memory: 33888kb

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:

1242 8071 2350 1314 7660 471 5567 124 2792 1283 5512 6026 1775 3383 1212 722 8646 9053 346 2932 2916 778 4458 9325 9054 2751 2015 4848 1702 4239 1117 163 3276 1387 8099 6122 6562 5578 4143 8451 6431 2097 3488 6418 849 6346 8027 6056 3477 1469 3671 3881 333 9067 62 1744 4238 4029 7442 542 7988 2791 2...

result:

ok OK (n = 10000, m = 200000)

Test #12:

score: 0
Accepted
time: 2480ms
memory: 33944kb

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:

9759 2175 9820 5109 3065 6592 3376 3227 1075 8788 9274 71 6401 427 3527 4625 930 5572 4821 5794 9993 3958 4023 3890 2186 2745 1741 8408 9841 8920 3560 3913 9612 6982 6040 7255 6829 5294 7318 8885 6024 1163 5255 7141 2827 8509 2762 116 3307 1173 6522 5665 6588 7801 309 2106 2438 1261 9766 7829 5061 1...

result:

ok OK (n = 10000, m = 200000)

Test #13:

score: 0
Accepted
time: 2105ms
memory: 33704kb

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:

5243 4514 1075 8187 870 5710 1631 9051 194 8588 9104 1529 9952 1765 536 6152 3441 7329 9768 2985 7184 3334 2734 4293 2430 6618 4179 284 6999 1163 4953 9931 3283 9362 2252 20 228 7996 3361 1004 2695 7603 6427 1793 1752 6092 9501 1012 1422 8175 4580 9636 9573 3155 5468 6602 6004 5308 2706 6216 6896 93...

result:

ok OK (n = 10000, m = 200000)

Test #14:

score: 0
Accepted
time: 2172ms
memory: 33644kb

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:

3031 2044 9205 4045 5065 3501 8105 1251 1733 1565 7990 3582 1608 8748 9382 8137 8388 4480 2885 7985 5085 2456 1927 4948 6450 3709 7531 5680 7938 7555 6509 7557 9799 1759 6345 4249 5905 4247 1561 5180 2919 8924 7218 2583 1549 5653 8933 8278 4197 7388 1871 4898 4484 9855 7823 7051 5262 6643 7072 833 8...

result:

ok OK (n = 10000, m = 200000)

Test #15:

score: 0
Accepted
time: 2300ms
memory: 33712kb

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:

5920 2989 8262 5664 9440 3837 6412 2604 9144 2186 3524 7194 2786 9789 8573 4809 580 831 9790 5760 9646 9076 4209 7276 6742 2409 7446 5392 9384 3814 8692 3053 9222 4090 1537 9675 2141 2606 3117 2798 9455 8583 6405 7083 4324 1096 5439 6605 7540 5780 5129 4646 24 7910 5417 7717 6012 6488 7339 5500 6697...

result:

ok OK (n = 10000, m = 200000)

Test #16:

score: 0
Accepted
time: 2081ms
memory: 33632kb

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:

5405 4878 999 2829 6469 3642 1117 2740 6345 5385 6640 7047 3122 3733 6885 6601 1584 8932 7378 26 8141 2885 2490 5945 3317 2053 8630 4432 1916 8353 2038 1558 1645 3411 4509 4481 4116 3055 9775 8816 3074 568 1578 8064 2762 6947 5360 5693 6602 5845 6098 5164 5346 838 2818 3191 7160 3996 9254 5216 2170 ...

result:

ok OK (n = 10000, m = 200000)

Test #17:

score: 0
Accepted
time: 2370ms
memory: 33688kb

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:

2317 6782 7575 9265 6993 1099 6612 7064 2747 1678 6368 2202 814 9423 3461 5029 7133 5488 2026 2261 4820 7303 1640 7430 2869 9839 4173 6986 6014 5725 6579 7179 1945 3354 8874 7752 9295 5630 7513 3705 5608 9164 4781 1653 3633 1101 2148 3618 9624 2824 9443 5399 7148 1186 9465 6776 3969 6980 393 2909 31...

result:

ok OK (n = 10000, m = 200000)

Test #18:

score: 0
Accepted
time: 2927ms
memory: 33896kb

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:

4514 5216 7010 2875 2874 6284 3365 7100 4334 2376 4714 8169 8129 1484 9311 1705 3465 9138 9722 5664 8364 7263 8425 8584 2837 6784 4835 7392 1482 1882 7050 5902 6191 7245 5436 7906 9018 549 6527 1157 9 7548 8684 8488 5325 2463 9250 7915 3480 8979 3676 5560 3250 9743 7836 8208 1287 4037 9451 7716 3914...

result:

ok OK (n = 10000, m = 200000)

Test #19:

score: 0
Accepted
time: 2222ms
memory: 33948kb

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:

8326 2000 6570 4892 1361 5783 5980 998 1541 645 8746 479 2766 6095 2743 4836 9779 2427 1091 1686 1715 9611 7349 4230 8732 8110 1580 7906 6709 1869 9348 5206 4993 3518 7225 9947 5536 6131 9502 3121 6977 9527 5336 7255 357 5229 2907 2392 3646 792 7609 337 4725 2350 3243 184 3954 5274 9499 9592 4303 27...

result:

ok OK (n = 10000, m = 200000)

Test #20:

score: 0
Accepted
time: 2515ms
memory: 33692kb

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:

4718 3247 6505 381 6401 9663 7436 6936 1653 9082 7765 3730 5709 6328 8409 4935 1284 2143 2102 9246 839 916 6383 8895 9654 1851 807 4625 6245 9291 3067 5105 7397 8025 3775 8228 4546 7233 4597 811 8492 7311 2349 5119 4146 9599 6874 574 4296 7190 4937 2149 9737 1243 4447 4969 1622 3976 2074 8257 4124 9...

result:

ok OK (n = 10000, m = 200000)

Test #21:

score: 0
Accepted
time: 2158ms
memory: 33876kb

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:

4213 5394 5033 7487 4440 2175 5693 2466 5727 3553 7947 3396 2836 3703 9010 61 3893 4318 7887 2234 7438 9642 3774 7454 5462 6874 1328 2746 9879 7254 9141 114 2428 1231 6639 6922 84 9348 9948 4992 8489 7129 1714 9023 2322 8554 7828 3338 6320 5516 5479 3648 3450 9109 6177 593 3816 8611 1633 1349 49 618...

result:

ok OK (n = 10000, m = 200000)

Test #22:

score: 0
Accepted
time: 2259ms
memory: 33692kb

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:

5426 8855 1894 7454 3946 2268 7218 8499 627 2433 7905 4398 8758 9936 3339 4101 9403 7920 2023 458 5884 5151 9286 1771 931 683 617 9980 1762 6624 1448 1111 7527 8658 1878 9299 5848 3098 1840 5256 7017 30 5704 1518 2999 9273 896 2235 7138 9389 830 2753 2550 8945 3565 6024 1614 1123 7101 4149 1062 388 ...

result:

ok OK (n = 10000, m = 200000)

Test #23:

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

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:

7021 2697 1715 1054 1527 1599 3932 3568 223 4222 8911 2455 4498 2146 357 2839 6940 5617 9910 603 5407 2207 3314 3040 1294 6010 2033 8305 1818 9544 6026 2091 7841 1703 8337 3858 2404 880 8630 1831 4566 7030 5662 5989 1026 2491 9474 9929 8210 6812 7774 4627 8439 7566 7503 3239 5489 2976 6004 8062 2329...

result:

ok OK (n = 10000, m = 200000)

Test #24:

score: 0
Accepted
time: 2505ms
memory: 33640kb

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:

4539 9990 2392 7606 1538 2279 4744 8638 6144 5751 781 2930 6754 8995 4087 7847 3391 3122 8138 2711 4311 8606 9890 5153 9649 4496 2065 7260 3153 7821 9703 5290 2474 2649 7454 9463 2298 3644 621 21 2269 1074 8657 4736 139 9923 9214 8157 1075 7356 170 7630 6816 7785 3778 8405 9263 1235 1824 9904 120 71...

result:

ok OK (n = 10000, m = 200000)

Test #25:

score: 0
Accepted
time: 2170ms
memory: 33696kb

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:

1839 4932 3517 8883 7420 1303 2285 6497 1735 7382 8955 9357 7727 1508 4337 9884 2753 955 2441 4900 630 6308 2944 1760 468 3755 7876 7895 890 1069 8941 8944 1398 4330 9178 1415 4634 2073 9334 815 1568 8539 277 8672 6365 1151 8395 1431 7820 7160 891 576 129 4720 6031 4234 480 6008 3794 2694 6823 2931 ...

result:

ok OK (n = 10000, m = 200000)

Test #26:

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

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:

9698 6642 1656 8319 4564 1712 7789 1812 2313 6380 4629 1160 3725 7135 671 9986 4308 1952 727 425 8977 4528 5953 1730 7013 2330 4498 8059 2541 3627 8270 8891 9961 1677 4271 4465 1543 6163 2193 9320 569 5110 2372 9949 5288 8183 3720 2657 5232 4554 5847 9025 8975 4965 312 899 8537 4639 2502 470 7956 62...

result:

ok OK (n = 10000, m = 200000)

Test #27:

score: 0
Accepted
time: 2480ms
memory: 33696kb

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:

9723 5076 4719 6070 9925 7401 7627 2740 6186 4438 5017 9781 7549 7152 8727 5261 1338 4101 5410 5407 2933 9687 4033 7028 9315 8968 2482 9939 3695 4891 4299 6906 2981 463 3850 631 9131 160 66 5455 4034 3748 9653 1602 7553 4028 6714 8248 7888 1270 8449 6578 9029 4865 8050 5951 5056 7324 6396 8280 951 6...

result:

ok OK (n = 10000, m = 200000)

Test #28:

score: 0
Accepted
time: 2155ms
memory: 33876kb

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:

1006 9231 3591 2655 3027 9756 3721 1899 378 483 11 440 2863 6395 1487 4876 9497 1690 8142 1902 3173 7721 918 618 2142 5685 9864 548 5885 7324 6196 3191 8046 1751 9152 4227 8203 956 1211 5130 4483 7445 2804 7162 8830 2576 5360 5456 7192 9559 8623 7742 55 538 5804 9697 9001 3452 6562 2411 9642 5708 22...

result:

ok OK (n = 10000, m = 200000)

Test #29:

score: 0
Accepted
time: 2288ms
memory: 33688kb

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:

6798 9775 9784 1933 8828 1786 6533 8913 5623 481 8187 2026 2171 3701 399 579 5446 605 4679 8522 2785 9711 5349 8624 7709 5995 9055 8246 9053 9182 4155 2172 5827 6939 6598 7228 9648 3517 8396 4842 1105 3237 2115 9299 995 9530 3330 890 3717 4597 7588 2052 2106 1959 6118 2873 5690 2197 1753 6298 2034 8...

result:

ok OK (n = 10000, m = 200000)

Test #30:

score: 0
Accepted
time: 1936ms
memory: 33928kb

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:

6916 7024 7169 6218 7062 7953 6375 2125 7059 9109 8712 1749 6937 4541 3123 6747 8779 3435 4050 7258 1544 7453 8609 3022 9831 5898 1258 8118 7404 284 6137 8395 6259 360 3506 276 2178 4061 9668 920 1609 124 9867 7677 1453 145 5139 4547 3174 5163 1615 3415 8589 6073 7110 7809 681 5255 4810 6160 9927 36...

result:

ok OK (n = 10000, m = 200000)

Test #31:

score: 0
Accepted
time: 2317ms
memory: 33888kb

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:

8962 7551 6622 4555 638 8457 8134 9808 375 3781 1408 6757 7507 4147 5868 5685 4741 604 8145 4933 5026 3713 2722 8915 754 6999 3221 1084 2208 829 9041 2753 1349 5420 1107 660 3034 4596 6898 3882 8913 7987 3226 2641 2854 8328 1076 2230 4452 1055 6917 9303 4913 4107 9131 4736 5427 6531 1922 9210 3308 9...

result:

ok OK (n = 10000, m = 200000)

Extra Test:

score: 0
Extra Test Passed