QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#115325#6329. Colorful GraphxaphoenixAC ✓575ms11152kbC++144.0kb2023-06-25 17:24:322023-06-25 17:24:35

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-25 17:24:35]
  • 评测
  • 测评结果:AC
  • 用时:575ms
  • 内存:11152kb
  • [2023-06-25 17:24:32]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define LC k<<1
#define RC k<<1|1
#define IO cin.sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define rep(i,a,n) for (int i = a; i < n; i++)
#define repn(i,a,n) for (int i = a; i <= n; i++)
#define per(i,a,n) for (int i = (n) - 1; i >= a; i--)
#define pern(i,a,n) for (int i = n; i >= a; i--)

typedef long long LL;
typedef long double LD;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<int, LL> PIL;
typedef pair<LL, int> PLI;
typedef pair<double, double> PDD;
typedef pair<ull, ull> PUU;
typedef pair<LL, LL> PLL;

const int N = 21000;
const int M = 510000;
const int mod = 1e9+7;
const int inf = (int)1e9;
const LL INF = 1e18;
const double eps = 1e-9;

mt19937_64 Rand((unsigned long long)new char);
#define rand Rand

int n, m;
int dfn[N], low[N], instack[N], scc[N], cnt, scc_cnt;
stack<int> st;
vector<int> g[N];
void tarjan(int x) {
	dfn[x] = low[x] = ++cnt;
	st.push(x);
	instack[x] = 1;
	for (auto y: g[x]) {
		if (dfn[y] == 0) {
			tarjan(y);
			low[x] = min(low[x], low[y]);
		}
		else if (instack[y]) low[x] = min(low[x], dfn[y]);
	}
	if (low[x]==dfn[x]) {
		++scc_cnt;
		while (!st.empty() && st.top() != x) {
			scc[st.top()] = scc_cnt;
			instack[st.top()] = 0;
			st.pop();
		}
		st.pop();
		scc[x] = scc_cnt;
		instack[x] = 0;
	}
}

int fa[N], col[N];
int ans[N], que[N], tail, tot;
int find(int x) {
	return fa[x] == x? x: fa[x] = find(fa[x]);
}
int ax, ay;
struct MCMF {
	// bfs, dinic
	// st must be the lowest index, ed must be the highest index
	int e[M], f[M], pre[M], last[N];
	int d[N], now[N];
	int num, st, ed, maxflow;
	queue<int> q;
	void init() {
		num = 1;
		repn(i, st, ed) last[i] = 0;
		maxflow = 0;
	}
	void insert(int x, int y, int z) {
		e[++num] = y, f[num] = z, pre[num] = last[x], last[x] = num;
		e[++num] = x, f[num] = 0, pre[num] = last[y], last[y] = num;
	}
	bool bfs() {
	    memset(d, -1, sizeof(d));
	    d[st] = 0;
		q.push(st);
	    while(!q.empty()) {
	        int now = q.front();
	        for (int i = last[now]; i; i = pre[i]) if (f[i] && d[e[i]] == -1) {
	                d[e[i]] = d[now] + 1;
	                q.push(e[i]); 
	            }
	        q.pop();
	    }
	    if (d[ed] == -1) return 0;
		return 1;
	}
	int dfs(int x, int incf) {
	    if (x == ed) return incf;
	    int flow = 0, w;
	    for (int i = now[x]; i; i = pre[i]) if (f[i] && d[e[i]] == d[x] + 1) {
				w = dfs(e[i], min(incf - flow, f[i]));
	            f[i] -= w, f[i ^ 1] += w; flow += w;
	            if (f[i]) now[x] = i;
				if (flow == incf) return incf;
	        }
	    if (!flow) d[x] = -1;
	    return flow;
	}
	void run() {
		while(bfs()) {
			repn(i, st, ed) now[i] = last[i];
			maxflow += dfs(st, inf);
		}
	}
	void work(int x) {
		if (x == ed) return;
		for (int i = last[x]; i; i = pre[i]) if (f[i ^ 1] && (i % 2 == 0)) {
			f[i ^ 1]--;
			work(e[i]);
			if (e[i] == ed) ay = (x + 1) / 2;
			if (x == st) ax = (e[i] + 1) / 2;
			return;
		}
	}
}solver;
int main() {
	IO;
	cin >> n >> m;
	repn(i, 1, m) {
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
	}
	repn(i, 1, n) if (dfn[i] == 0) tarjan(i);
	solver.st = 0, solver.ed = scc_cnt * 2 + 1;
	solver.init();
	repn(i, 1, scc_cnt) {
		solver.insert(0, i * 2 - 1, 1), solver.insert(i * 2, scc_cnt * 2 + 1, 1);
		solver.insert(i * 2, i * 2 - 1, n);
	}
	repn(x, 1, n) for (auto y: g[x]) {
		if (scc[x] == scc[y]) continue;
		solver.insert(2 * scc[x] - 1, 2 * scc[y], n);
	}
	repn(i, 1, scc_cnt) fa[i] = i;
	solver.run();
	repn(i, 1, solver.maxflow) {
		solver.work(0);
		int fx = find(ax), fy = find(ay);
		fa[fx] = fy;
	}
	repn(i, 1, scc_cnt) if (!ans[find(i)]) ans[find(i)] = ++tot;
	repn(i, 1, n) cout << ans[find(scc[i])] << " \n"[i == n];
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 10168kb

input:

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

output:

2 2 2 1 2

result:

ok AC

Test #2:

score: 0
Accepted
time: 2ms
memory: 10180kb

input:

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

output:

1 1 2 1 1

result:

ok AC

Test #3:

score: 0
Accepted
time: 2ms
memory: 10180kb

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: 474ms
memory: 10284kb

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:

1 107 414 203 2 3 2 377 655 1505 1 1 4 1 232 5 516 6 702 25 498 585 2 253 102 7 8 6 334 9 1171 566 10 11 385 385 286 12 2 13 1525 614 14 534 15 687 16 2 17 18 879 19 1292 2 122 187 1 20 1031 21 575 2 2 2 158 22 2 2 243 23 24 710 25 981 26 1179 6 570 932 2 2 2 427 443 1 451 610 751 603 2 309 6 27 306...

result:

ok AC

Test #5:

score: 0
Accepted
time: 548ms
memory: 10580kb

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 618 465 1723 1 886 671 1 1 1 1 1 1274 1 2 1 1 1 2330 3 1713 2095 1232 1 1 848 1896 782 1568 1664 1 1 1 4 5 1371 1 117 135 6 237 1187 7 1846 8 21 9 10 1573 18 1533 2303 204 1811 1 11 12 13 14 1 1 15 1 805 1558 1 617 1 2264 16 1 1 1 17 18 1 1 1607 1 1804 884 19 1891 1 1 670 1 20 1 416 1341 1 21 22...

result:

ok AC

Test #6:

score: 0
Accepted
time: 575ms
memory: 9024kb

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 464 319 103 3 165 1084 1720 4 1148 5 6 902 632 529 7 385 1158 1690 701 8 9 1446 551 266 731 413 10 11 1792 12 1334 752 1410 13 411 421 94 14 237 2073 1741 15 385 1175 685 303 16 45 377 17 1672 1538 694 323 323 18 583 5 19 62 20 2183 1827 1894 221 813 21 22 23 24 25 1078 460 1211 26 956 1014 27 8...

result:

ok AC

Test #7:

score: 0
Accepted
time: 265ms
memory: 10356kb

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 1 1 1 1 2 354 3 1 1 1 1 1 1443 1548 1 1 4 1345 1 795 607 1367 1504 1428 1007 5 6 1 7 1 1 1 1 1536 226 1 699 1 1 879 1 8 1 9 1 10 1 1 1 11 12 1 13 1 1 783 1 14 1 1 113 1 15 272 1499 1 1743 1 1 1 16 1 1 1 1 1 1 1 1017 1 17 1052 1145 18 1 1 1 19 1523 1510 20 1 1 1 1 21 22 23 1 1 476 24 1513 1 1 2...

result:

ok AC

Test #8:

score: 0
Accepted
time: 40ms
memory: 8772kb

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 1073 5 6 2667 1045 3245 3304 2946 7 434 8 9 10 976 11 12 125 13 14 2692 15 16 17 18 19 1675 20 1067 21 22 3194 23 1614 459 24 515 971 25 26 1204 3088 27 28 29 30 31 2522 1552 3493 32 263 2395 33 34 35 36 37 577 20 38 3396 2833 3337 39 40 41 525 42 730 1745 2103 43 44 2792 45 46 2095 47 2380 ...

result:

ok AC

Test #9:

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

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: 36ms
memory: 10472kb

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: 6ms
memory: 11152kb

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:

23 29 1 1 19 19 1 7 1 1 1 1 1 30 1 7 1 25 1 1 14 1 29 1 1 1 1 1 1 1 1 1 31 1 1 7 34 33 1 1 1 19 16 1 12 1 14 1 1 7 1 1 1 1 1 7 1 1 1 35 14 34 34 1 1 1 1 13 29 1 5 29 1 1 19 1 20 13 29 1 23 15 1 1 3 6 1 1 15 1 29 1 1 1 1 17 36 1 3 1 1 1 1 33 1 1 25 1 1 20 1 1 1 23 33 1 29 1 1 1 1 20 13 1 33 1 1 1 1 3...

result:

ok AC

Test #12:

score: 0
Accepted
time: 7ms
memory: 10384kb

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:

1 44 1 15 1 1 46 1 80 1 65 23 79 1 1 17 1 1 1 1 1 1 1 1 1 1 3 1 69 81 1 1 1 1 1 1 56 1 77 1 1 1 63 1 1 15 1 1 1 32 30 82 1 1 1 1 1 49 65 1 15 50 1 1 1 23 1 1 71 67 1 83 69 1 1 1 1 1 60 13 1 1 1 1 1 15 1 1 1 1 71 1 1 1 26 1 1 1 1 1 32 1 1 71 15 1 1 63 1 17 3 1 1 67 1 33 1 1 70 1 1 71 1 16 1 1 1 73 1 ...

result:

ok AC

Test #13:

score: 0
Accepted
time: 14ms
memory: 9068kb

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:

1 2 341 1 1 17 8 433 574 254 28 1 102 487 178 1 546 179 379 489 117 1 1 89 378 1 1 464 137 1 436 150 195 224 1 72 1 112 259 34 311 1 22 533 1 313 230 1 1 292 163 184 457 569 264 575 254 406 472 131 1 1 324 1 1 352 341 417 201 476 1 1 1 1 102 1 350 1 484 124 1 1 1 210 576 72 1 210 1 299 39 261 1 577 ...

result:

ok AC

Test #14:

score: 0
Accepted
time: 13ms
memory: 9148kb

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:

1107 1 1108 803 1 1109 204 1 363 671 975 836 1 985 1111 534 592 1 717 133 1 702 1 359 1112 1 1113 1114 1115 1116 1 1117 1 1118 1203 465 539 1204 715 904 738 1205 1206 1254 1 574 1122 724 1273 822 833 185 1 136 1 1274 860 1093 79 893 42 1 126 601 623 1275 582 1276 826 1277 1278 477 1279 1280 1198 128...

result:

ok AC

Test #15:

score: 0
Accepted
time: 29ms
memory: 8828kb

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 2 3 17 18 24 32 33 34 36 38 39 40 54 56 94 102 236 238 41 239 240 242 243 245 246 268 274 276 277 345 351 338 359 256 361 363 368 369 370 371 372 373 316 375 377 378 379 132 381 382 366 118 385 387 365 388 27 391 393 398 323 399 401 402 403 314 207 408 410 419 379 397 420 421 389 434 202 436 453 4...

result:

ok AC

Test #16:

score: 0
Accepted
time: 32ms
memory: 10024kb

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:

1 8 306 311 314 315 212 322 71 325 326 327 175 237 352 362 364 21 367 241 369 375 376 377 363 380 386 387 388 389 337 24 397 227 129 401 262 402 404 387 416 427 428 429 372 247 246 430 432 435 449 451 468 472 473 372 476 289 218 477 270 478 479 318 480 483 487 234 489 454 270 491 493 494 545 548 552...

result:

ok AC

Test #17:

score: 0
Accepted
time: 31ms
memory: 10524kb

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 5 55 71 73 74 375 400 401 403 261 404 405 239 236 413 415 416 158 417 418 419 426 427 429 430 432 433 446 447 384 454 455 456 457 232 461 177 462 464 465 142 246 467 468 469 470 471 57 474 479 480 149 481 482 505 511 523 252 524 530 531 532 276 534 543 357 350 544 557 558 559 560 14 561 562 563 56...

result:

ok AC

Test #18:

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

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:

1 4 6 7 8 9 17 18 19 20 21 22 23 24 28 29 32 609 611 612 225 613 213 614 409 617 618 560 619 491 620 622 623 624 625 627 90 628 629 474 630 631 632 633 112 638 639 255 640 643 648 649 650 627 56 596 658 53 659 676 304 298 699 100 243 700 701 702 52 359 703 393 704 705 443 692 285 707 709 710 712 713...

result:

ok AC

Test #19:

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

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:

185 185 185 185 96 185 185 215 185 185 185 185 185 185 185 185 185 185 197 185 185 185 185 92 185 185 185 185 185 185 89 226 185 185 185 14 185 185 185 185 185 185 185 185 129 185 185 185 185 91 185 136 185 185 185 185 185 185 185 185 185 175 185 187 185 185 214 228 50 185 185 185 200 185 185 209 18...

result:

ok AC

Test #20:

score: 0
Accepted
time: 17ms
memory: 8784kb

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:

2 3 5 7 8 9 11 16 18 19 20 21 23 24 25 27 28 30 32 33 34 35 37 43 44 44 45 47 48 50 52 53 55 56 58 59 60 61 64 65 67 68 69 72 77 78 79 80 81 82 83 87 88 89 90 92 95 96 97 98 99 101 102 104 105 108 111 113 116 121 122 123 124 126 133 136 137 110 138 139 141 142 143 144 145 146 147 150 151 153 154 156...

result:

ok AC

Test #21:

score: 0
Accepted
time: 17ms
memory: 10344kb

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:

2 6 15 17 18 19 21 22 25 30 34 35 38 39 40 41 42 46 47 48 50 51 53 57 60 62 64 65 67 68 73 74 75 79 80 83 85 86 87 91 92 93 94 71 95 96 100 104 105 106 107 12 109 110 111 115 116 117 119 120 121 129 132 133 135 137 138 139 140 142 143 145 149 151 155 156 157 160 164 167 172 37 177 178 183 185 187 19...

result:

ok AC

Test #22:

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

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 5 6 7 9 11 12 14 15 17 18 23 24 28 31 34 35 44 45 30 51 54 57 58 59 60 61 65 73 75 76 78 89 90 91 92 94 95 98 99 101 102 105 107 109 114 119 120 121 122 123 125 126 127 129 130 132 133 134 135 137 138 139 142 143 144 147 154 158 159 161 162 164 165 166 168 169 170 172 15 178 183 184 186 192 19...

result:

ok AC

Test #23:

score: 0
Accepted
time: 15ms
memory: 10024kb

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 3 5 6 7 9 10 13 14 16 18 22 32 34 35 38 39 41 43 47 49 50 51 58 59 60 64 67 69 70 71 74 77 81 84 85 89 90 93 94 96 101 102 105 106 110 113 117 119 120 127 128 129 137 140 142 143 144 145 147 150 155 157 159 162 164 167 172 176 180 188 191 195 200 202 203 140 98 209 212 214 219 223 231 233 234 218 ...

result:

ok AC

Test #24:

score: 0
Accepted
time: 10ms
memory: 9908kb

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:

2 10 21 32 38 67 75 47 114 117 130 132 133 142 146 147 149 163 169 172 173 180 184 257 230 266 271 272 273 145 275 276 78 266 65 347 352 11 356 368 370 374 32 375 376 168 113 128 408 410 411 412 374 414 187 416 58 417 422 430 437 326 358 128 442 443 448 450 451 456 68 460 182 246 488 490 491 492 494...

result:

ok AC

Test #25:

score: 0
Accepted
time: 2ms
memory: 10108kb

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:

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

result:

ok AC

Test #26:

score: 0
Accepted
time: 2ms
memory: 10092kb

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

result:

ok AC

Test #27:

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

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: 2ms
memory: 8228kb

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: 10104kb

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:

1 1 1 1 1 1 1 2 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 #30:

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

input:

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

output:

1 2 1 1 1 1

result:

ok AC

Test #31:

score: 0
Accepted
time: 40ms
memory: 10652kb

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:

3483 3484 2451 3258 3485 1798 3486 80 1762 3487 3488 2923 1320 3181 3489 360 3490 3491 2861 3492 3493 142 3161 3494 3495 2231 3496 1069 57 2578 1152 1030 3497 3498 3499 2398 3500 404 347 569 886 3501 2139 3502 869 3503 720 3504 3505 3506 687 2419 3507 3508 3509 131 1344 2177 1149 2003 3510 606 930 3...

result:

ok AC