QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#426588#6329. Colorful GraphCall_me_EricAC ✓954ms11408kbC++146.4kb2024-05-31 15:49:412024-05-31 15:49:41

Judging History

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

  • [2024-05-31 15:49:41]
  • 评测
  • 测评结果:AC
  • 用时:954ms
  • 内存:11408kb
  • [2024-05-31 15:49:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
bool stmemory;
namespace Call_me_Eric{
inline int read(){
    int x = 0, f = 1;char ch = getchar();
    while(ch < '0' || ch > '9'){if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = (x << 1) + (x << 3) + (ch ^ 48);ch = getchar();}
    return x * f;
}

const int maxn = 2e4 + 10,maxm = 8e4 + 10, INF = 0x3f3f3f3f;
int n, m;
struct edge1{
    int u, v, l, r;
    edge1(int u = 0,int v = 0,int l = 0,int r = 0):u(u),v(v),l(l),r(r){}
};
vector<pair<int,int> > ed[maxn];
int revin[maxn], revout[maxn];
namespace Dinic{
    const int maxn = 4e4 + 10;
    int total = 0;
    int head[maxn], tot = 1;
    struct edge{
        int to, nexte, cap, flow;
        edge(int to = 0,int ne = 0,int ca = 0,int fl = 0):to(to),nexte(ne),cap(ca),flow(fl){}
    }e[maxm * 2];
    void add(int u,int v,int cap){e[++tot] = edge(v,head[u],cap);head[u] = tot;}
    void addd(int u,int v,int cap){add(u,v,cap);add(v, u, 0);}

    int dep[maxn], cur[maxn];
    int dfs(int u,int flow,int T){
        // printf("%lld\n",u);
        if(u == T)return flow;
        int rest = 0, tmp = 0;
        for(int i = cur[u];i && flow;i = e[i].nexte){
            cur[u] = i; int v = e[i].to;
            if(e[i].cap - e[i].flow > 0 && (dep[v] == dep[u] + 1)){
                tmp = dfs(v,min(flow,e[i].cap - e[i].flow),T);
                if(tmp == 0)dep[v] = INF;
                e[i].flow += tmp; e[i ^ 1].flow -= tmp;
                flow -= tmp;rest += tmp;
                if(!flow)return rest;
            }
        }
        return rest;
    }
    bool bfs(int S,int T){
        queue<int> que;
        for(int i = 1;i <= total;i++){dep[i] = INF;cur[i] = 0;}
        que.push(S);dep[S] = 1; cur[S] = head[S];
        while(!que.empty()){
            int u = que.front(); que.pop();
            for(int i = head[u];i;i = e[i].nexte){
                int v = e[i].to;
                if(e[i].cap - e[i].flow > 0 && dep[v] == INF){
                    que.push(v);
                    cur[v] = head[v];
                    dep[v] = dep[u] + 1;
                    if(v == T)return 1;
                }
            }
        }
        return 0;
    }
    int Dinic(int S,int T){
        int mxflow = 0;
        while(bfs(S,T)){mxflow += dfs(S,INF,T);}
        return mxflow;
    }
    int in[maxn], out[maxn];
    int solve(vector<edge1> edgs,int S,int T,int ttt){
        total = ttt;int S1 = ++total;int T1 = ++total;
        for(edge1 edg : edgs){
            int u = edg.u, v = edg.v, l = edg.l, r = edg.r;
            in[v] += l;out[u] += l;addd(u, v, r - l);
        }
        int sum = 0;
        for(int i = 1;i <= total - 2;i++){
            if(in[i] > out[i]){addd(S1,i,in[i] - out[i]);sum += (in[i] - out[i]);}
            if(in[i] < out[i])addd(i,T1,out[i] - in[i]);
        }
        addd(T,S,INF);int pos = tot;
        int tmpp = Dinic(S1,T1);int res = e[pos ^ 1].flow;
        e[pos].flow = e[pos].cap;e[pos ^ 1].flow = e[pos ^ 1].cap;
        // for(int i = 1;i <= tot;i ++){
        //     cerr << "u = " << e[i ^ 1].to << " v = " << e[i].to << " cap = " << e[i].cap << " flow = " << e[i].flow << endl;
        //     // cerr << e[i ^ 1].to << " " << e[i].to << endl;
        // }
        int tmp = Dinic(T,S);
        cerr << "res = " << res << " tmp = " << tmp << endl;
        cerr << "dert = " << res - tmp << endl;
        for(int i = 2;i <= tot - 2;i += 2){
            int u = e[i ^ 1].to, v = e[i].to, rest = e[i].flow;
            if(revin[u] == revout[v])rest++;
            if(v <= total - 2 && v != S)ed[u].emplace_back(v, rest);
        }
        return res - tmp;
    }
};

vector<int> edg[maxn];
int dfn[maxn], low[maxn], idx;
bool book[maxn];stack<int> stk;
int color, col[maxn];vector<int> scc[maxn];
void Tarjan(int u){
    dfn[u] = low[u] = ++idx;
    stk.push(u);book[u] = 1;
    for(int v : edg[u]){
        if(!dfn[v]){Tarjan(v);low[u] = min(low[u], low[v]);}
        else if(book[v]){low[u] = min(low[u],dfn[v]);}
    }
    if(dfn[u] == low[u]){
        color++;int v = stk.top();
        do{
            v = stk.top();stk.pop();
            col[v] = color;
            scc[color].emplace_back(v);
            book[v] = 0;
        }while(v != u);
    }
}

vector<int> e[maxn];
int in[maxn], out[maxn];

int c[maxn];
void dfs(int u,int col,int T){
    // cerr << "u = " << u << " col = " << col << endl;
    if(u == T)return;if(revin[u] > 0) c[revin[u]] = col;
    for(auto &i : ed[u])if(i.second){dfs(i.first, col,T);i.second--;return;}
}


void main(){
    n = read(); m = read();
    for(int i = 1;i <= m;i++){
        int u, v;
        u = read(); v = read();
        edg[u].emplace_back(v);
    }
    for(int i = 1;i <= n;i++)if(!dfn[i])Tarjan(i);
    for(int u = 1;u <= n;u++)for(int v : edg[u]){
        if(col[v] != col[u])e[col[u]].emplace_back(col[v]);
    }

    int total = 0;int S = ++total;int T = ++total;total += 2;
    for(int i = 1;i <= 2;i++)revin[i] = -i,revout[i] = -i - 10;
    for(int i = 1;i <= color;i++){in[i] = ++total;out[i] = ++total;revin[in[i]] = revout[out[i]] = i;}
    for(int i = 1;i <= total;i++){if(revin[i] == 0)revin[i] = -i - 30;if(revout[i] == 0)revout[i] = -i - total - 10;}
    vector<edge1> edgs;
    for(int i = 1;i <= color;i++){
        sort(e[i].begin(),e[i].end());e[i].erase(unique(e[i].begin(),e[i].end()),e[i].end());
        for(int v : e[i])edgs.emplace_back(out[i],in[v],0, INF);
    }
    for(int i = 1;i <= color;i++){
        edgs.emplace_back(S,in[i],0,1); edgs.emplace_back(out[i],T,0,1);
        edgs.emplace_back(in[i],out[i],1,INF);
    }
    // cerr << "incnt = " << incnt << " outcnt = " << outcnt << endl;
    int res = Dinic::solve(edgs,S,T,total);
    
    // for(int u = 1;u <= total;u++){
    //     for(auto i : ed[u]){
    //         int v = i.first, w = i.second;
    //         cerr << "u = " << u << " v = " << v << " w = " << w << endl;
    //     }
    //     cerr << "revin = " << revin[u] << " revout = " << revout[u] << endl;
    // }
    for(int i = 1;i <= res;i++)dfs(S,i,T);

    for(int i = 1;i <= n;i++)printf("%d ",c[col[i]]);
    puts("");
    return;
}
};
bool edmemory;
signed main(){
    auto stclock = clock();
    Call_me_Eric::main();
    auto edclock = clock();
    cerr << (&stmemory - &edmemory) / 1024.0 / 1024.0 << " Mib cost.\n";
    cerr << (edclock - stclock) * 1.0 / CLOCKS_PER_SEC << " Sec cost.\n";
    return 0;
}

詳細信息

Test #1:

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

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: 1ms
memory: 9408kb

input:

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

output:

1 1 2 2 2 

result:

ok AC

Test #3:

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

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: 722ms
memory: 11408kb

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 1657 1326 1564 1746 2 3 1365 1110 1505 1750 1750 4 1750 1519 5 516 6 1061 25 1257 585 1747 1498 1662 7 8 1730 1404 9 1171 1198 10 11 1357 1358 286 12 1747 13 1525 1158 14 534 15 687 16 1747 17 18 890 19 1292 1746 1647 187 1747 20 1031 21 1192 1746 1746 1747 158 22 1747 1747 1506 23 24 710 25 981 2...

result:

ok AC

Test #5:

score: 0
Accepted
time: 954ms
memory: 11288kb

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:

2332 2332 618 465 1723 2332 886 671 2332 2324 2324 2332 2332 1274 2333 1 2332 2332 2332 2330 2 1713 2095 1232 2332 2332 848 1896 782 1568 1664 2332 2332 2332 3 4 1371 2332 117 135 5 237 1187 6 1846 7 21 8 9 1573 18 1533 2303 204 1811 2332 10 11 12 13 2332 2332 14 2324 805 1558 2332 617 2332 2264 15 ...

result:

ok AC

Test #6:

score: 0
Accepted
time: 921ms
memory: 11064kb

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 2256 3 165 1084 1720 4 1209 5 6 1456 1755 529 7 385 1158 1690 1683 8 9 1446 1840 266 1643 413 10 11 1792 12 1334 1621 1410 13 1970 421 94 14 2126 2073 1741 15 1998 1177 1705 303 16 2298 377 17 1672 1538 1695 323 2043 18 583 2329 19 2282 20 2183 1827 1894 221 813 21 22 23 24 25 1078 1909 ...

result:

ok AC

Test #7:

score: 0
Accepted
time: 363ms
memory: 11252kb

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 1750 1750 1750 1750 1750 1750 2 354 3 1750 1750 1750 1750 1750 1443 1548 1750 1750 4 1345 1750 795 607 1367 1504 1428 1007 5 6 1750 7 1750 1750 1750 1750 1536 226 1750 699 1750 1750 879 1750 8 1750 9 1750 10 1750 1750 1750 11 12 1750 13 1750 1750 783 1750 14 1750 1750 113 1750 15 272 1499 1750 174...

result:

ok AC

Test #8:

score: 0
Accepted
time: 16ms
memory: 10860kb

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: 19ms
memory: 10320kb

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

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: 4ms
memory: 10380kb

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:

44 50 70 70 40 40 70 67 70 70 70 70 70 1 70 67 70 41 70 70 20 70 50 70 70 70 70 70 70 70 70 70 2 70 70 67 7 28 70 70 70 40 16 70 3 70 20 70 70 67 70 70 70 70 70 67 70 70 70 48 20 7 7 70 70 70 70 71 50 70 65 50 70 70 40 70 53 71 50 70 44 27 70 70 13 55 70 70 27 70 50 70 70 70 70 31 4 70 13 70 70 70 7...

result:

ok AC

Test #12:

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

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 1 274 62 274 274 72 274 218 274 16 259 74 274 274 75 274 274 274 274 274 274 274 274 274 274 213 274 130 2 274 274 274 274 274 274 195 274 115 274 274 274 215 274 274 62 274 274 274 176 232 3 274 274 274 274 274 49 16 274 62 84 274 274 274 259 274 274 20 104 274 268 130 274 274 274 274 274 4 68 ...

result:

ok AC

Test #13:

score: 0
Accepted
time: 8ms
memory: 10608kb

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 1 105 1049 1049 354 880 565 666 259 385 1049 1034 348 955 1049 668 676 2 410 998 1049 1049 3 846 1049 1049 4 451 1049 308 769 741 264 1049 445 1049 1011 622 236 934 1049 393 764 1049 5 992 1049 1049 6 845 466 7 8 961 9 259 414 10 759 1049 1049 277 1049 1049 889 105 374 92 376 1049 1049 1049 104...

result:

ok AC

Test #14:

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

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:

815 2604 1 1647 2604 2 1001 2604 1867 3 1554 4 2604 5 6 2421 136 2604 999 1808 2604 7 2604 1684 8 2604 9 10 11 12 2604 13 2604 14 97 933 1995 1471 15 1080 2217 1323 296 576 2604 90 292 509 16 2364 620 1356 2604 2104 2604 2453 885 2520 17 18 2251 2604 901 19 2382 20 125 21 2302 22 732 1149 23 1469 11...

result:

ok AC

Test #15:

score: 0
Accepted
time: 16ms
memory: 10632kb

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 4 5 7 2008 10 11 620 13 535 17 1903 2799 2292 34 35 895 2650 1099 36 827 797 37 208 540 1388 41 1379 48 49 2557 1625 1632 51 52 53 1473 54 55 56 57 1199 1127 58 59 750 1446 315 61 217 62 952 64 1520 65 2169 67 2609 68 720 2521 70 933 71 990 2886 72 1477 75 750 1804 239 76 1803 78 2507 82 83 13...

result:

ok AC

Test #16:

score: 0
Accepted
time: 19ms
memory: 10732kb

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:

1820 1258 12 2574 1897 13 2522 14 1868 15 16 697 1582 25 26 31 833 32 1660 1411 35 36 37 2504 1285 1369 969 1389 2829 980 40 41 42 885 43 44 2787 2613 45 1389 53 54 1869 424 66 1593 1327 55 56 2807 57 1693 64 435 65 66 67 2989 2750 68 2989 1891 363 2354 69 1218 1061 71 72 2069 73 892 74 75 95 1971 9...

result:

ok AC

Test #17:

score: 0
Accepted
time: 18ms
memory: 10744kb

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 3 4 2628 1975 1363 9 10 2539 11 746 556 2529 12 13 16 17 1465 2345 2429 1079 18 1941 1515 19 20 2821 21 1350 23 1859 25 26 2809 2162 1948 27 28 68 29 30 31 2722 32 33 2453 34 2406 2802 2046 2572 38 872 39 48 49 51 52 382 53 54 55 203 2217 1339 56 1945 1388 1131 2472 59 60 61 62 63 213 944 2446 258...

result:

ok AC

Test #18:

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

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:

335 1 2151 2 438 3 4 32 5 247 6 7 8 9 10 11 12 18 176 351 19 20 1668 21 1234 22 1043 23 258 2385 1196 1185 1331 25 26 27 68 723 1392 342 1353 2104 2305 423 961 28 1708 1217 29 1106 1885 1889 34 27 1878 37 38 2051 1568 42 2066 2384 43 44 45 46 47 2057 668 17 1094 48 49 1145 50 2159 1913 52 53 54 55 5...

result:

ok AC

Test #19:

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

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:

1 254 254 254 14 254 254 2 254 254 254 254 254 254 254 254 254 254 3 254 254 254 254 28 254 254 254 254 254 254 89 4 254 254 254 241 254 254 254 254 254 254 254 254 132 254 254 254 254 5 254 42 254 254 254 254 254 254 254 254 254 6 254 7 254 254 29 176 71 254 254 254 8 254 254 9 254 254 254 254 254 ...

result:

ok AC

Test #20:

score: 0
Accepted
time: 18ms
memory: 10780kb

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:

1 2607 2492 2 3 833 4 1802 5 6 372 152 1974 8 9 3198 2919 717 10 1480 1307 11 2897 12 1809 1809 1681 1865 13 15 1466 1350 16 2304 3361 17 18 2432 19 484 20 2257 21 23 812 24 25 2848 26 1972 27 28 29 727 30 31 479 32 2811 33 34 35 480 293 36 38 39 2481 42 1369 43 44 45 46 362 47 48 49 50 2945 51 1020...

result:

ok AC

Test #21:

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

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:

2780 2 4 1267 5 1168 765 1945 6 7 8 9 10 11 2287 3067 1702 12 3639 2019 13 1774 893 1088 2541 2090 15 3585 16 17 18 19 20 21 22 23 794 24 1053 25 1997 3170 26 27 2018 28 31 32 1423 2366 33 595 3573 34 35 36 3121 1700 648 37 38 42 43 3372 2093 44 309 45 2812 3227 46 47 48 50 51 52 53 3322 56 938 57 2...

result:

ok AC

Test #22:

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

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:

3603 1 2 3 4 670 5 3492 6 7 8 9 2874 12 13 14 16 1951 17 18 2675 3305 19 577 21 845 2678 3096 22 23 24 25 3114 1861 27 1909 28 3062 29 30 32 33 34 35 1893 36 37 41 42 43 3538 2827 44 45 46 47 48 49 50 51 2779 917 52 53 54 2627 56 1691 57 59 118 60 61 484 62 2551 63 64 65 1452 66 68 69 73 74 76 78 79...

result:

ok AC

Test #23:

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

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 2 1281 1775 3 2055 4 5 94 6 2296 7 12 1822 1445 13 1695 1537 2505 14 15 16 17 18 1091 19 1976 22 2064 2093 23 25 27 30 2168 1437 31 32 1855 1029 35 851 36 37 39 1446 40 41 42 3028 43 44 1627 46 69 47 48 49 1791 50 51 450 189 53 1827 1984 54 56 705 59 61 62 63 66 67 68 69 70 2781 71 72 76 2186 2473...

result:

ok AC

Test #24:

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

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:

427 2 306 4 6 8 371 9 424 10 200 758 794 426 11 558 136 788 12 153 13 277 350 19 778 24 648 77 21 249 22 23 652 24 30 31 32 170 436 33 58 44 4 324 34 709 39 40 41 753 42 43 44 135 45 46 31 406 47 48 576 50 235 40 428 51 54 261 759 751 384 343 185 66 67 584 68 190 69 476 235 71 333 72 719 72 617 547 ...

result:

ok AC

Test #25:

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

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:

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

result:

ok AC

Test #26:

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

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

result:

ok AC

Test #27:

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

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

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

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

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: 16ms
memory: 10548kb

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 2486 3293 3 1833 4 115 1797 5 6 2958 1355 3216 7 395 8 9 2896 10 11 177 3196 12 13 2266 14 1104 92 2613 1187 1065 15 16 17 2433 18 439 382 604 921 19 2174 20 904 21 755 22 23 24 722 2454 25 26 27 166 1379 2212 1184 2038 28 641 965 29 2303 30 31 3320 514 32 947 33 34 1030 2845 35 1703 36 37 38 39...

result:

ok AC