QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#375295#5208. Jumbled TreesInfinityNSRE 140ms8024kbC++209.0kb2024-04-03 05:35:532024-04-03 05:35:53

Judging History

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

  • [2024-04-03 05:35:53]
  • 评测
  • 测评结果:RE
  • 用时:140ms
  • 内存:8024kb
  • [2024-04-03 05:35:53]
  • 提交

answer

#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
using namespace std;
typedef pair<int,int> pii;

int mod=998244353;
inline int add(int x,int y){int ret=x+y;if(ret>=mod)ret-=mod;return ret;}
inline int sub(int x,int y){int ret=x-y;if(ret<0)ret+=mod;return ret;}
inline int mul(int x,int y){return ((ll)x*y)%mod;}
inline int step(int base,int pw){int ret=1;while(pw){if(pw&1)ret=mul(ret,base);base=mul(base,base);pw>>=1;}return ret;}
inline int invv(int x){return step(x,mod-2);}


const int maxn=1010;

namespace flow{

    struct edge{
        int u,v;
        ll f,c;
        int eid;
    };
    vector<edge>e;
    const int maxn=2010;
    int fpos[maxn];
    vector<int>vect[maxn];
    int s,t;
    int n;

    void real_add_edge(int u,int v,int cap,int eid){

        vect[u].pb(e.size());
        e.pb({u,v,0,cap,eid});

        vect[v].pb(e.size());
        e.pb({v,u,cap,cap,eid});
    }
    void rem_real_add_edge(int u,int v){

        vect[u].pop_back();
        e.pop_back();

        vect[v].pop_back();
        e.pop_back();
    }

    void init(){
        for(int i=1;i<=n;i++)
            real_add_edge(i,i+n,1,-1);
        s=0;
        t=2*n+1;
    }

    void add_edge(int u,int v,int cap,int eid){
        ///u+n -> v
        real_add_edge(u+n,v,cap,eid);
    }
    ll send_flow(int x,ll flow){

        if(x==t)return flow;

        fpos[x]=1;
        for(int i=0;i<vect[x].size();i++){

            int id=vect[x][i];

            if(e[id].c>e[id].f && fpos[e[id].v]==0){

                ll temp_flow=send_flow(e[id].v,min(flow,e[id].c-e[id].f));

                if(temp_flow){

                    e[id].f+=temp_flow;
                    e[id^1].f-=temp_flow;

                    return temp_flow;
                }

            }

        }

        return 0;
    }
    vector<int> get_flow(int s1,int s2,int t1,int t2){

        for(int i=0;i<e.size();i+=2){
            e[i].f=0;
            e[i^1].f=e[i^1].c;
        }

        real_add_edge(s,s1,1,-1);
        real_add_edge(s,s2,1,-1);
        real_add_edge(t1+n,t,1,-1);
        real_add_edge(t2+n,t,1,-1);

        ///printf("%d %d | %d %d FIND\n",s1,s2,t1,t2);
        for(int i=0;i<2;i++){
            //printf("%d flow\n",i);
            memset(fpos,0,sizeof(fpos));
            send_flow(s,1);
            //printf("%d flow\n",i);
            ///assert(send_flow(s,1)==1);
        }

        rem_real_add_edge(s,s1);
        rem_real_add_edge(s,s2);
        rem_real_add_edge(t1+n,t);
        rem_real_add_edge(t2+n,t);

        vector<int>ret;
        for(int i=0;i<e.size();i++){
            int a=e[i].u;
            int b=e[i].v;
            int f=e[i].f;
            if(a>n && a<t && b<=n && b>=1 && f && e[i].eid!=-1){
                ret.pb(e[i].eid);
                if(e[i].eid==-1)printf("%d %d %d %d dodao\n",a,b,n,ret.back());
            }
        }
        ///printf(" EDGES\n");

        return ret;

    }

}

struct edge{
    int a,b,w;
};

vector<edge>e;
vector<int>vect[maxn];
vector<pii>scand;


void add_edge(int a,int b,int w){
    vect[a].pb(e.size());
    vect[b].pb(e.size());
    e.pb({a,b,w});
    flow::add_edge(a,b,1,e.size()-1);
    flow::add_edge(b,a,1,e.size()-1);
}

int disc[maxn],mint[maxn],ctm;
int get_nxt(int eid,int x){
    if(e[eid].a==x)return e[eid].b;
    return e[eid].a;
}
int ecol[maxn],ncnt;
int compsum[maxn];
int pos[maxn];
int s;
int n,m;
void obradi(vector<int>edges){

    memset(pos,0,sizeof(pos));

    ncnt++;
    for(int i=0;i<edges.size();i++){
        int id=edges[i];

        //printf("%d ",id);

        pos[e[id].a]=1;
        pos[e[id].b]=1;

        ecol[id]=ncnt;
        compsum[ncnt]=add(compsum[ncnt],e[id].w);
    }
    //printf(" OB\n");
    int sz=-1;
    for(int i=1;i<=n;i++){
        sz+=pos[i];
    }

    scand.pb({compsum[ncnt],sz});

}
void find_bridges(int x,int p,vector<int>&stek){

    disc[x]=++ctm;
    mint[x]=disc[x];
    ///printf("%d %d XX\n",x,disc[x]);
    for(int i=0;i<vect[x].size();i++){
        int id=vect[x][i];
        if(id==p)continue;

        int nxt=get_nxt(vect[x][i],x);

        if(disc[nxt]<disc[x])stek.pb(id);

        if(disc[nxt])mint[x]=min(mint[x],disc[nxt]);
        else{
            find_bridges(nxt,id,stek);
            mint[x]=min(mint[x],mint[nxt]);

            if(mint[nxt]>=disc[x]){

                /*printf("%d %d %d EDGE\n",x,nxt,id);
                for(int i=0;i<stek.size();i++)printf("%d ",stek[i]);
                printf(" STEK\n");*/

                vector<int>edges;
                while(stek.back()!=id){
                    ///printf("%d sz\n",stek.size());
                    edges.pb(stek.back());
                    stek.pop_back();
                }
                edges.pb(stek.back());
                stek.pop_back();

                obradi(edges);

            }

        }

        //printf("%d %d | %d %d AAA\n",x,e[id].b,mint[e[id].b],disc[x]);
    }

///printf("%d RET\n",x);

}

bool calc_s(){

    int ep=0;
    s=0;
    for(int i=0;i<scand.size();i++){
        int v=scand[i].ff;
        int cc=scand[i].ss;

       // printf("%d %d \n",v,cc);

        if(cc==0){
            if(v!=0)return false;
        }
        else{
            int pom=mul(v,invv(cc));
            if(ep==0){
                ep=1;
                s=pom;
            }
            else{
                if(s!=pom)return false;
            }
        }

    }
    return true;
}

vector<pair<int,vector<int>>>ops;
void apply_mst(int v,vector<int>o){

    if(o.size()!=n-1){
        printf("%d SZ | ",o.size());
        for(int i=o.size()-1;i>=0;i--){
            int id=o[i];
            printf("%d %d %d | ",id,e[id].a,e[id].b);
        }
        printf("\n");
        fflush(stdout);
    }
    assert(o.size()==n-1);

    ops.pb({v,o});
    for(int i=0;i<o.size();i++){
        int id=o[i];
        e[id].w=sub(e[id].w,v);
        //printf("%d ",id);
    }
    /*printf(" | %d APPLIED\n",v);
    for(int i=0;i<e.size();i++){
        printf("%d ",e[i].w);
    }
    printf(" STATE\n");*/
}

void dfs(int x,int p,vector<int>&es){
    pos[x]=1;
    ///printf("%d dOSO\n",x);
    for(int i=0;i<vect[x].size();i++){
        int id=get_nxt(vect[x][i],x);
        if(pos[id])continue;
        es.pb(vect[x][i]);
        dfs(id,vect[x][i],es);
    }
}
void apply_rand_mst(){

    vector<int>edges;
    memset(pos,0,sizeof(pos));
    dfs(1,-1,edges);
    apply_mst(s,edges);

}
void solve_comp(int c){

    vector<int>cand;
    for(int i=0;i<e.size();i++){
        if(ecol[i]==c)cand.pb(i);
    }

    while(cand.size()){
        int id=cand.back();
        cand.pop_back();
        if(e[id].w==0)continue;
        int id2=cand.back();
        vector<int>es=flow::get_flow(e[id].a,e[id].b,e[id2].a,e[id2].b);
        es.pb(id);
        es.pb(id2);

        //assert(id!=id2);

        /*for(int i=0;i<es.size();i++){
            int id=es[i];
            printf("%d %d |",e[id].a,e[id].b);
        }
        printf(" -> %d %d | %d %d  CIKLUS\n",e[id].a,e[id].b,e[id2].a,e[id2].b);*/

        memset(pos,0,sizeof(pos));
        for(int j=0;j<es.size();j++){
            int id=es[j];
            //printf("%d AAA\n",id);
            pos[e[id].b]=1;
            pos[e[id].a]=1;
        }

        //cout<<"IDE FLOW33"<<endl;

        vector<int>qry,qry2;
        for(int j=0;j<es.size();j++){
            int id=es[j];
            dfs(e[id].a,-1,qry);
            dfs(e[id].b,-1,qry);
        }
        //cout<<"IDE FLOW44"<<endl;

        qry2=qry;
        /*for(int j=0;j<qry.size();j++){
            int id=qry[j];
            printf("%d %d |",e[id].a,e[id].b);
        }
        printf(" TREE\n");*/

        for(int j=0;j<es.size();j++){
            int idc=es[j];
            if(idc==id)qry.pb(idc);
            else if(idc==id2)qry2.pb(idc);
            else{
                qry.pb(idc);
                qry2.pb(idc);
            }
        }
        ///printf("%d %d %d SIZES\n",qry.size(),qry2.size(),es.size());

        ///if(qry.size()!=n-1)while(1){}

        int goal=e[id].w;
        apply_mst(goal,qry);
        apply_mst(sub(0,goal),qry2);
    }

}

int main(){

    //freopen("test.txt","r",stdin);

    scanf("%d %d %d",&n,&m,&mod);

    flow::n=n;
    flow::init();

    for(int i=1;i<=m;i++){
        int u,v,w;
        scanf("%d %d %d",&u,&v,&w);
        add_edge(u,v,w);

    }

    vector<int>stek;
    find_bridges(1,-1,stek);


    if(!calc_s()){
        printf("-1\n");
        return 0;
    }

    ///printf("%d SS\n",s);
    apply_rand_mst();

    for(int i=1;i<=ncnt;i++){
        solve_comp(i);
    }

    printf("%d\n",ops.size());
    for(int i=0;i<ops.size();i++){
        printf("%d ",ops[i].ff);
        vector<int>&pom=ops[i].ss;
        for(auto x:pom)printf("%d ",x+1);
        printf("\n");
    }

    return 0;
}

詳細信息

Test #1:

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

input:

3 3 101
1 2 30
2 3 40
3 1 50

output:

5
60 1 2 
50 1 3 
51 1 2 
30 3 2 
71 3 1 

result:

ok Participant found an answer (5 trees) and jury found an answer (5 trees)

Test #2:

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

input:

2 2 37
1 2 8
1 2 15

output:

3
23 1 
15 2 
22 1 

result:

ok Participant found an answer (3 trees) and jury found an answer (3 trees)

Test #3:

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

input:

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

output:

-1

result:

ok Both jury and participant did not find an answer

Test #4:

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

input:

10 15 997
4 3 459
9 7 94
9 8 767
10 2 877
5 8 258
3 4 166
8 5 621
8 10 619
9 1 316
10 5 516
3 10 125
1 7 961
3 6 500
4 10 976
3 4 842

output:

-1

result:

ok Both jury and participant did not find an answer

Test #5:

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

input:

20 30 9973
1 10 696
3 8 2905
12 7 6609
20 10 1962
11 9 8430
19 2 412
6 3 6936
19 7 9113
14 15 5635
15 7 1770
13 10 3182
3 16 2625
17 1 7387
11 5 3700
9 15 1048
2 3 7717
12 10 8625
7 13 8141
5 14 2245
6 4 2819
18 19 8709
18 5 6191
17 10 7606
9 20 8626
17 4 8848
4 13 1073
10 8 2277
14 2 7714
11 8 5318...

output:

59
9375 1 4 24 5 14 19 9 10 3 8 6 16 2 7 20 25 26 12 21 
9860 7 20 25 13 1 4 24 15 9 28 6 8 3 18 21 2 12 14 30 
113 7 20 25 13 1 4 24 15 9 28 6 8 3 18 21 2 12 14 29 
5205 11 18 3 12 1 2 4 6 7 9 13 14 15 20 21 22 24 25 29 
4768 11 18 3 12 1 2 4 6 7 9 13 14 15 20 21 22 24 25 28 
2946 12 1 13 17 15 21 ...

result:

ok Participant found an answer (59 trees) and jury found an answer (59 trees)

Test #6:

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

input:

50 80 99991
6 5 67664
39 4 74944
11 9 13035
13 48 81979
40 20 57943
20 31 72081
1 6 39307
48 39 3550
28 48 41071
18 28 42935
37 32 7538
37 29 3815
50 37 88043
38 41 7283
40 26 66278
37 34 60696
47 19 80875
4 26 67
20 32 91858
39 24 83485
45 25 12241
48 46 61691
37 44 47541
39 40 70034
37 42 25006
27...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #7:

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

input:

100 150 999983
84 10 999545
69 48 930138
48 13 303468
36 6 668122
91 84 115623
62 71 59711
12 37 749281
86 49 281976
26 46 624831
91 8 450475
92 55 460900
50 63 513056
72 2 477622
26 96 11359
31 82 953946
6 71 406339
24 7 177090
70 4 67359
31 39 795565
47 32 407459
26 35 760698
22 37 508175
8 93 612...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #8:

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

input:

200 250 9999991
170 185 3242943
70 17 6083198
137 55 4000889
15 171 1113989
108 65 7988488
192 37 8812990
53 143 8707264
80 180 2504807
55 163 2706048
67 64 6210980
87 165 7693967
155 122 8550804
56 99 7228534
114 138 7047731
190 196 6684929
86 197 8866886
38 195 6717874
112 133 7257617
160 104 3210...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #9:

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

input:

500 600 99999989
265 416 47066772
354 266 16969437
195 415 7917612
354 136 43128175
163 191 58723996
144 84 65835385
157 45 94124747
232 441 17509499
70 397 64101208
223 387 7043647
320 47 84970673
100 2 87310855
87 131 75042257
101 391 27645446
79 26 68547739
390 185 92142961
257 15 80922292
276 48...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #10:

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

input:

500 700 99999989
250 2 71289880
454 447 70661327
328 253 57519343
11 201 67456781
294 99 23392419
215 322 61059212
411 389 69899684
488 429 89579827
437 79 60564061
413 380 34922641
477 372 14858185
156 44 3101349
88 8 52225146
115 26 8582010
171 237 33206748
237 495 31192017
146 32 62712576
209 352...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #11:

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

input:

500 800 99999989
258 304 1237432
159 152 6684056
8 47 64155938
436 265 83092505
204 302 3892712
142 302 77925167
37 15 20298972
202 395 35856655
284 260 96812598
365 172 48834835
196 101 64871741
174 45 37729972
302 206 90932677
305 275 27712443
443 157 81820535
16 248 22708463
461 479 64749118
105 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #12:

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

input:

500 900 99999989
122 188 44796717
73 121 56798468
334 358 95823235
485 453 96779071
209 391 45946094
332 168 91056077
481 483 81268636
148 393 25213027
107 214 99281713
493 46 61525618
472 355 74320568
258 482 99615552
159 393 20311839
411 121 5207095
20 131 65269699
45 339 51772607
195 292 64556504...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #13:

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

input:

500 1000 99999989
75 20 25003980
292 19 89418683
353 246 74910681
183 201 97535184
254 421 50614221
15 396 86624029
82 13 67776336
86 70 62843451
279 3 55801636
29 425 30024776
176 243 16631048
498 363 77415492
55 305 80862521
213 110 30693079
432 358 99667002
201 30 44433122
97 203 16284993
118 490...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #14:

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

input:

500 499 999999937
287 228 350409600
392 107 350409600
458 22 350409600
362 425 350409600
368 136 350409600
364 71 350409600
211 265 350409600
167 116 350409600
195 353 350409600
489 477 350409600
380 85 350409600
281 15 350409600
263 247 350409600
453 122 350409600
104 187 350409600
331 223 35040960...

output:

1
350409600 214 267 66 113 137 376 28 30 432 370 389 364 42 399 117 272 241 35 285 232 329 483 227 244 11 419 333 47 24 171 83 306 258 61 324 19 298 231 216 280 464 249 439 206 134 336 383 43 158 86 179 436 470 135 192 475 366 388 265 72 348 368 458 484 401 130 136 235 450 52 3 199 417 266 477 166 4...

result:

ok Participant found an answer (1 trees) and jury found an answer (1 trees)

Test #15:

score: 0
Accepted
time: 12ms
memory: 4656kb

input:

500 510 999999937
417 280 770450784
207 303 770450784
472 396 770450784
345 191 964169440
164 67 770450784
492 302 770450784
5 71 770450784
386 22 770450784
77 25 487491058
430 467 770450784
148 95 770450784
288 215 770450784
55 451 10190666
215 69 770450784
267 195 770450784
487 283 770450784
435 3...

output:

257
770450784 381 49 153 33 160 116 499 187 4 415 222 50 95 19 28 55 411 361 375 82 61 9 265 30 440 85 173 59 201 252 147 214 262 191 431 3 359 110 23 150 74 8 244 259 205 473 443 17 398 355 353 139 68 216 58 32 363 131 41 352 482 496 70 292 442 155 158 319 407 31 80 373 130 83 99 132 91 129 21 264 ...

result:

ok Participant found an answer (257 trees) and jury found an answer (257 trees)

Test #16:

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

input:

500 525 999999937
439 54 982774700
417 443 87702331
21 82 982774700
39 477 982774700
363 493 982774700
500 161 982774700
86 44 982774700
312 47 982774700
120 282 982774700
224 254 670954686
268 311 59221562
216 242 982774700
16 256 505585800
448 102 982774700
362 295 555877345
76 210 819076841
53 24...

output:

395
982774700 375 485 199 21 30 137 64 374 43 381 156 141 440 120 324 119 502 233 192 132 65 160 83 336 98 256 134 14 224 5 354 4 67 298 95 510 286 353 216 449 237 398 35 171 188 404 383 2 87 295 270 250 51 219 407 248 469 273 173 45 402 108 10 143 265 153 63 176 271 405 218 487 230 323 25 128 66 32...

result:

ok Participant found an answer (395 trees) and jury found an answer (395 trees)

Test #17:

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

input:

500 550 999999937
478 408 544946602
494 234 544946602
118 11 544946602
497 38 435997116
193 371 493919798
252 238 826125135
69 229 683109191
300 159 544946602
328 102 302951499
37 227 568031903
347 13 544946602
111 375 624947749
291 447 544946602
5 140 544946602
250 41 544946602
387 202 544946602
38...

output:

617
544946602 550 244 104 41 463 506 156 288 298 42 254 64 255 18 309 545 385 17 172 469 162 147 269 90 393 488 59 222 452 373 145 39 135 294 352 203 177 48 38 388 110 201 52 40 209 205 441 111 248 87 464 63 132 196 10 391 6 439 76 4 105 263 72 73 187 62 436 286 347 546 544 120 329 151 318 357 231 2...

result:

ok Participant found an answer (617 trees) and jury found an answer (617 trees)

Test #18:

score: 0
Accepted
time: 45ms
memory: 5636kb

input:

500 600 999999937
265 416 960325147
354 266 501849515
195 415 308033318
354 136 658703469
163 191 792878874
144 84 388345161
157 45 308033318
232 441 175503107
70 397 520297316
223 387 650583946
320 47 790017725
100 2 477058566
87 131 953737746
101 391 308033318
79 26 941025744
390 185 519333525
257...

output:

811
308033318 112 20 158 363 138 51 127 259 177 22 466 265 124 34 83 213 21 271 28 472 290 66 189 573 19 338 404 171 586 368 201 133 459 367 17 389 520 13 35 192 328 314 266 325 592 232 39 32 49 172 535 73 26 193 184 323 118 76 208 575 161 221 236 147 99 59 160 481 44 390 64 397 478 165 391 109 15 3...

result:

ok Participant found an answer (811 trees) and jury found an answer (811 trees)

Test #19:

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

input:

500 500 999999937
56 278 340955979
53 151 340955979
482 317 340955979
4 138 340955979
454 135 340955979
482 361 340955979
85 89 340955979
436 201 340955979
450 483 340955979
274 258 340955979
13 318 340955979
87 227 340955979
141 114 340955979
284 340 340955979
377 48 340955979
110 134 340955979
271...

output:

25
340955979 158 100 372 61 435 20 223 395 127 183 186 463 326 19 117 380 187 278 170 49 35 228 334 397 288 37 282 368 305 219 96 45 248 174 377 402 394 491 128 27 393 363 118 281 446 105 180 184 447 367 374 329 47 141 301 224 237 482 396 142 235 92 102 62 220 66 116 36 129 135 426 242 217 459 152 1...

result:

ok Participant found an answer (25 trees) and jury found an answer (25 trees)

Test #20:

score: 0
Accepted
time: 73ms
memory: 5948kb

input:

500 700 999999937
250 2 231570738
454 447 348559779
328 253 557290971
11 201 742990307
294 99 355194759
215 322 346919021
411 389 223497390
488 429 924302863
437 79 634119443
413 380 194151871
477 372 634119443
156 44 723189726
88 8 656811915
115 26 494639245
171 237 579262439
237 495 225519328
146 ...

output:

1213
634119443 243 315 640 48 198 63 18 235 100 266 463 437 109 449 369 55 201 13 572 328 295 139 227 517 95 144 258 297 234 268 177 521 140 24 290 220 173 36 20 80 96 504 117 207 197 430 389 270 590 7 128 509 89 339 84 182 394 451 195 120 212 583 208 32 676 299 648 223 353 92 606 352 215 98 586 118...

result:

ok Participant found an answer (1213 trees) and jury found an answer (1213 trees)

Test #21:

score: 0
Accepted
time: 92ms
memory: 6520kb

input:

500 800 999999937
258 304 583150933
159 152 864655622
8 47 904254153
436 265 649209189
204 302 999927615
142 302 437142821
37 15 886997658
202 395 176364113
284 260 352132138
365 172 621577977
196 101 999803609
174 45 669960837
302 206 85008264
305 275 142531904
443 157 652057600
16 248 693746068
46...

output:

1441
649209189 137 90 444 35 99 653 7 181 482 186 456 21 199 194 200 520 121 375 50 15 183 20 511 100 342 657 231 459 458 258 57 368 422 254 48 42 101 527 542 256 324 17 465 166 176 212 405 294 431 22 185 389 171 153 274 510 134 159 340 190 109 161 632 742 30 73 731 213 158 369 177 38 296 358 504 40...

result:

ok Participant found an answer (1441 trees) and jury found an answer (1441 trees)

Test #22:

score: 0
Accepted
time: 116ms
memory: 7120kb

input:

500 900 999999937
122 188 437691348
73 121 296323029
334 358 25382116
485 453 71271129
209 391 955537437
332 168 58669489
481 483 584529141
148 393 88230539
107 214 706736962
493 46 995301637
472 355 754703158
258 482 416475555
159 393 775800573
411 121 458973126
20 131 939950122
45 339 247694299
19...

output:

1701
5612341 166 227 316 213 346 705 401 296 251 337 26 204 631 60 232 36 556 135 533 542 91 625 342 196 432 446 537 260 61 65 218 208 66 184 124 258 667 268 487 33 378 146 144 148 155 308 68 284 740 209 176 70 460 330 157 801 178 11 265 27 170 206 254 262 39 53 243 754 532 18 282 544 434 359 195 73...

result:

ok Participant found an answer (1701 trees) and jury found an answer (1701 trees)

Test #23:

score: 0
Accepted
time: 138ms
memory: 7528kb

input:

500 1000 999999937
75 20 857550680
292 19 110166270
353 246 190797204
183 201 150954990
254 421 374099649
15 396 837014574
82 13 802431102
86 70 422727121
279 3 985425226
29 425 742626961
176 243 571825134
498 363 619955816
55 305 797984505
213 110 284175102
432 358 702809990
201 30 28699854
97 203 ...

output:

1945
818970192 344 94 203 522 440 218 354 878 217 478 266 46 172 580 12 39 650 243 104 227 138 700 79 359 299 2 62 83 181 63 372 207 453 398 58 109 25 27 95 3 93 236 129 262 277 360 37 699 35 685 318 310 20 317 200 234 18 45 341 148 242 157 252 196 561 287 254 131 414 452 290 51 1 78 8 119 566 460 1...

result:

ok Participant found an answer (1945 trees) and jury found an answer (1945 trees)

Test #24:

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

input:

2 1000 999999937
1 2 411133720
1 2 776367809
1 2 801503481
2 1 289867740
2 1 639986495
2 1 555099841
2 1 689485994
1 2 108816472
2 1 877082404
1 2 123678957
2 1 880363745
1 2 770025482
1 2 593440355
2 1 899935259
1 2 157609551
2 1 373761515
2 1 2889558
2 1 629415436
1 2 684947844
1 2 485414377
2 1 4...

output:

1999
862815664 1 
995610156 1000 
4389781 999 
746899739 999 
253100198 998 
347464232 998 
652535705 997 
631489105 997 
368510832 996 
32793297 996 
967206640 995 
306138703 995 
693861234 994 
772493052 994 
227506885 993 
664994231 993 
335005706 992 
21570696 992 
978429241 991 
310562264 991 
...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #25:

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

input:

10 1000 999999937
3 6 178912852
10 3 875510731
6 7 212989905
7 5 974004463
1 10 620941502
7 5 600081434
9 1 394370115
1 3 776909504
5 1 370501286
6 8 726447186
10 5 267613208
2 9 467291795
9 2 938683115
5 4 729586694
2 7 214781199
6 5 414875992
9 6 60215552
3 6 901637793
7 9 907537612
7 8 42123063
1...

output:

1999
785709981 5 2 1 3 4 14 25 12 74 
234534110 2 11 14 25 52 1 3 7 1000 
765465827 2 11 14 25 52 1 3 7 999 
346034755 3 1 2 5 35 4 12 25 999 
653965182 3 1 2 5 35 4 12 25 998 
482909997 10 1 2 5 7 12 15 23 998 
517089940 10 1 2 5 7 12 15 23 997 
328259378 1 2 5 7 12 3 4 14 997 
671740559 1 2 5 7 12...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #26:

score: 0
Accepted
time: 41ms
memory: 4440kb

input:

100 1000 999999937
27 22 577129898
47 76 383040531
44 49 252504590
66 46 764432363
75 76 827756718
80 35 275529478
95 9 886404040
55 97 184978304
11 72 641255171
65 95 394679645
37 8 171252921
35 39 277250820
62 10 745905336
97 76 208239094
16 34 460397322
74 28 465442229
89 95 979433574
70 86 67725...

output:

1999
127560596 69 107 3 66 15 52 13 87 10 7 57 18 85 230 177 6 22 2 5 55 205 23 41 75 46 129 11 25 39 297 64 9 122 31 1 38 269 93 113 187 137 16 266 83 98 36 21 148 92 40 90 82 127 71 121 48 8 110 311 60 45 34 141 207 379 367 324 47 99 272 390 102 239 389 27 197 97 491 42 4 351 263 338 441 341 511 6...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #27:

score: 0
Accepted
time: 138ms
memory: 8024kb

input:

498 1000 999999937
487 73 269543467
331 211 379519784
495 422 686973047
284 16 204129347
254 399 260794796
422 126 211993357
166 429 802536094
351 315 235479275
49 324 904476025
55 15 317387996
440 330 833475395
398 483 245510540
283 270 881075381
392 210 101464008
462 186 116907647
183 33 19696935
...

output:

1999
833785709 40 131 205 146 154 166 122 441 203 74 427 125 94 397 106 315 14 254 268 20 8 69 36 332 76 162 150 170 537 37 3 6 179 374 127 777 733 331 929 380 292 758 295 126 73 215 79 510 448 216 849 156 865 58 220 80 181 38 85 199 81 71 372 120 297 482 89 190 334 466 225 998 118 676 123 52 623 59...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #28:

score: 0
Accepted
time: 138ms
memory: 7872kb

input:

499 1000 999999937
144 284 46025639
242 260 240568220
449 203 912275568
260 4 382100531
96 298 24757210
255 315 720292625
111 97 124002714
227 444 550413391
331 282 363023595
201 44 757190858
498 460 378149715
387 63 989403521
195 296 477597041
210 146 858766928
499 87 408290897
313 395 347050751
14...

output:

1999
767509726 348 8 121 51 362 360 14 40 115 188 234 310 295 3 111 431 75 12 315 23 185 374 62 376 146 665 178 251 662 2 4 329 129 1 160 507 125 442 263 717 352 19 110 131 21 94 161 43 199 64 28 318 559 399 282 514 202 106 379 195 102 304 171 164 80 429 342 87 82 607 301 238 11 261 773 389 81 361 9...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #29:

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

input:

500 1000 999999937
114 191 548698698
257 259 174101411
166 144 307067234
5 65 315189831
130 144 764747698
191 263 657349687
435 125 520510567
72 457 869051725
31 434 652697712
451 437 241147129
140 367 568108671
423 368 152200500
258 291 922031445
489 5 313644610
407 393 435155235
96 135 53577132
26...

output:

1997
912213077 546 682 86 59 190 350 77 597 71 114 174 72 23 109 171 170 304 96 607 262 22 31 103 669 24 94 356 209 196 166 596 571 857 116 208 548 202 641 731 160 64 58 242 3 212 425 712 155 53 91 516 167 427 115 501 815 105 14 4 117 379 143 473 99 62 333 235 179 248 415 220 477 400 102 446 840 192...

result:

ok Participant found an answer (1997 trees) and jury found an answer (1997 trees)

Test #30:

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

input:

10 1000 999999937
1 6 169017311
6 4 813438192
7 10 658256408
3 10 356519068
5 8 105814076
10 9 432666653
2 10 924273201
4 2 438838176
6 10 23105379
9 3 61095925
4 6 492672241
8 1 350092485
1 3 849557758
9 8 527128919
5 10 399172798
2 4 637109541
9 7 862381710
8 4 821851347
9 1 517530356
10 7 7723516...

output:

1999
880696294 1 2 8 7 3 17 10 22 5 
381129132 44 3 5 7 8 10 12 17 1000 
618870805 44 3 5 7 8 10 12 17 999 
165093448 1 9 3 17 14 13 24 140 999 
834906489 1 9 3 17 14 13 24 140 998 
583259876 35 1 52 22 3 7 17 18 998 
416740061 35 1 52 22 3 7 17 18 997 
83631959 24 2 1 35 25 5 6 22 997 
916367978 24...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #31:

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

input:

50 1000 999999937
47 31 338993180
1 40 981131058
16 14 475599962
29 44 218651110
13 5 295788288
8 46 379702422
16 8 788369898
12 21 193552464
42 4 516953820
17 46 395588075
26 32 801052259
22 6 252241088
25 47 415361628
36 14 665366957
24 5 332323875
45 22 667496708
30 48 315574397
42 5 265997928
16...

output:

1999
759603654 2 46 5 21 1 13 26 4 90 11 97 9 66 29 12 55 94 8 25 38 17 96 3 14 36 84 54 180 6 10 47 59 215 118 27 49 92 80 83 22 153 192 109 434 125 37 24 552 591 
852870307 129 25 42 34 5 15 22 64 3 14 36 20 2 70 191 10 6 141 80 79 44 27 571 17 184 59 215 249 192 109 429 54 69 4 9 11 12 13 24 26 2...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #32:

score: 0
Accepted
time: 70ms
memory: 5480kb

input:

200 1000 999999937
155 193 467849083
56 59 535575167
97 22 494627324
200 72 960374690
51 200 104743381
129 37 403458202
99 138 318791385
164 7 513263543
116 185 858111714
169 165 864977405
87 135 479124746
164 37 463283980
98 150 827389077
111 2 519317068
8 84 554409749
51 11 688845859
164 39 370009...

output:

1999
433965560 87 248 71 8 115 13 63 35 57 233 69 1 127 110 451 34 15 122 3 261 740 139 206 41 53 20 18 16 5 4 118 370 270 73 942 97 189 162 238 107 201 164 10 93 357 94 483 342 19 31 40 14 82 436 308 133 66 161 39 42 78 433 24 676 76 234 99 51 9 64 217 644 143 70 48 83 30 75 50 289 85 128 152 212 1...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #33:

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

input:

499 1000 999999937
378 480 476231202
116 251 757524517
304 91 136773672
58 7 246393874
378 453 282946052
378 336 684803902
161 356 124374696
378 359 997729308
378 72 26684646
378 325 946203739
370 109 226216491
378 220 60777554
344 414 415380261
378 275 83199163
378 412 850660890
378 81 183620361
37...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #34:

score: 0
Accepted
time: 103ms
memory: 7504kb

input:

500 1000 999999937
430 117 111637665
85 228 267289407
478 304 819693771
477 99 161971830
69 242 172626708
397 448 755199536
397 165 556061372
397 309 705286456
397 71 441535487
397 242 463539465
451 64 63633665
397 333 435428974
441 202 512181674
397 217 566535010
397 241 556061372
390 384 444381502...

output:

1845
556061372 304 34 234 74 301 6 151 708 760 774 689 644 81 482 467 573 344 522 3 775 84 544 13 213 5 534 616 321 76 550 53 276 285 177 366 646 613 421 199 192 390 286 1 101 93 560 684 859 75 345 587 566 130 114 329 986 19 649 807 667 753 62 194 225 659 66 546 36 216 831 4 104 52 196 828 47 126 26...

result:

ok Participant found an answer (1845 trees) and jury found an answer (1845 trees)

Test #35:

score: 0
Accepted
time: 11ms
memory: 4040kb

input:

20 1000 2
5 11 1
10 6 0
10 13 1
3 6 0
4 8 0
14 1 0
6 7 1
19 20 1
15 12 0
5 1 1
2 5 0
14 5 1
13 4 1
6 12 1
20 16 1
10 13 1
2 10 1
17 14 1
2 19 1
17 12 1
17 11 0
5 20 1
10 5 0
7 19 0
12 9 0
14 6 1
12 13 1
7 2 1
16 15 1
2 15 1
8 12 1
3 14 1
3 17 1
9 10 1
10 1 1
14 20 0
6 12 0
19 1 0
2 16 1
8 15 1
1 11 ...

output:

1019
0 6 12 1 21 20 9 29 15 8 19 17 2 4 113 13 5 183 185 333 
1 11 19 8 79 7 284 183 318 1 3 6 9 10 13 20 21 29 32 999 
1 11 19 8 79 7 284 183 318 1 3 6 9 10 13 20 21 29 32 998 
1 82 140 113 219 1 2 5 6 8 9 11 15 18 19 21 31 35 89 998 
1 82 140 113 219 1 2 5 6 8 9 11 15 18 19 21 31 35 89 997 
1 17 1...

result:

ok Participant found an answer (1019 trees) and jury found an answer (972 trees)

Test #36:

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

input:

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

output:

1323
0 39 3 18 5 4 9 10 8 2 29 19 46 21 1 38 6 60 16 125 69 12 17 49 543 36 136 178 11 93 
1 9 10 24 36 7 21 46 19 29 34 69 12 17 49 72 3 228 329 6 60 725 4 5 11 13 15 37 51 999 
2 9 10 24 36 7 21 46 19 29 34 69 12 17 49 72 3 228 329 6 60 725 4 5 11 13 15 37 51 998 
1 34 32 7 22 12 17 49 25 9 10 24 ...

result:

ok Participant found an answer (1323 trees) and jury found an answer (1338 trees)

Test #37:

score: 0
Accepted
time: 23ms
memory: 3996kb

input:

40 1000 5
39 1 1
28 24 4
37 5 0
9 6 2
20 7 0
12 7 4
15 39 2
33 27 1
40 6 3
3 34 0
37 38 3
19 6 4
40 10 4
5 1 3
39 12 0
2 13 4
38 8 4
28 39 0
35 21 4
11 40 3
7 29 4
12 29 4
9 3 2
18 23 1
38 2 2
33 4 2
14 16 1
36 19 1
37 14 4
23 37 3
33 22 3
34 23 1
7 24 2
17 16 2
13 17 4
38 23 4
39 14 1
31 6 4
26 19 ...

output:

1583
3 1 7 50 24 30 3 69 27 41 13 9 4 23 10 68 42 8 56 17 81 39 28 53 19 59 6 5 107 120 16 35 213 376 137 183 176 2 258 307 
1 18 2 161 27 34 35 16 187 13 306 472 1 3 4 5 6 7 8 10 14 17 19 23 24 28 30 39 42 53 56 59 68 81 107 137 183 198 376 1000 
4 18 2 161 27 34 35 16 187 13 306 472 1 3 4 5 6 7 8 ...

result:

ok Participant found an answer (1583 trees) and jury found an answer (1573 trees)

Test #38:

score: 0
Accepted
time: 27ms
memory: 4100kb

input:

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

output:

1719
4 7 46 10 51 18 16 9 11 17 4 2 6 56 13 57 3 5 23 49 70 34 60 48 43 72 21 41 14 1 80 58 103 27 112 693 37 25 113 304 19 728 750 389 
1 20 22 21 35 3 5 23 128 25 64 2 4 8 71 16 9 11 176 96 43 214 27 112 61 51 10 46 50 56 13 185 60 364 687 14 32 36 58 62 91 129 141 1000 
6 20 22 21 35 3 5 23 128 2...

result:

ok Participant found an answer (1719 trees) and jury found an answer (1705 trees)

Test #39:

score: 0
Accepted
time: 27ms
memory: 4012kb

input:

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

output:

1831
8 7 46 10 51 18 16 9 11 17 4 2 6 56 13 57 3 5 23 49 70 34 60 48 43 72 21 41 14 1 80 58 103 27 112 693 37 25 113 304 19 728 750 389 
1 20 22 21 35 3 5 23 128 25 64 2 4 8 71 16 9 11 176 96 43 214 27 112 61 51 10 46 50 56 13 185 60 364 687 14 32 36 58 62 91 129 141 1000 
10 20 22 21 35 3 5 23 128 ...

result:

ok Participant found an answer (1831 trees) and jury found an answer (1797 trees)

Test #40:

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

input:

45 1000 2
42 1 1
13 16 1
22 25 1
20 1 1
18 11 1
42 12 1
40 7 1
33 6 1
13 18 1
39 2 1
19 30 1
10 4 1
1 45 1
16 18 1
17 41 1
21 11 1
1 7 1
1 7 1
43 22 1
45 22 1
5 18 1
30 25 1
3 16 1
37 13 1
35 39 1
6 31 1
12 22 1
28 27 1
4 29 1
45 14 1
31 26 1
39 43 1
29 10 1
42 28 1
26 16 1
6 27 1
33 22 1
8 41 1
17 ...

output:

1001
0 1 6 27 3 22 11 118 64 29 12 177 28 36 8 43 95 25 10 69 104 63 2 14 5 16 253 30 47 65 226 137 15 38 109 128 7 86 224 241 781 260 31 393 257 
1 37 3 22 11 118 4 1 6 53 30 47 62 12 33 135 23 2 9 5 16 296 52 28 48 38 15 42 113 10 69 97 59 224 86 7 128 170 972 226 468 8 26 43 1000 
1 37 3 22 11 11...

result:

ok Participant found an answer (1001 trees) and jury found an answer (1934 trees)

Test #41:

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

input:

45 1000 3
42 1 1
13 16 2
22 25 2
20 1 0
18 11 2
42 12 2
40 7 2
33 6 1
13 18 2
39 2 1
19 30 1
10 4 2
1 45 2
16 18 1
17 41 1
21 11 2
1 7 1
1 7 1
43 22 1
45 22 2
5 18 1
30 25 1
3 16 1
37 13 1
35 39 2
6 31 1
12 22 2
28 27 2
4 29 2
45 14 1
31 26 2
39 43 2
29 10 2
42 28 1
26 16 1
6 27 1
33 22 1
8 41 2
17 ...

output:

1319
0 1 6 27 3 22 11 118 64 29 12 177 28 36 8 43 95 25 10 69 104 63 2 14 5 16 253 30 47 65 226 137 15 38 109 128 7 86 224 241 781 260 31 393 257 
2 37 3 22 11 118 4 1 6 53 30 47 62 12 33 135 23 2 9 5 16 296 52 28 48 38 15 42 113 10 69 97 59 224 86 7 128 170 972 226 468 8 26 43 1000 
1 37 3 22 11 11...

result:

ok Participant found an answer (1319 trees) and jury found an answer (1932 trees)

Test #42:

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

input:

45 1000 5
42 1 2
13 16 3
22 25 1
20 1 3
18 11 3
42 12 3
40 7 3
33 6 4
13 18 4
39 2 3
19 30 4
10 4 3
1 45 2
16 18 4
17 41 3
21 11 3
1 7 4
1 7 0
43 22 2
45 22 4
5 18 0
30 25 3
3 16 3
37 13 3
35 39 3
6 31 4
12 22 3
28 27 2
4 29 2
45 14 1
31 26 2
39 43 1
29 10 3
42 28 2
26 16 2
6 27 2
33 22 4
8 41 3
17 ...

output:

1605
2 1 6 27 3 22 11 118 64 29 12 177 28 36 8 43 95 25 10 69 104 63 2 14 5 16 253 30 47 65 226 137 15 38 109 128 7 86 224 241 781 260 31 393 257 
3 37 3 22 11 118 4 1 6 53 30 47 62 12 33 135 23 2 9 5 16 296 52 28 48 38 15 42 113 10 69 97 59 224 86 7 128 170 972 226 468 8 26 43 1000 
2 37 3 22 11 11...

result:

ok Participant found an answer (1605 trees) and jury found an answer (1951 trees)

Test #43:

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

input:

45 1000 7
42 1 2
13 16 3
22 25 3
20 1 2
18 11 1
42 12 1
40 7 5
33 6 2
13 18 5
39 2 3
19 30 3
10 4 4
1 45 2
16 18 1
17 41 1
21 11 1
1 7 2
1 7 1
43 22 1
45 22 3
5 18 3
30 25 2
3 16 5
37 13 1
35 39 4
6 31 6
12 22 4
28 27 5
4 29 4
45 14 2
31 26 3
39 43 6
29 10 2
42 28 4
26 16 5
6 27 3
33 22 4
8 41 1
17 ...

output:

1695
1 1 6 27 3 22 11 118 64 29 12 177 28 36 8 43 95 25 10 69 104 63 2 14 5 16 253 30 47 65 226 137 15 38 109 128 7 86 224 241 781 260 31 393 257 
6 37 3 22 11 118 4 1 6 53 30 47 62 12 33 135 23 2 9 5 16 296 52 28 48 38 15 42 113 10 69 97 59 224 86 7 128 170 972 226 468 8 26 43 1000 
1 37 3 22 11 11...

result:

ok Participant found an answer (1695 trees) and jury found an answer (1973 trees)

Test #44:

score: 0
Accepted
time: 27ms
memory: 4088kb

input:

45 1000 11
42 1 3
13 16 7
22 25 6
20 1 9
18 11 7
42 12 6
40 7 4
33 6 2
13 18 9
39 2 2
19 30 7
10 4 6
1 45 7
16 18 4
17 41 6
21 11 2
1 7 7
1 7 9
43 22 5
45 22 5
5 18 8
30 25 4
3 16 4
37 13 10
35 39 1
6 31 6
12 22 2
28 27 2
4 29 2
45 14 8
31 26 5
39 43 9
29 10 3
42 28 4
26 16 6
6 27 1
33 22 5
8 41 9
1...

output:

1817
0 1 6 27 3 22 11 118 64 29 12 177 28 36 8 43 95 25 10 69 104 63 2 14 5 16 253 30 47 65 226 137 15 38 109 128 7 86 224 241 781 260 31 393 257 
8 37 3 22 11 118 4 1 6 53 30 47 62 12 33 135 23 2 9 5 16 296 52 28 48 38 15 42 113 10 69 97 59 224 86 7 128 170 972 226 468 8 26 43 1000 
3 37 3 22 11 11...

result:

ok Participant found an answer (1817 trees) and jury found an answer (1988 trees)

Test #45:

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

input:

300 1000 579907477
85 20 501369811
170 209 398163019
213 60 24791654
230 141 419019038
262 23 307332223
76 171 6647363
82 256 472269037
83 216 98974104
212 171 206720550
270 276 515676983
204 176 51907464
144 112 422022914
118 82 330909459
205 132 575785329
169 140 55357686
40 286 145577484
126 212 ...

output:

1999
110715191 62 269 119 163 28 221 69 112 352 23 90 181 31 379 73 188 22 51 189 43 83 151 170 47 164 160 159 24 150 268 123 165 109 61 34 91 106 467 306 461 279 757 18 63 19 10 172 297 233 267 55 116 100 183 289 126 178 293 97 422 957 208 298 8 271 205 41 310 282 16 403 57 75 85 20 161 124 218 101...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #46:

score: 0
Accepted
time: 107ms
memory: 6704kb

input:

350 1000 994747931
95 304 672543274
30 294 551111098
27 157 153882783
116 157 512439805
203 153 527241207
111 105 470017102
282 4 195745674
175 189 61279030
344 65 6080303
281 134 896176207
11 182 876685758
157 196 599267556
77 207 337469051
143 130 692521419
123 120 187503868
51 289 102179308
21 29...

output:

1999
863207455 49 39 405 310 342 82 62 400 503 197 26 111 138 18 158 63 127 7 246 107 207 106 285 10 84 596 341 12 3 51 5 434 66 146 27 76 151 309 148 135 378 21 34 52 428 120 105 302 402 145 128 13 256 542 67 125 348 325 64 495 59 81 202 56 631 75 9 209 293 132 6 19 603 181 271 177 96 280 58 189 26...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #47:

score: 0
Accepted
time: 113ms
memory: 6748kb

input:

400 1000 967527623
227 62 593968166
174 386 319015265
11 386 37103681
254 362 439221071
301 329 441776182
166 272 228510487
215 140 164578119
281 268 87582058
356 247 835697768
66 197 929873194
333 289 477978462
156 48 669732140
300 106 567689265
229 125 128833926
380 331 286498390
357 58 4652963
17...

output:

1999
525945103 471 192 5 34 87 152 258 174 248 24 22 118 66 295 233 69 509 15 30 414 17 85 159 134 598 98 7 75 18 135 137 145 155 310 175 158 275 156 235 289 116 313 42 383 90 303 37 434 76 131 130 413 25 10 255 119 91 539 214 244 8 511 86 197 277 196 231 525 217 209 274 555 216 502 41 59 46 67 292 ...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #48:

score: 0
Accepted
time: 125ms
memory: 7588kb

input:

450 1000 955153609
290 219 65970737
334 77 21598136
198 332 90012774
363 300 235053495
73 132 615775924
295 155 562343519
445 436 152605289
399 252 933967514
262 423 376322373
230 294 265251767
89 32 847945694
61 94 770914730
56 305 374807056
137 64 69327712
323 107 782667
209 274 944022728
23 21 23...

output:

1999
925119728 283 83 70 561 340 53 504 426 174 709 403 181 101 93 118 34 151 65 556 495 247 164 347 121 387 242 128 260 63 193 727 336 26 130 55 69 178 736 154 320 397 172 408 342 12 212 153 29 10 61 108 62 304 195 41 77 32 218 277 857 333 404 268 168 47 600 236 720 675 350 134 81 38 102 148 88 742...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #49:

score: 0
Accepted
time: 140ms
memory: 8024kb

input:

499 1000 830842109
454 357 281331744
288 10 603468239
151 105 612741336
176 23 696034831
478 38 86151600
96 1 205849625
428 233 227676259
116 344 432314466
181 263 725179555
154 330 276902007
387 454 212244033
434 297 150051447
73 473 657304392
434 484 467362896
31 317 540666741
83 2 818695382
74 55...

output:

1999
829731142 6 23 321 287 47 256 46 791 126 86 343 165 637 12 205 186 223 59 267 79 75 215 515 98 251 172 750 22 25 115 490 284 69 192 110 391 322 125 288 39 54 8 458 668 58 35 329 166 64 268 38 225 743 180 26 732 700 34 107 217 438 31 327 861 793 112 3 393 324 798 281 134 701 74 61 662 360 586 46...

result:

ok Participant found an answer (1999 trees) and jury found an answer (1999 trees)

Test #50:

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

input:

497 497 2
138 127 1
224 181 1
445 401 0
162 242 0
410 15 1
496 295 0
318 352 1
195 403 1
478 148 0
394 47 0
229 151 0
270 123 0
234 395 0
319 133 1
258 332 1
118 384 0
78 419 1
467 456 0
277 279 0
46 78 0
193 89 0
487 128 1
249 376 0
121 115 1
421 477 1
317 240 0
474 339 1
127 428 0
221 289 1
248 36...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #51:

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

input:

497 497 2
472 43 1
217 85 1
366 196 0
223 301 0
68 25 1
72 115 1
286 74 0
175 122 1
487 129 0
46 54 0
477 24 1
6 134 0
312 456 1
402 364 1
465 98 1
264 44 0
49 4 0
257 22 0
397 285 1
430 388 0
259 342 1
354 300 1
448 96 1
290 228 0
31 272 0
332 130 0
348 160 1
198 366 1
18 467 0
474 308 1
374 101 1
...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #52:

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

input:

497 497 2
81 446 1
484 359 0
417 249 1
113 74 1
27 14 0
51 380 1
207 148 0
422 334 0
386 419 1
369 46 1
338 136 1
211 62 1
264 125 0
426 90 0
404 211 1
339 66 0
468 21 1
394 177 1
127 442 1
262 190 0
172 415 0
29 10 1
189 484 0
379 60 1
102 84 0
118 163 0
236 76 1
33 422 0
384 328 1
9 448 0
425 120 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #53:

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

input:

499 499 2
282 20 1
276 126 0
353 375 1
62 89 1
461 127 0
18 159 0
197 310 1
393 418 1
38 246 1
363 84 1
312 314 1
473 370 1
456 22 0
17 111 1
450 417 1
114 413 0
238 449 0
260 454 1
210 86 0
349 468 0
465 477 0
376 362 0
287 87 1
494 44 1
334 349 0
183 77 0
10 154 1
54 433 1
286 325 1
224 140 0
156 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #54:

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

input:

499 499 3
28 294 2
84 43 1
224 290 2
302 18 2
443 410 0
320 370 2
425 42 2
82 235 1
396 76 0
412 270 0
387 360 2
195 84 0
409 416 2
339 390 1
365 342 1
187 223 0
442 142 1
299 320 1
32 321 1
79 56 0
485 437 1
76 272 2
379 93 1
410 169 0
413 16 1
50 347 1
378 101 1
30 384 2
332 348 0
26 395 1
92 40 2...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #55:

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

input:

499 499 89
443 214 36
365 483 68
177 343 67
419 112 70
294 104 37
271 77 50
397 115 52
473 141 34
282 318 5
343 467 67
320 157 87
68 486 51
69 466 65
35 484 35
248 91 73
101 13 57
278 67 0
78 172 71
322 74 68
482 370 65
459 295 32
207 39 16
361 321 9
441 431 36
147 363 6
93 390 59
90 128 44
339 178 ...

output:

-1

result:

ok Both jury and participant did not find an answer

Test #56:

score: -100
Runtime Error

input:

500 500 499
349 244 372
211 55 184
392 217 54
343 125 381
169 265 319
184 382 159
329 187 268
341 248 273
240 360 62
35 438 70
27 408 479
130 35 319
313 57 223
376 245 135
219 170 59
469 425 277
140 398 302
275 41 337
377 148 171
307 64 256
446 484 361
124 137 369
62 216 297
466 343 71
26 462 451
41...

output:

500 SZ | 0 349 244 | 0 349 244 | 99 370 227 | 437 227 397 | 490 397 171 | 225 171 469 | 15 469 425 | 349 425 420 | 364 420 226 | 363 226 327 | 300 327 127 | 324 127 399 | 209 399 200 | 400 200 320 | 316 320 52 | 422 52 185 | 328 185 377 | 18 377 148 | 77 148 346 | 138 346 312 | 192 312 369 | 443 369...

result: