QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#426426#6329. Colorful GraphEXODUSAC ✓1391ms10552kbC++173.9kb2024-05-31 10:50:512024-05-31 10:50:51

Judging History

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

  • [2024-05-31 10:50:51]
  • 评测
  • 测评结果:AC
  • 用时:1391ms
  • 内存:10552kb
  • [2024-05-31 10:50:51]
  • 提交

answer


#include <vector>
#include <algorithm>
#include <cassert>
namespace exodus{
	namespace internal{
		class nothing{
		public:
			nothing(){}
			friend nothing operator +(const nothing&,const nothing&){return nothing();}
		};
	}
	template<class info=internal::nothing>
	struct dsu{
	public:
		struct node{
		public:
			node(){anc=-1,siz=1,ifo=info();}
			int anc,siz;
			info ifo;
		};
		dsu():_n(0){}
		explicit dsu(int n){
			_n=n;node.resize(n);
			for(int i=0;i<n;i++)
				node[i].anc=i;
		}
		void build(int n){
			_n=n;
			node.clear();
			node.resize(n);
			for(int i=0;i<n;i++)
				node[i].anc=i;
		}
		int find(int u){
			assert(0<=u&&u<_n);
			return __find(u);
		}
		void merge(int u,int v){
			assert(0<=u&&u<_n);
			assert(0<=v&&v<_n);
			u=__find(u),v=__find(v);
			if(node[u].siz<node[v].siz)std::swap(u,v);
			node[v].anc=u;
			node[u].ifo=node[u].ifo+node[v].ifo;
		}
		bool check(int u,int v){
			assert(0<=u&&u<_n);
			assert(0<=v&&v<_n);
			u=__find(u),v=__find(v);
			return u==v;
		}
	private:
		int _n;
		std::vector<node>node;
		int __find(int u){
			return u==node[u].anc?u:node[u].anc=__find(node[u].anc);
		}
	};
}

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

bitset<7000>bts[7000],used;
vector<int>g[7000];
int main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>>edge(m);
	for(auto& [u,v]:edge)
		cin>>u>>v,--u,--v;
	for(auto [u,v]:edge){
		g[u].emplace_back(v);
	}
	auto bfs=[&](int s){
		static queue<int>q;
		q.emplace(s);
		bts[s][s]=true;
		while(!q.empty()){
			int u=q.front();
			q.pop();
			for(auto v:g[u]){
				if(!bts[s][v]){
					bts[s][v]=true;
					q.emplace(v);
				}
			}
		}
	};
	
	for(int i=0;i<n;i++)
		bfs(i);
	
	for(int i=0;i<n;i++){
		bts[i].reset(i);
		for(int j=i+1;j<n;j++){
			if(bts[i].test(j)&&bts[j].test(i)){
				bts[j].reset(i);
			}
		}
	}
	int cnt=n;
	vector<int>pre(n,-1);
	vector<int>nxt(n,-1),mat(n,-1);
	auto spread=[&](int s)-> bool {
		queue<int>q;
		q.emplace(s);
		int pos=-1,target=-1;
		while(!q.empty()){
			int u=q.front();
			q.pop();
			auto good_pro=bts[u]&used;
			for(int v=good_pro._Find_first();v<n;v=good_pro._Find_next(v)){
				used.reset(v);
				if(nxt[v]==-1){
					pos=u;
					target=v;
					goto there;
				}else{
					q.emplace(nxt[v]);
					pre[nxt[v]]=u;
				}
			}
		}
		
		there:;
		if(target==-1)
			return false;
		while(pos!=-1){
			swap(target,mat[pos]);
			nxt[mat[pos]]=pos;
			pos=pre[pos];
		}
		return true;
	};
	for(int i=0;i<n;i++){
		used.set();
		fill(pre.begin(),pre.end(),-1);
		if(spread(i))
			cnt--;
	}
#ifdef EXODUS
	cerr<<cnt<<'\n';
#endif
	// for(int i=0;i<n;i++)
	// 	printf("%d ",nxt[i]);
	// printf("\n");
	exodus::dsu dsu(n);
	for(int u=0;u<n;u++){
		if(nxt[u]!=-1){
			dsu.merge(u,nxt[u]);
		}
	}
	vector<int>ans(n);
	for(int i=0;i<n;i++){
		static int colx=0;
		if(dsu.find(i)==i){
			ans[i]=++colx;
		}
	}
	for(int i=0;i<n;i++){
		ans[i]=ans[dsu.find(i)];
	}
	for(int i=0;i<n;i++)
		cout<<ans[i]<<' ';
	cout<<'\n';
#ifdef EXODUS
	cerr<<clock()<<'\n';
	vector<vector<int>>_g(n);
	vector<vector<int>>reach(n,vector<int>(n));
	for(auto [u,v]:edge){
		_g[u].emplace_back(v);
	}
	auto _bfs=[&](int s){
		static queue<int>q;
		q.emplace(s);
		reach[s][s]=true;
		while(!q.empty()){
			int u=q.front();
			q.pop();
			for(auto v:_g[u]){
				if(!reach[s][v]){
					reach[s][v]=true;
					q.emplace(v);
				}
			}
		}
	};
	for(int i=0;i<n;i++)
		_bfs(i);
	// for(int i=0;i<n;i++,cerr<<'\n')
	// 	for(int j=0;j<n;j++)
	// 		cerr<<reach[i][j]<<' ';
	vector<int>_lis;
	for(int i=1;i<=cnt;i++){
		_lis.clear();
		for(int j=0;j<n;j++)
			if(ans[j]==i)
				_lis.emplace_back(j);
		for(auto u:_lis)
			for(auto v:_lis){
				if(!reach[u][v]&&!reach[v][u]){
					cerr<<"Wrong Answer\n";
					return 1;
				}
			}
	}
	cerr<<"Accept\n";
#endif
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

1 1 1 2 2 

result:

ok AC

Test #2:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

5 7
1 2
2 1
4 3
5 1
5 4
4 1
4 5

output:

1 1 2 1 2 

result:

ok AC

Test #3:

score: 0
Accepted
time: 1ms
memory: 3812kb

input:

8 6
6 1
3 4
3 6
2 3
4 1
6 4

output:

1 1 1 1 2 1 3 4 

result:

ok AC

Test #4:

score: 0
Accepted
time: 320ms
memory: 10200kb

input:

7000 6999
4365 4296
2980 3141
6820 4995
4781 24
2416 5844
2940 2675
3293 2163
3853 5356
262 6706
1985 1497
5241 3803
353 1624
5838 4708
5452 3019
2029 6161
3849 4219
1095 1453
4268 4567
1184 1857
2911 3977
1662 2751
6353 6496
2002 6628
1407 4623
425 1331
4445 4277
1259 3165
4994 1044
2756 5788
5496 ...

output:

1709 1709 1709 2 342 1 342 2 1709 1 5 5 644 3 5 3 2 1750 1709 3 5 4 9 9 12 12 9 226 9 6 5 12 7 226 8 9 6 10 10 15 7 12 14 8 11 9 1725 15 13 33 516 51 10 51 14 11 15 16 12 17 1725 51 27 51 13 30 27 51 33 19 21 14 22 15 35 16 27 17 18 27 51 19 30 33 21 22 35 27 51 19 21 20 27 19 20 20 30 33 25 21 23 2...

result:

ok AC

Test #5:

score: 0
Accepted
time: 249ms
memory: 10232kb

input:

7000 6999
4832 1603
5984 6985
5355 3687
6007 2170
5984 3486
3267 2189
538 2123
4343 4553
5855 6168
5984 257
4239 2304
5984 2063
3298 1869
5984 6353
5984 2018
5984 5387
5984 3382
3164 3978
2690 2816
4810 2638
5984 3773
5984 1634
5984 2786
5984 3671
5984 5140
2943 5721
5984 414
1105 4060
3093 796
5984...

output:

1 1 1 2 3 2 4 5 3 24 708 4 5 6 6 7 3 4 5 7 6 8 9 10 3 5 11 12 13 14 15 8 9 10 11 12 16 13 17 18 14 19 20 15 21 3 22 9 16 23 24 25 26 27 28 13 17 18 19 10 20 21 22 4 29 30 23 31 24 32 25 26 27 28 13 20 29 30 33 8 34 35 31 36 5 32 37 23 27 708 38 39 28 29 21 24 40 26 33 34 30 35 41 8 42 36 43 32 37 44...

result:

ok AC

Test #6:

score: 0
Accepted
time: 257ms
memory: 10440kb

input:

7000 6999
1649 5337
1701 3344
4394 2172
3330 39
5932 1141
5381 5340
5453 3300
125 2172
6810 5263
804 2172
6635 2172
676 4740
3015 1183
1710 5769
611 5915
3419 1581
2094 2172
4508 2172
6604 2433
6113 1466
1604 696
1518 1123
1287 2940
4825 2172
5130 4524
2693 2172
106 2172
5157 2172
3693 2172
5198 217...

output:

1 2 1 2 3 3 3 4 5 2326 8 5 14 10 10 6 10 7 8 9 14 6 7 10 9 11 14 12 2332 9 13 11 14 15 15 12 13 16 17 15 13 18 19 16 19 1153 1800 20 17 13 21 18 22 23 22 24 19 1800 25 20 13 21 23 26 27 28 29 30 22 24 19 25 20 31 27 32 21 31 32 26 31 28 30 33 27 29 32 31 30 33 34 35 36 27 37 33 37 34 35 38 39 40 59 ...

result:

ok AC

Test #7:

score: 0
Accepted
time: 333ms
memory: 10268kb

input:

7000 6999
2896 6321
881 2623
5058 2623
4833 2623
4669 2623
4781 5007
1447 2623
4781 4768
4781 3834
2758 4792
797 5055
3784 2623
4781 5510
6606 3040
597 3459
4136 2037
1291 3989
4781 837
4781 4379
5637 2053
1642 2665
4781 4664
4781 952
4924 2511
4781 4201
4781 2352
4781 5362
3901 197
137 2623
2706 19...

output:

1 1 1 1749 2 1 2 1749 1 2 2 2 4 3 4 2 3 4 4 4 4 5 5 6 7 8 9 10 5 6 7 8 9 10 11 7 11 12 11 13 10 9 14 12 7 13 11 14 10 13 12 13 9 14 12 13 12 15 15 16 12 15 16 16 16 15 17 18 16 19 17 18 19 16 18 17 19 18 20 18 20 20 21 17 21 22 19 21 22 23 18 23 24 20 21 24 22 23 21 24 22 23 25 25 23 26 25 26 25 27 ...

result:

ok AC

Test #8:

score: 0
Accepted
time: 127ms
memory: 10224kb

input:

6999 6998
1269 3969
1269 2429
1269 2609
1269 2515
1269 6166
1269 6614
3108 1269
2105 1269
4670 1269
578 1269
4661 1269
1421 1269
2576 1269
6152 1269
1269 6636
3011 1269
305 1269
5189 1269
1683 1269
6861 1269
1269 5798
1499 1269
282 1269
914 1269
80 1269
677 1269
701 1269
1269 359
6521 1269
1269 1754...

output:

1 2 3 4 1 5 6 2 3 4 5 6 7 7 8 9 10 8 11 12 9 13 14 10 15 16 17 18 19 11 20 12 21 22 13 23 14 15 24 16 17 25 26 18 19 27 28 29 30 31 20 21 22 32 23 24 33 34 35 36 37 25 26 38 27 28 29 39 40 41 30 42 31 32 33 43 44 34 45 46 35 47 36 37 48 38 49 39 40 50 41 51 42 52 53 54 43 55 56 57 44 45 46 47 48 58 ...

result:

ok AC

Test #9:

score: 0
Accepted
time: 26ms
memory: 10064kb

input:

7000 0

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

ok AC

Test #10:

score: 0
Accepted
time: 732ms
memory: 10488kb

input:

7000 6999
3138 1903
3285 5919
6182 1430
1164 961
1577 6445
1390 3384
935 5723
6614 6387
4799 2877
3915 5128
5366 5455
2287 3941
2053 2326
4022 6993
488 2922
4327 4701
4674 3221
1666 4773
4356 3232
3888 937
4318 6942
577 1299
4491 1938
5154 1254
790 5532
4286 5478
2918 6725
2853 304
2554 5207
5140 77...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok AC

Test #11:

score: 0
Accepted
time: 725ms
memory: 10260kb

input:

7000 6999
33 3147
5877 4807
3116 4168
1651 2456
624 1740
6440 3058
6414 489
1023 2523
706 93
5523 598
4211 6063
3570 6840
6566 2971
6614 1907
5893 4389
4022 2527
5096 2345
4682 2134
188 5597
695 4285
1344 3832
3534 879
6574 6252
3759 3444
2167 85
5630 6600
3158 4404
6389 689
4871 6719
4295 6008
3437...

output:

70 35 55 55 39 39 55 67 55 21 55 21 55 30 21 48 55 70 30 21 24 43 35 55 30 21 43 55 30 21 43 55 65 30 21 45 57 58 43 55 65 61 64 30 22 21 64 2 43 48 55 65 30 21 33 16 2 43 15 57 64 57 58 55 65 30 21 37 34 33 16 35 2 43 53 15 53 37 35 55 70 6 65 30 16 49 21 33 10 2 35 43 15 55 54 39 8 65 16 30 4 21 3...

result:

ok AC

Test #12:

score: 0
Accepted
time: 861ms
memory: 10268kb

input:

7000 6999
1247 5150
3318 2013
5686 1615
6145 6521
5717 94
2787 3443
2648 4875
5332 5934
1897 1651
4640 2183
1750 6964
148 5228
745 2814
474 1165
496 6735
180 3412
2723 3374
6200 4361
497 5328
1928 5998
5648 1261
5090 4723
1715 706
2499 897
6569 6204
6039 2787
2882 5044
5767 4256
975 1877
1857 4453
6...

output:

27 69 27 249 27 121 252 27 268 121 187 6 268 27 121 6 27 121 255 27 121 255 27 121 255 27 140 121 187 206 255 27 44 121 206 255 76 27 268 44 121 206 163 255 201 235 27 44 121 236 36 166 206 255 201 257 27 14 109 44 210 45 121 166 206 6 255 201 243 83 257 268 243 27 44 88 121 166 252 65 206 255 201 2...

result:

ok AC

Test #13:

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

input:

7000 6999
2349 199
5295 2831
6143 2006
3212 3198
6956 3807
732 4838
5069 1027
5744 3479
6 5301
5687 4452
4201 1151
1353 4884
548 3506
6094 4799
4950 6939
5234 817
652 1314
979 6984
5771 1851
398 1322
2294 4298
847 3929
6833 183
2904 6745
4797 3874
94 315
4282 582
6591 5037
962 147
799 908
2593 5547
...

output:

681 681 1005 681 806 176 32 123 5 559 176 681 783 668 986 806 898 986 663 479 404 109 700 235 788 681 217 486 973 806 358 846 1049 886 45 1015 109 753 355 586 419 700 176 445 681 419 985 217 806 751 497 525 259 386 718 331 267 1012 710 884 45 109 139 537 573 244 624 110 749 668 700 930 681 217 1015 ...

result:

ok AC

Test #14:

score: 0
Accepted
time: 1252ms
memory: 10552kb

input:

7000 6999
3409 1629
2076 6412
4997 1078
6320 626
4501 1104
4173 1774
5507 2375
2299 5115
4321 127
1192 6635
1909 3398
2972 499
862 5024
421 2931
861 1536
902 3813
659 4514
1843 3035
3669 1228
1724 1880
34 706
133 3468
6116 585
5073 1461
5667 3405
715 4834
6915 3007
1736 6108
3264 2870
2393 6474
2108...

output:

1021 1239 1398 126 1239 2146 2578 44 2360 2417 2592 2370 1239 2592 1295 2282 2349 2519 160 2593 44 623 527 2530 2608 1239 2359 1389 2357 2270 1521 675 2001 2563 1207 2437 1917 1223 1837 1605 2348 2229 2286 2457 2519 2563 2221 1843 1730 57 2309 283 506 718 44 1287 2113 2221 1297 1944 497 527 163 601 ...

result:

ok AC

Test #15:

score: 0
Accepted
time: 34ms
memory: 10156kb

input:

7000 7000
2048 5882
6801 2408
3225 2608
1441 5079
497 6253
557 5589
2535 6257
4800 2595
4713 1286
4759 6636
4303 4296
6195 2048
6994 2987
1249 3044
1036 10
6472 2076
1996 1086
1279 1486
6100 369
4797 3437
2493 4576
2944 5601
197 5582
5488 5035
4023 659
2651 5024
2257 5710
1001 3941
446 4815
687 702
...

output:

1 920 1984 2 3 2006 1205 4 5 1293 1832 6 1067 7 1046 197 1048 8 1629 573 9 1585 419 544 1106 819 1992 10 1708 1192 1785 2601 2382 2253 11 814 1533 12 2617 13 383 2272 14 129 182 284 15 22 2247 303 16 416 2808 1166 2613 1588 17 18 686 1498 19 2450 82 1495 20 2026 2103 2528 21 459 2274 22 23 2190 24 2...

result:

ok AC

Test #16:

score: 0
Accepted
time: 37ms
memory: 10256kb

input:

6993 7000
6927 2941
6385 1428
6914 2553
2474 4268
2068 1640
2298 6960
6201 1806
4912 59
4407 5504
1595 6868
6378 2515
3713 3724
2995 2589
2314 2932
4042 431
6322 4178
5947 6850
6192 735
3802 1043
4982 1575
311 6496
5006 3191
6473 3084
2387 4706
6632 5901
5113 3066
5248 1274
5671 717
1311 4261
1960 3...

output:

1808 344 953 883 413 1 1235 185 2 2287 2269 623 1109 1490 1317 1699 3 1394 4 5 1460 1573 6 7 8 962 9 10 11 12 2485 2640 13 1632 2024 2654 168 324 1833 10 1753 2167 14 15 16 17 1838 18 1938 524 19 2813 1226 273 20 16 815 1798 163 21 2035 22 23 185 24 140 2209 775 121 2818 1043 1038 2626 25 156 1242 2...

result:

ok AC

Test #17:

score: 0
Accepted
time: 55ms
memory: 10096kb

input:

6930 7000
3746 2945
3523 6758
4109 1106
2732 5415
2423 844
3702 6309
6503 5362
5997 6294
5688 1396
4842 1764
4780 4521
1254 826
37 4653
2138 2358
6345 1223
1385 2341
5261 5867
4815 2918
4209 696
4235 2314
3680 2919
5605 5155
6643 3391
2691 1418
6289 2093
1970 1804
828 5237
4025 1111
1164 5519
5889 2...

output:

1 2408 1403 1505 2191 809 1309 1521 2 2603 2414 3 4 1097 1862 796 892 5 1288 6 7 591 914 2305 1610 8 2028 9 1598 782 2421 2031 2346 1189 10 1778 2210 2680 11 179 2134 888 1623 12 13 677 14 15 473 1324 142 16 1562 17 231 2175 159 491 1532 2113 2164 1319 1081 460 754 2758 2426 518 34 1220 916 1422 18 ...

result:

ok AC

Test #18:

score: 0
Accepted
time: 88ms
memory: 9800kb

input:

6300 7000
5921 5466
723 5843
1084 3134
3865 5742
5492 2885
328 4408
6055 4074
3702 2240
1342 2353
295 734
553 48
4454 2980
1248 4460
5023 19
2784 441
105 844
6048 1773
4840 5260
3910 1292
5578 2864
4978 3116
6182 4962
2575 1661
5030 435
5861 4709
5033 358
1746 5816
5877 3921
2678 5679
1784 33
207 59...

output:

1954 154 1635 1868 1 266 2332 2 3 4 5 6 7 8 1990 1637 1453 907 9 2048 2093 10 11 1640 1739 12 13 1537 14 15 16 312 230 17 18 1506 1017 2296 542 395 19 20 345 1134 1015 1491 1091 1872 21 216 1123 22 23 1506 867 1099 151 246 1881 902 2359 1071 24 1401 522 2302 2380 25 26 2288 27 449 28 377 31 779 522 ...

result:

ok AC

Test #19:

score: 0
Accepted
time: 162ms
memory: 7396kb

input:

2800 7000
218 2670
1436 2268
38 2781
55 783
549 1627
660 1609
2268 2645
1376 1395
2747 71
785 1451
1096 2633
2655 2557
1569 307
16 56
1993 2751
1154 2760
478 2452
1841 2764
155 1781
215 1432
1788 2548
193 2665
167 1038
2425 2314
439 1615
269 1187
1222 245
1638 2016
2352 1511
2333 1564
1667 2576
1751...

output:

194 194 194 194 53 194 53 174 194 53 174 194 53 174 194 53 174 194 253 53 174 194 253 63 53 174 194 253 63 53 94 109 194 253 63 1 109 194 253 63 109 194 253 63 2 194 253 63 194 17 253 3 194 53 253 194 53 253 194 53 253 51 194 134 53 253 4 5 6 75 53 253 144 75 53 94 253 144 75 53 94 253 144 75 53 94 ...

result:

ok AC

Test #20:

score: 0
Accepted
time: 24ms
memory: 10220kb

input:

7000 7000
4828 3840
4148 2678
1645 2954
5516 1204
4664 285
904 1978
1434 1688
1902 5205
1324 4512
1722 1246
6724 5227
524 196
937 6286
6609 4724
5408 5610
4405 2463
5493 1567
2625 2894
2378 3685
5399 6872
6475 6546
5697 1265
1811 1314
2347 3005
6245 271
2414 434
3492 6948
4447 599
793 6107
464 5353
...

output:

2935 1 1030 1184 2 3 3346 415 176 4 5 6 1222 2038 679 2958 7 1635 758 8 9 10 3416 3185 11 11 12 2232 13 1248 2222 14 1844 15 431 1049 16 17 524 18 961 19 962 821 20 21 140 22 23 24 25 2265 26 27 28 473 2034 29 30 1370 31 674 1372 1059 32 2834 1396 3002 1532 200 33 34 2565 819 2801 3056 35 36 2778 37...

result:

ok AC

Test #21:

score: 0
Accepted
time: 25ms
memory: 10124kb

input:

6993 7000
1576 5558
2853 3183
212 2572
1001 75
3386 6483
401 22
489 6768
6520 1684
6439 6188
3810 6414
4088 1924
371 1666
2822 410
5664 1676
1043 1365
384 2688
4179 6357
6466 4630
2829 4371
116 6817
1535 6172
751 5740
499 2484
2013 4576
6556 670
6177 3847
5344 4280
6103 1055
496 4934
6639 217
6606 4...

output:

840 2670 653 1 2 3 949 4 2284 1600 149 5 2607 6 7 8 9 429 10 11 3246 12 3419 2122 13 3505 3348 250 14 2633 2825 15 752 854 2626 16 2146 17 18 1414 19 20 1393 1799 21 22 824 1288 23 1907 24 25 1997 1810 26 508 27 28 666 29 30 530 298 31 1180 1351 32 92 3536 33 34 2556 510 1746 2648 3365 35 3262 325 4...

result:

ok AC

Test #22:

score: 0
Accepted
time: 24ms
memory: 10148kb

input:

6930 7000
2378 5636
2953 3870
897 2126
112 1756
3302 5114
4591 5593
5408 4899
1204 6313
6254 2214
5360 6680
2354 5865
5959 5969
1628 5317
6396 1006
2402 1767
1921 3373
3758 312
2167 5711
4119 6585
19 3951
1714 1206
3754 4376
4516 307
6312 165
5721 2470
4828 4842
4520 4310
1922 4946
2006 3856
1218 58...

output:

1 2 3 3506 4 5 438 2985 6 807 7 3086 8 600 1758 287 3002 2979 1862 1780 9 3103 1552 695 3065 218 10 11 12 1024 3101 2196 13 1446 1689 14 15 16 1132 17 107 18 3612 19 3058 2273 1101 3608 20 21 22 23 24 1320 25 26 375 1842 817 27 28 29 3311 30 31 2920 32 720 3512 1163 1558 33 2152 34 3387 35 36 2217 3...

result:

ok AC

Test #23:

score: 0
Accepted
time: 20ms
memory: 9528kb

input:

6300 7000
1562 45
1716 2699
5291 4828
5063 4588
5888 4130
5901 6109
1476 921
3390 5892
5425 3782
824 5679
2278 6102
6146 5556
4874 2115
2842 2803
1963 5131
3736 2611
320 5272
758 5667
4087 228
5139 760
1812 2968
2897 6117
277 387
336 1322
4319 4597
608 4481
6182 3050
4333 3570
401 1662
3085 3197
537...

output:

1 1233 2 3 4 2154 5 796 6 187 805 2586 365 7 8 2323 9 2632 680 1062 2362 10 485 1493 11 12 2793 1526 13 14 15 2391 909 320 16 997 2269 2076 1509 1428 1615 1506 2139 17 801 1791 2456 1239 548 18 2302 19 20 870 1296 2419 21 2126 1547 2173 41 2094 3107 891 2568 1922 1607 793 988 22 2692 23 804 1816 302...

result:

ok AC

Test #24:

score: 0
Accepted
time: 6ms
memory: 7760kb

input:

2800 7000
931 1154
1783 1159
2515 1596
1734 1277
825 430
938 208
288 684
970 2075
618 2411
2690 500
223 2162
2093 2765
172 1029
832 1571
89 2333
2301 981
1354 1094
1989 137
2340 1804
2600 1249
1714 2343
1043 2738
1375 1239
804 2578
424 1572
568 1945
2233 297
1890 519
1475 944
2732 1123
2012 927
2232...

output:

520 190 51 435 537 169 447 802 14 680 650 510 1 297 715 2 538 113 69 205 574 3 11 24 4 563 5 6 341 215 138 43 558 563 570 9 362 305 512 245 7 571 186 8 765 69 659 407 228 47 146 255 571 286 600 81 9 533 727 400 766 147 281 407 139 752 757 646 483 7 301 10 11 549 446 263 15 179 52 12 281 544 823 361 ...

result:

ok AC

Test #25:

score: 0
Accepted
time: 1ms
memory: 5952kb

input:

52 41
18 31
2 5
22 32
1 50
50 29
9 32
44 27
45 17
26 24
18 30
28 25
38 28
5 47
49 38
23 50
8 3
16 24
29 46
7 52
30 38
33 32
39 32
3 18
50 44
1 35
49 37
18 24
29 6
20 39
40 45
33 28
51 52
26 40
38 43
52 45
39 40
42 34
6 45
32 19
20 52
34 28

output:

8 25 22 1 25 8 28 22 9 2 3 4 5 6 7 11 8 22 9 23 10 15 24 11 12 20 13 12 24 22 14 15 12 16 17 18 19 22 23 20 21 16 22 13 23 24 25 26 19 13 27 28 

result:

ok AC

Test #26:

score: 0
Accepted
time: 1ms
memory: 4072kb

input:

291 56
117 283
21 277
128 22
245 45
8 223
150 129
16 15
224 163
288 76
218 238
25 233
100 262
244 101
76 207
286 80
164 238
165 283
133 251
23 235
22 280
65 205
8 30
66 76
232 90
251 287
80 62
58 218
285 225
247 199
149 34
219 16
286 221
174 248
20 58
169 69
229 119
178 216
152 147
148 189
116 207
7...

output:

1 128 2 3 4 5 6 22 7 8 9 10 11 12 13 13 14 15 16 183 233 236 196 17 195 18 19 20 21 22 23 24 124 25 26 27 28 29 30 83 31 32 33 34 35 36 37 38 39 128 40 41 42 43 44 45 46 183 47 48 49 50 51 52 170 172 53 54 55 56 57 77 197 58 59 172 60 61 62 50 63 64 65 66 67 68 233 69 70 71 72 73 74 75 134 76 77 78 ...

result:

ok AC

Test #27:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

26 295
19 5
19 13
10 2
14 13
19 24
20 13
9 3
18 11
13 25
13 14
24 6
1 2
25 6
6 13
7 25
1 9
2 8
6 8
13 18
2 7
11 9
14 12
21 19
17 23
8 14
3 5
22 8
8 3
25 5
24 21
10 3
23 13
24 20
3 21
23 18
7 15
24 18
18 21
18 4
8 12
13 9
12 1
14 9
18 20
9 22
10 25
3 26
2 14
5 20
1 24
24 1
23 6
18 6
21 11
19 4
24 25
...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 

result:

ok AC

Test #28:

score: 0
Accepted
time: 1ms
memory: 3864kb

input:

63 1000
22 9
25 11
52 54
34 30
18 8
24 3
42 30
61 51
34 17
36 52
58 9
41 53
19 12
40 3
54 47
23 51
44 59
10 21
35 52
34 56
43 15
39 41
12 37
13 21
55 48
16 57
39 25
26 25
22 57
54 34
63 55
11 27
60 40
41 1
24 59
20 53
14 6
51 35
44 9
47 35
32 39
40 28
9 49
29 27
16 25
56 53
28 56
5 39
35 57
61 37
22...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 

result:

ok AC

Test #29:

score: 0
Accepted
time: 1ms
memory: 4092kb

input:

42 113
29 15
21 15
28 13
30 42
7 33
4 31
16 18
11 36
38 13
33 6
28 27
17 19
21 25
42 4
19 16
8 37
38 4
4 19
20 22
33 27
26 42
31 39
14 29
6 32
20 12
40 6
32 28
23 18
41 22
10 4
7 28
31 13
14 24
37 40
9 20
26 32
13 18
35 29
9 29
34 26
19 32
20 25
34 39
33 23
28 35
35 22
7 16
40 13
39 24
24 20
18 24
4...

output:

2 2 2 2 2 2 2 2 1 2 1 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 

result:

ok AC

Test #30:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

6 8
5 1
1 5
6 5
4 1
4 3
2 4
5 3
3 4

output:

1 1 1 1 1 2 

result:

ok AC

Test #31:

score: 0
Accepted
time: 142ms
memory: 10192kb

input:

7000 6999
6253 1991
6253 4600
1137 6253
1764 6253
6253 908
6253 2205
6253 213
6253 4399
6300 6253
4601 6253
6253 4884
6937 6253
6253 4070
2646 6253
1007 6253
6552 6253
6253 2115
6253 922
6223 6253
6253 2496
3522 6253
2050 6253
6253 763
6803 6253
6253 3847
2816 6253
6253 6297
6253 471
6253 3211
3203 ...

output:

1 2 1 2 3 3 4 4 5 5 6 6 7 8 7 9 8 9 10 10 11 11 12 12 13 13 14 14 15 16 17 18 15 16 17 19 18 20 21 22 23 19 24 20 25 21 26 22 23 24 27 28 25 26 27 29 30 31 32 33 28 34 35 29 36 30 31 37 38 32 39 33 34 40 41 35 42 36 37 38 39 40 41 42 43 43 44 45 44 46 47 45 46 47 48 49 48 50 51 49 52 50 53 54 51 55 ...

result:

ok AC