QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#97674#6329. Colorful Graphwhatever#AC ✓686ms7772kbC++144.0kb2023-04-17 21:08:282023-04-17 21:08:32

Judging History

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

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

answer

#include <bits/stdc++.h>
using namespace std;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
using pii = pair<int, int>;
using i64 = long long;
#define rep(i, a, b) for (int i = a, I = b; i <= I; ++i)
#define per(i, a, b) for (int i = a, I = b; i >= I; --i)
template<typename T> void up(T &x, T y) { if (x < y) x = y; }
template<typename T> void down(T &x, T y) { if (x > y) x = y; }

const int N = 7005, inf = 1e9;
int n, m, a[N], b[N], c[N], bel[N], stk[N], to[N], top, cnt, d[N];
vector<int> e1[N], e2[N];
bool vis[N];

void dfs1(int u) {
    vis[u] = 1;
    for (auto v : e2[u]) if (!vis[v]) dfs1(v);
    stk[++top] = u;
}
void dfs2(int u, int c) {
    bel[u] = c;
    for (auto v : e1[u]) if (!bel[v]) dfs2(v, c);
}

vector<int> A, B;
namespace flow {
	const int N = 14005, M = 123456;
	int n, s, t, d[N], que[N], cap[M], res;
	int cnt = 1, head[N], cur[N], to[M], nxt[M], val[M];

	void addedge(int u, int v, int w) {
		to[++cnt] = v;
        cap[cnt] = val[cnt] = w;
		nxt[cnt] = head[u];
		head[u] = cnt;
	}
	void add(int u, int v, int w) {
		addedge(u, v, w);
		addedge(v, u, 0); 
	}
	bool bfs() {
		int l = 1, r = 0;
		rep(i, 0, n) cur[i] = head[i], d[i] = 0;
		que[++r] = s, d[s] = 1;
		while (l <= r) {
			int u = que[l++];
			for (int i = head[u]; i; i = nxt[i]) {
				int v = to[i], w = val[i];
				if (d[v] || !w) continue;
				d[v] = d[u] + 1;
				que[++r] = v;
			}
		} 
		return d[t];
	}
	int dfs(int u, int flow) {
		if (u == t) return flow;
		int rest = flow;
		for (int &i = cur[u]; i; i = nxt[i]) {
			int v = to[i], w = val[i];
			if (d[v] != d[u] + 1 || !w) continue;
			int k = dfs(v, min(flow, w));
			if (!k) d[v] = 0;
			rest -= k;
			val[i] -= k, val[i ^ 1] += k; 
			if (!rest) break;
		}
		return flow - rest;
	}
	int dinic() {
		res = 0;
		while (bfs()) res += dfs(s, inf); 
		return res;
	}

    struct edge {
        int to, nxt, val;
    } e[M];
    int hd[N], tot;
    // void get_path(int u) {
        // for (int &i = hd[u]; i; ) {
        //     int v = e[i].to;
        //     if (!--e[i].val) i = e[i].nxt;
        //     get_path(v);
        //     if (v == t) B.push_back(u);
        //     if (u == s) A.push_back(v);
        // }
    // }
    void get_path(int u) {
        for (int &i = hd[u]; i; ) {
            int v = e[i].to;
            if (!--e[i].val) i = e[i].nxt;
            if (v == t) B.push_back(u);
            if (u == s) A.push_back(v);
            get_path(v);
            return;
        }
    }
    void solve() {
        rep(u, 0, n) {
            for (int i = head[u]; i; i = nxt[i]) {
                if (!cap[i]) continue;
                int f = cap[i] - val[i];
                if (!f) continue;
                int v = to[i];
                e[++tot] = {v, hd[u], f}, hd[u] = tot;
            }
        }
        while (res--) get_path(s);
        // get_path(s);
    }
}

int main() {
    // freopen("1.in", "r", stdin);
    ios::sync_with_stdio(0), cin.tie(0);

    cin >> n >> m;
    rep(i, 1, m) {
        cin >> a[i] >> b[i];
        e1[a[i]].push_back(b[i]);
        e2[b[i]].push_back(a[i]);
    }
    rep(i, 1, n) if (!vis[i]) dfs1(i);
    per(i, n, 1) {
        int u = stk[i];
        if (!bel[u]) dfs2(u, ++cnt);
    }
    
    flow::t = flow::n = 2 * cnt + 1;
    rep(i, 1, cnt) flow::add(flow::s, i, 1), flow::add(i + cnt, flow::t, 1);
    rep(i, 1, cnt) flow::add(i + cnt, i, inf);
    rep(i, 1, m) {
        int u = bel[a[i]], v = bel[b[i]];
        if (u == v) continue;
        flow::add(u, v + cnt, inf);
    }

    int res = flow::dinic();
    flow::solve();
    assert((int) A.size() == res);
    rep(i, 0, res - 1) {
        to[A[i]] = B[i] - cnt, ++d[B[i] - cnt];
        assert(d[B[i] - cnt] == 1);
    }
    int col = 0;
    rep(u, 1, cnt) {
        if (d[u]) continue;
        c[u] = ++col;
        int x = u;
        while (to[x]) x = to[x], c[x] = col;
    }
    rep(i, 1, n) cout << c[bel[i]] << " \n"[i == n];

    return 0;
}

詳細信息

Test #1:

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

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: 0ms
memory: 5800kb

input:

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

output:

2 2 1 2 2

result:

ok AC

Test #3:

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

input:

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

output:

4 4 4 4 3 4 2 1

result:

ok AC

Test #4:

score: 0
Accepted
time: 534ms
memory: 7060kb

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:

1750 107 414 203 632 557 745 377 655 1505 168 32 727 128 232 803 516 935 702 25 498 585 318 253 102 1581 793 849 334 23 1171 566 244 853 385 385 286 416 250 306 1525 614 1465 534 351 687 119 273 323 1431 879 826 1292 726 122 187 215 408 1031 1637 575 679 724 457 158 207 477 441 243 639 1397 710 1101...

result:

ok AC

Test #5:

score: 0
Accepted
time: 686ms
memory: 6932kb

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:

1747 1312 618 465 1723 614 886 671 127 1980 1947 291 349 1274 44 16 514 1854 1535 2330 245 1713 2095 1232 664 1809 848 1896 782 1568 1664 1764 485 632 797 982 1371 423 117 135 107 237 1187 305 1846 1829 21 1625 1124 1573 18 1533 2303 204 1811 452 6 1169 518 1462 228 1479 1515 1947 805 1558 307 617 1...

result:

ok AC

Test #6:

score: 0
Accepted
time: 674ms
memory: 7604kb

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:

2333 2332 464 319 103 319 165 1084 1720 1383 1148 1499 1625 902 632 529 390 385 1158 1690 701 267 1750 1446 551 266 731 413 1877 452 1792 471 1334 752 1410 705 411 421 94 1184 237 2073 1741 694 385 1175 685 303 523 45 377 1679 1672 1538 694 323 323 455 583 5 132 62 2294 2183 1827 1894 221 813 2109 1...

result:

ok AC

Test #7:

score: 0
Accepted
time: 177ms
memory: 7772kb

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:

1750 1 1 1 1 1 1 395 354 868 1 1 1 1 1 1443 1548 1 1 1043 1345 1 795 607 1367 1504 1428 1007 755 1514 1 740 1 1 1 1 1536 226 1 699 1 1 879 1 429 1 1269 1 555 1 1 1 1358 1326 1 1360 1 1 783 1 244 1 1 113 1 1139 272 1499 1 1743 1 1 1 1136 1 1 1 1 1 1 1 1017 1 895 1052 1145 887 1 1 1 1728 1523 1510 614...

result:

ok AC

Test #8:

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

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:

3499 3498 3497 3496 1073 2137 2963 2667 1045 3245 3304 2946 2868 434 1451 1008 3261 976 1642 218 125 576 292 2692 2646 2610 1106 3227 1215 1675 3387 1067 1081 119 3194 1331 1614 459 2240 515 971 1070 2272 1204 3088 2798 285 2970 2668 3457 2522 1552 3493 1088 263 2395 2422 2443 1605 2717 518 577 20 1...

result:

ok AC

Test #9:

score: 0
Accepted
time: 3ms
memory: 5676kb

input:

7000 0

output:

7000 6999 6998 6997 6996 6995 6994 6993 6992 6991 6990 6989 6988 6987 6986 6985 6984 6983 6982 6981 6980 6979 6978 6977 6976 6975 6974 6973 6972 6971 6970 6969 6968 6967 6966 6965 6964 6963 6962 6961 6960 6959 6958 6957 6956 6955 6954 6953 6952 6951 6950 6949 6948 6947 6946 6945 6944 6943 6942 6941 ...

result:

ok AC

Test #10:

score: 0
Accepted
time: 3ms
memory: 7556kb

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: 3ms
memory: 6944kb

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:

71 67 60 60 36 36 60 42 60 60 60 60 60 4 60 42 60 70 60 60 40 60 67 60 60 60 60 60 60 60 60 60 57 60 60 42 65 66 60 60 60 36 38 60 41 60 40 60 60 42 60 60 60 60 60 42 60 60 60 64 40 65 65 60 60 60 60 40 67 60 44 67 60 60 36 60 36 40 67 60 71 40 60 60 44 43 60 60 40 60 67 60 60 60 60 37 18 60 44 60 6...

result:

ok AC

Test #12:

score: 0
Accepted
time: 3ms
memory: 6908kb

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:

274 160 274 181 274 274 158 274 142 274 148 175 143 274 274 180 274 274 274 274 274 274 274 274 274 274 188 274 147 20 274 274 274 274 274 274 152 274 145 274 274 274 149 274 274 181 274 274 274 168 170 102 274 274 274 274 274 155 148 274 181 155 274 274 274 175 274 274 146 147 274 142 147 274 274 2...

result:

ok AC

Test #13:

score: 0
Accepted
time: 4ms
memory: 5340kb

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:

1049 262 753 1049 1049 934 938 709 632 798 929 1049 884 683 840 1049 649 839 736 682 874 1049 1049 892 737 1049 1049 566 862 1049 707 858 829 811 1049 903 1049 877 794 926 767 1049 931 654 1049 766 810 1049 1049 458 846 834 697 634 791 211 798 724 571 864 1049 1049 763 1049 1049 745 753 719 824 689 ...

result:

ok AC

Test #14:

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

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:

2618 2359 1014 1536 2359 174 1977 2359 1852 974 1409 1507 2359 1207 842 1734 1693 2359 1593 2033 2359 991 2359 1853 803 2359 1224 1323 1329 600 2359 561 2359 1703 2552 1785 1731 982 1594 1457 1583 254 2301 2523 2359 1710 2616 1591 2478 1522 1510 1995 2359 2031 2359 954 1484 1326 2071 1135 2096 2359 ...

result:

ok AC

Test #15:

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

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:

3009 3007 3006 3005 3004 3003 3002 3001 3000 2999 2994 2993 2972 2971 2936 2933 2931 2930 2927 2839 2830 2829 2828 2822 2817 2901 2815 2792 2785 2784 2804 2783 2790 2782 2781 2780 2778 2777 2767 2765 2764 2763 2762 2760 2703 2702 2701 2699 2698 2813 2690 2689 2685 2881 2684 2686 2683 2677 2672 2668 ...

result:

ok AC

Test #16:

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

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:

3001 2995 2994 2982 2980 2979 2977 2797 2796 2771 2769 2768 2767 2718 2717 2972 2687 2684 2683 2681 2676 2969 2675 2673 2972 2660 2659 2651 2649 2648 2647 2646 2645 2635 2727 2633 2756 2629 2628 2651 2924 2627 2624 2895 2608 2602 2588 2587 2586 2697 2585 2584 2583 2582 2581 2608 2772 2911 2564 2550 ...

result:

ok AC

Test #17:

score: 0
Accepted
time: 9ms
memory: 6892kb

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:

2927 2924 2923 2919 2583 2871 2691 2566 2565 2831 2704 2561 2560 2556 2825 2548 2547 2546 2538 2530 2518 2517 2513 2506 2501 2500 2499 2498 2678 2497 2665 2766 2496 2479 2476 2629 2888 2475 2472 2469 2467 2466 2899 2465 2859 2464 2460 2457 2441 2439 2433 2432 2431 2423 2601 2422 2421 2420 2768 2419 ...

result:

ok AC

Test #18:

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

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:

1836 1835 1834 1831 1911 1829 1983 2342 1822 2248 1821 1820 1819 1818 1817 1816 1815 1988 1813 1807 1806 1805 1792 1787 1784 1783 1935 1899 1777 1774 1773 1771 2297 1766 1764 1989 1895 1763 1762 1823 2064 1756 2317 1808 2225 1755 2032 2157 1754 1753 1851 1752 1751 1989 2176 2307 1750 2275 2290 2296 ...

result:

ok AC

Test #19:

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

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:

254 33 33 33 244 33 33 107 33 33 33 33 33 33 33 33 33 33 157 33 33 33 33 252 33 33 33 33 33 33 57 84 33 33 33 55 33 33 33 33 33 33 33 33 85 33 33 33 33 53 33 59 33 33 33 33 33 33 33 33 33 94 33 39 33 33 123 216 76 33 33 33 232 33 33 251 33 33 33 33 33 33 33 33 33 33 33 33 33 187 33 196 33 33 188 33 ...

result:

ok AC

Test #20:

score: 0
Accepted
time: 5ms
memory: 5612kb

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:

3618 3617 3613 3611 3610 3606 3604 3602 3601 3600 3596 3592 3591 3589 3588 3587 3582 3580 3574 3572 3570 3569 3567 3566 3565 3565 3562 3559 3558 3557 3555 3552 3551 3550 3556 3547 3546 3544 3541 3540 3539 3538 3537 3536 3533 3532 3531 3530 3529 3528 3527 3526 3525 3521 3520 3519 3518 3517 3514 3513 ...

result:

ok AC

Test #21:

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

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:

3659 3658 3657 3652 3651 3650 3648 3646 3645 3643 3642 3641 3640 3639 3637 3632 3631 3628 3627 3626 3624 3617 3616 3611 3605 3604 3603 3601 3600 3599 3598 3597 3596 3595 3594 3591 3590 3588 3587 3586 3585 3584 3583 3581 3578 3577 3576 3575 3571 3564 3563 3562 3560 3659 3559 3558 3557 3552 3550 3547 ...

result:

ok AC

Test #22:

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

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:

3620 3618 3615 3614 3613 3606 3601 3600 3597 3596 3593 3591 3590 3587 3586 3585 3584 3583 3579 3578 3577 3576 3575 3574 3573 3570 3565 3564 3562 3589 3561 3560 3581 3559 3557 3556 3554 3552 3549 3548 3547 3546 3544 3543 3542 3540 3539 3538 3537 3536 3535 3525 3516 3515 3513 3510 3509 3508 3507 3506 ...

result:

ok AC

Test #23:

score: 0
Accepted
time: 4ms
memory: 5448kb

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:

3130 3129 3127 3124 3122 3120 3118 3117 3111 3109 3105 3096 3095 3094 3093 3092 3091 3088 3086 3085 3084 3083 3082 3081 3080 3079 3078 3076 3074 3072 3071 3069 3068 3067 3066 3065 3064 3063 3059 3056 3050 3049 3048 3047 3044 3042 3040 3038 3036 3031 3015 3011 3006 3003 3001 2994 2993 2992 2991 2990 ...

result:

ok AC

Test #24:

score: 0
Accepted
time: 4ms
memory: 6692kb

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:

821 815 797 790 789 788 784 783 782 766 765 732 787 796 656 706 642 636 778 618 613 611 632 597 591 702 725 674 504 502 498 497 492 702 625 490 489 485 483 482 481 478 790 461 460 778 448 447 445 444 439 472 478 438 792 434 490 414 412 459 411 410 547 447 678 407 406 401 505 522 788 388 632 802 385 ...

result:

ok AC

Test #25:

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

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:

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

result:

ok AC

Test #26:

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

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:

245 244 243 242 241 240 239 238 237 236 235 234 233 232 231 231 230 229 228 227 226 225 224 223 222 221 220 219 218 238 217 216 215 213 212 211 210 209 208 207 206 205 204 203 202 201 200 199 198 244 197 196 195 194 193 192 191 227 190 189 188 186 185 184 183 182 181 180 179 178 177 176 175 174 173 ...

result:

ok AC

Test #27:

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

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: 3ms
memory: 5972kb

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

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 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

result:

ok AC

Test #30:

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

input:

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

output:

2 1 2 2 2 2

result:

ok AC

Test #31:

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

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:

3517 3516 2486 3293 850 1833 3312 115 1797 3143 1338 2958 1355 3216 1536 395 1553 516 2896 3415 2153 177 3196 3444 481 2266 3057 1104 92 2613 1187 1065 1649 2309 3484 2433 2958 439 382 604 921 410 2174 1996 904 2557 755 2659 801 1310 722 2454 139 1824 227 166 1379 2212 1184 2038 1994 641 965 2416 23...

result:

ok AC