QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#125479#6329. Colorful GraphEnergy_is_not_over#AC ✓559ms52884kbC++174.9kb2023-07-16 18:54:112023-07-16 18:54:13

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-16 18:54:13]
  • 评测
  • 测评结果:AC
  • 用时:559ms
  • 内存:52884kb
  • [2023-07-16 18:54:11]
  • 提交

answer

//#pragma GCC optimize("Ofast", "unroll-loops")
//#pragma GCC target("sse", "sse2", "sse3", "ssse3", "sse4")

#ifdef __APPLE__
#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstdint>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <random>
#include <deque>
#include <functional>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <complex>
#include <numeric>
#include <cassert>
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <thread>
#else
#include <bits/stdc++.h>
#endif

#define all(a) a.begin(),a.end()
#define len(a) (int)(a.size())
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define fi first
#define se second

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

template<typename T>
bool umin(T &a, T b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
bool umax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#if __APPLE__
#define D for (bool _FLAG = true; _FLAG; _FLAG = false)
#define LOG(...) print(#__VA_ARGS__" ::", __VA_ARGS__) << endl
template <class ...Ts> auto &print(Ts ...ts) { return ((cerr << ts << " "), ...); }
#else
#define D while (false)
#define LOG(...)
#endif

const int max_n = 7077, inf = 1000111222;

int N;
int used[max_n], nxt[max_n], pr[max_n];
bool f[max_n][max_n];

bool try_khun(int v) {
    if (used[v]) {
        return false;
    }
    used[v] = 1;
    for (int to = 0; to < N; ++to) {
        if (f[v][to] && pr[to] == -1) {
            pr[to] = v;
            nxt[v] = to;
            return true;
        }
    }
    for (int to = 0; to < N; ++to) {
        if (f[v][to] && try_khun(pr[to])) {
            pr[to] = v;
            nxt[v] = to;
            return true;
        }
    }
    return false;
}

vector<vector<int>> minimum_path_cover(int n) {
    memset(nxt, -1, sizeof(nxt));
    memset(pr, -1, sizeof(pr));
    N = n;
    for (int run = 1; run; ) {
        run = 0;
        ::memset(used, 0, sizeof(used));
        for (int i = 0; i < n; ++i) {
            if (nxt[i] == -1 && try_khun(i)) {
                run = 1;
            }
        }
    }
    vector<char> is_start(n, 1);
    for (int i = 0; i < n; ++i) {
//        cout << nxt[i] << endl;
        if (nxt[i] == -1) {
            continue;
        }
        is_start[nxt[i]] = 0;
    }
    vector<vector<int>> paths;
    for (int i = 0; i < n; ++i) {
        if (is_start[i]) {
            vector<int> path;
            for (int v = i; v != -1; v = nxt[v]) {
                path.push_back(v);
            }
            paths.push_back(path);
        }
    }
    return paths;
}

int n, m, pos_in_order[max_n];
vector<int> g[max_n], order;

void dfs(int v) {
    used[v] = 1;
    for (int to : g[v]) {
        if (!used[to]) {
            dfs(to);
        }
    }
    order.push_back(v);
}

void dfs2(int v, bool f[]) {
    f[pos_in_order[v]] = 1;
    for (int to : g[v]) {
        if (!f[pos_in_order[to]]) {
            dfs2(to, f);
        }
    }
}

int main() {
//    freopen("input_m.txt", "r", stdin);
//    freopen("input_m.txt", "w", stdout);

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    if (0) {
        n = m = 7000;
        for (int i = 0; i < m; ++i) {
            int u = rand() % n;
            int v = rand() % n;
            u = i;
            v = (i + 1) % m;
            g[u].push_back(v);
        }
    } else {
        cin >> n >> m;
        while (m--) {
            int u, v;
            cin >> u >> v;
            --u;
            --v;
            g[u].push_back(v);
        }
    }
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            dfs(i);
        }
    }
    reverse(order.begin(), order.end());
    for (int i = 0; i < order.size(); ++i) {
        pos_in_order[order[i]] = i;
    }
    for (int i = 0; i < order.size(); ++i) {
        assert(pos_in_order[order[i]] == i);
        dfs2(order[i], f[i]);
    }
    for (int i = 0; i < n; ++i) {
        ::memset(f[i], 0, i + 1);
    }
    if (0) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                cout << f[i][j];
            }
            cout << endl;
        }
    }
    auto paths = minimum_path_cover(n);
    vector<int> ans(n);
    int id = 0;
    for (auto path : paths) {
        ++id;
        for (int v : path) {
            ans[order[v]] = id;
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << ans[i] << " ";
    }
    cout << "\n";
}

詳細信息

Test #1:

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

input:

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

output:

1 1 1 2 1 

result:

ok AC

Test #2:

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

input:

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

output:

2 2 1 1 1 

result:

ok AC

Test #3:

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

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: 254ms
memory: 52476kb

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 569 1623 1022 1383 1749 1748 1072 1747 714 1342 373 1747 157 730 1746 596 1745 120 622 1690 1247 135 1227 1184 1744 1743 996 1500 1742 153 325 1741 1740 257 1241 1235 1739 111 1738 1427 1736 1737 252 1736 1625 1735 1060 1734 1733 1286 1732 1018 355 1546 476 850 1731 141 1730 72 564 1484 1205 16...

result:

ok AC

Test #5:

score: 0
Accepted
time: 135ms
memory: 52668kb

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:

2088 2098 827 544 469 1973 1566 1831 162 2236 2252 862 346 1945 1305 2333 1649 1371 1117 572 2332 1366 1951 1980 1550 242 706 2246 1570 1162 647 1564 1369 737 2331 2330 1887 983 332 994 2329 1624 2160 2328 1269 2327 528 2326 2325 2211 1616 2181 926 1863 502 593 2324 2323 2322 2321 204 113 2320 2202 ...

result:

ok AC

Test #6:

score: 0
Accepted
time: 199ms
memory: 52736kb

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 681 997 258 2331 1343 1853 1885 2330 1564 2329 2328 471 1789 534 2327 857 1737 1986 2002 2326 2325 516 1538 1109 2112 796 2324 2323 1682 2322 1010 2177 670 2321 1138 781 1499 2320 652 811 1827 2319 1055 1701 1942 1030 2318 116 872 2317 2037 118 1971 990 904 2316 414 14 2315 165 2314 479 15...

result:

ok AC

Test #7:

score: 0
Accepted
time: 208ms
memory: 52616kb

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 1406 1664 23 1501 1680 1522 1749 1397 1748 1576 155 56 712 1347 308 203 31 872 1747 406 1220 956 1144 384 247 323 744 1746 1745 1024 1744 885 233 1561 1434 215 1525 378 1052 1113 282 872 925 1743 1453 1742 1275 1741 1354 105 1188 1740 1739 970 1738 256 709 968 807 1737 1673 987 1638 792 1736 14...

result:

ok AC

Test #8:

score: 0
Accepted
time: 77ms
memory: 52500kb

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 2428 3495 3494 834 2456 256 197 555 3493 3067 3492 3491 3490 2525 3489 3488 3376 3487 3486 809 3485 3484 3483 3482 3481 1826 3480 2434 3479 3478 307 3477 1887 3042 3476 2986 2530 3475 3474 2297 413 3473 3472 3471 3470 3469 979 1949 8 3468 3238 1106 3467 3466 3465 3464 3463 2924 3...

result:

ok AC

Test #9:

score: 0
Accepted
time: 38ms
memory: 51948kb

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: 336ms
memory: 52612kb

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: 534ms
memory: 52884kb

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:

60 24 58 35 60 44 40 52 28 17 15 38 15 71 65 65 51 22 24 43 22 39 22 45 47 71 56 52 32 60 15 48 70 58 8 56 24 24 31 45 12 39 41 10 69 34 24 19 19 48 52 27 46 25 5 61 48 38 31 24 11 24 65 44 21 71 37 4 24 70 22 22 39 38 21 60 21 22 10 3 60 32 11 67 12 53 36 12 45 44 65 30 66 13 24 19 68 15 5 30 17 43...

result:

ok AC

Test #12:

score: 0
Accepted
time: 559ms
memory: 52860kb

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 274 204 130 158 170 130 102 57 105 171 191 57 235 235 227 124 98 205 68 181 69 213 128 176 85 222 97 64 273 90 10 31 117 99 183 209 187 57 113 162 133 259 171 6 211 153 83 200 145 43 272 257 25 241 4 127 146 143 156 203 160 102 5 164 236 224 10 193 145 179 7 160 14 142 152 50 59 271 43 248 109 75 ...

result:

ok AC

Test #13:

score: 0
Accepted
time: 376ms
memory: 52872kb

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 1049 224 6 483 699 609 121 993 791 781 402 1031 18 193 484 1042 518 1048 994 52 656 957 1047 910 523 956 1046 327 936 179 78 784 786 482 971 966 571 462 915 286 832 657 994 849 1045 58 533 471 1044 238 686 1043 1042 742 1041 603 1040 1040 955 681 974 1021 227 74 462 766 549 279 748 132 670 876 502...

result:

ok AC

Test #14:

score: 0
Accepted
time: 231ms
memory: 52512kb

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:

1804 2474 2618 972 1342 2617 1618 2291 752 2616 2541 2615 2185 2614 2613 198 1511 482 1620 70 205 2612 357 859 2611 91 2610 2609 2608 2607 326 2606 1780 2605 2522 974 46 1148 2604 1539 402 1296 2323 1370 1492 2135 2327 2110 2603 1507 1999 2011 1734 515 1560 166 1734 99 2602 2601 368 496 2173 2600 23...

result:

ok AC

Test #15:

score: 0
Accepted
time: 121ms
memory: 51108kb

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 3008 3007 3006 3005 3003 1003 3000 2999 2392 2997 2479 2994 1108 211 718 2982 2981 1617 2455 1913 2980 2184 2496 2979 2810 2473 2382 2974 1633 2968 2967 534 1386 1379 2965 2964 2963 1538 2962 2961 2960 2959 1813 1885 2958 2957 2262 1566 2698 2955 2799 2954 803 2953 1491 2952 2808 2950 1903 2949...

result:

ok AC

Test #16:

score: 0
Accepted
time: 188ms
memory: 51184kb

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:

1182 1745 2994 428 1105 2993 480 2992 2363 2991 2990 2305 1420 2981 2980 2974 2168 2973 1342 1591 2970 2969 2968 498 2974 1633 2034 1613 173 2023 2964 2963 2962 2116 2961 2960 343 389 2959 1613 2951 2950 1133 1980 2938 1757 1675 2949 2948 495 2947 1309 2940 2570 2939 2938 2937 96 2391 2936 1761 1111...

result:

ok AC

Test #17:

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

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 2925 2924 300 1607 1564 2919 2918 389 1469 2183 2373 399 2917 2916 1396 2913 739 1308 499 1850 2912 987 1413 2911 2910 107 2909 1577 2907 2687 2905 2904 1493 766 980 2903 2902 2861 2901 2900 2899 652 2898 2897 431 2896 522 2745 882 356 2893 2057 2892 2881 2880 2878 2877 902 2876 2875 2874 2151 ...

result:

ok AC

Test #18:

score: 0
Accepted
time: 204ms
memory: 47216kb

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:

2059 2392 242 2391 2147 2390 2389 1700 2388 2145 2387 2386 2385 2384 2383 2382 2381 2380 2218 2043 487 2379 38 2378 2071 2377 635 2376 2134 8 1198 1209 216 2374 2373 2371 947 1673 1002 1815 1041 289 88 1971 2333 2370 685 1719 2369 1289 508 504 2364 2371 1288 2361 2360 864 825 2352 327 690 2351 2350 ...

result:

ok AC

Test #19:

score: 0
Accepted
time: 189ms
memory: 25044kb

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 248 11 254 241 34 27 253 236 220 89 40 149 100 19 173 197 103 252 150 64 95 126 227 91 21 246 188 74 9 248 251 37 90 247 28 143 9 86 109 73 236 171 70 148 184 225 15 4 250 235 213 139 110 182 54 11 113 236 166 54 249 95 248 10 103 244 79 216 75 106 114 247 84 137 246 110 234 219 213 106 14 32 53...

result:

ok AC

Test #20:

score: 0
Accepted
time: 105ms
memory: 52396kb

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 1012 1127 3617 3616 2784 3615 1818 3614 3613 3246 3467 1645 3611 3610 421 700 3070 3609 2140 2311 3608 722 3607 1811 1811 1939 1755 3606 3604 2153 2269 3603 1315 258 3602 3601 1187 3600 3133 3599 1362 3598 3596 2805 3595 3594 771 3593 1647 3592 3591 3590 2890 3589 3588 3138 3587 808 3586 3585 3...

result:

ok AC

Test #21:

score: 0
Accepted
time: 105ms
memory: 51708kb

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:

882 3660 3658 2397 3657 2496 2899 1718 3656 3655 3654 3653 3652 3651 1375 595 1961 3650 23 1644 3649 1889 2424 2358 1121 1573 3647 2212 3646 3645 3644 3643 3642 3641 3640 3639 2870 3638 2612 3637 3636 492 3635 3634 1645 3633 3630 3629 2240 1296 3628 3068 89 3627 3626 3625 541 1963 3016 3624 3623 361...

result:

ok AC

Test #22:

score: 0
Accepted
time: 104ms
memory: 51600kb

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:

20 3622 1993 3621 3620 2953 3619 1066 3618 3617 3616 3615 749 3612 3611 3610 3608 1672 3607 3606 948 318 3605 3048 3603 2777 945 527 3602 3601 3600 3599 509 3598 3596 1714 3595 561 3594 3593 3591 3590 3589 3588 1730 3587 3586 3582 3581 3580 85 796 3579 3578 3577 3576 3575 3574 3573 3572 844 139 3571...

result:

ok AC

Test #23:

score: 0
Accepted
time: 101ms
memory: 47504kb

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 1850 1356 3128 1076 3127 3126 1082 3125 2056 3124 3119 1309 1686 3118 1437 1594 626 3117 3116 3115 3114 3113 2042 3112 1155 3109 1067 1038 3108 3106 3104 3101 963 1694 3100 3099 1276 2105 3096 2284 3095 3094 3092 1685 3091 3090 3089 103 3088 3087 1505 3086 3064 1573 3085 3084 1340 3083 308...

result:

ok AC

Test #24:

score: 0
Accepted
time: 60ms
memory: 24544kb

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:

399 825 222 823 312 819 589 818 402 817 622 371 716 279 816 93 686 814 813 234 812 545 174 805 649 801 178 746 804 600 803 802 387 801 794 793 792 11 390 791 790 777 823 501 789 117 782 781 780 73 779 778 777 653 776 775 52 420 774 773 250 771 587 781 398 770 767 561 763 75 23 482 174 756 755 737 75...

result:

ok AC

Test #25:

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

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:

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

result:

ok AC

Test #26:

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

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 202 244 243 242 241 240 238 237 236 235 234 233 232 56 56 231 230 229 228 168 132 227 226 225 224 223 222 221 238 220 219 218 217 216 215 214 213 212 211 210 209 208 207 39 206 205 204 203 202 201 200 199 198 197 196 195 228 194 193 192 175 191 190 189 188 187 186 98 185 184 182 181 180 179 3 17...

result:

ok AC

Test #27:

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

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

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

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

result:

ok AC

Test #30:

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

input:

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

output:

1 2 1 2 2 1 

result:

ok AC

Test #31:

score: 0
Accepted
time: 130ms
memory: 52736kb

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 1033 226 3515 1686 3514 3404 1722 3513 3512 561 2164 303 3511 3124 3510 3509 623 3508 3507 3342 323 3506 3505 1253 3504 2415 3427 906 2332 2454 3503 3502 3501 1086 3500 3080 3137 2915 2598 3499 1345 3498 2615 3497 2764 3496 3495 3494 2797 1065 3493 3492 3491 3353 2140 1307 2335 1481 3490 2...

result:

ok AC