QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#166323#5402. 术树数Lynkcat#13 817ms97840kbC++204.4kb2023-09-06 08:43:522024-07-04 01:52:54

Judging History

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

  • [2024-07-04 01:52:54]
  • 评测
  • 测评结果:13
  • 用时:817ms
  • 内存:97840kb
  • [2023-09-06 08:43:52]
  • 提交

answer

#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) ((int)((x).size()))
#define int ll
// #define N 
using namespace std;
int Q,K,m;
int quickPower(int x,int y)
{
    int res=1;
    while (y)
    {
        if (y&1) 
        {
            res=res*x;
            if (y==1) break;
        }
        x=x*x;
        y>>=1;
    }
    return res;
}
void exgcd(int a,int b,int &x,int &y)
{
    if (!b)
    {
        x=1,y=0;
        return;
    }
    exgcd(b,a%b,y,x);
    y-=a/b*x;
}
inline int Inv(int x)
{
    int a, b;
    exgcd(x,K,a,b);
    return (a%K+K)%K;
}
void BellaKira()
{
    cin>>Q>>K>>m;
    vector<int>gd(K+1,0);
    for (int i=1;i<=K;i++) gd[i]=gcd(i,K);
    vector<poly>fa(Q+1,poly(20,0)),dis(Q+1,poly(30,0));
    vector<poly>basis(30,poly());
    vector<int>dep(Q+1,0);
    dep[1]=1;
    int n=1;
    function<poly(poly,poly)>add=[&](poly x,poly y)
    {
        for(int i=0;i<30;i++) x[i]=(x[i]+y[i])%K;
        return x;
    };
    function<poly(poly,int)>mul=[&](poly x,int y)
    {
        for(int i=0;i<30;i++) x[i]=(x[i]*y)%K;
        return x;
    };
    function<poly(poly,poly)>del=[&](poly x,poly y)
    {
        for(int i=0;i<30;i++) x[i]=(x[i]-y[i]+K)%K;
        return x;
    };
    function<poly(int)>trans=[&](int x)
    {
        poly res;
        for (int i=0;i<30;i++) res.push_back(x%K),x/=K;
        return res;
    };
    function<void(poly&,poly&,int)>work=[&](poly &x,poly &y,int i)
    {
        while (y[i]!=0)
        {
            if (x[i]<y[i]) 
            {
                swap(x,y);
                continue;
            }
            int t=x[i]/y[i];
            for (int j=0;j<30;j++)
                x[j]=(x[j]-t*y[j]%K+K)%K;
        }
    };
    function<void(poly)>ins=[&](poly x)
    {
        for (int i=29;i>=0;i--)
            if (x[i])
            {
                if (basis[i].empty())
                {
                    basis[i]=mul(x,Inv(x[i]));
                    // cout<<"??"<<x[i]<<" "<<K<<" "<<gd[x[i]]<<endl;
                    x=mul(x,K/gd[x[i]]);
                } else
                {
                    work(basis[i],x,i);
                }
            }
    };

    function<poly(poly)>qry=[&](poly x)
    {
        for (int i=29;i>=0;i--)
            if (x[i])
            {
                if (!basis[i].size()) continue;
                x=del(x,mul(basis[i],(x[i]/basis[i][i])));
            }
        return x;
    };
    function<int(int,int)>lca=[&](int x,int y)
    {
        if (dep[x]<dep[y]) swap(x,y);
        for (int i=18;i>=0;i--)
            if (dep[fa[x][i]]>=dep[y]) x=fa[x][i];
        if (x==y) return x;
        for (int i=18;i>=0;i--) 
            if (fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i];
        return fa[x][0];
    };
    while (Q--)
    {
        int opt,x,y;
        cin>>opt>>x>>y;
        if (opt==1)
        {
            poly v=trans(y);
            n++;
            dep[n]=dep[x]+1;
            fa[n][0]=x;
            for (int i=1;i<=18;i++)
                fa[n][i]=fa[fa[n][i-1]][i-1];
            dis[n]=add(dis[x],v);
            ins(add(v,v));
        }
        else
        if (opt==2)
        {
            int w;
            cin>>w;
            poly v=trans(w);
            int z=lca(x,y);
            ins(add(v,v));
            v=add(v,dis[x]);
            v=add(v,dis[y]);
            v=del(v,dis[z]);
            v=del(v,dis[z]);
            ins(v);
        }
        else 
        if (opt==3)
        {
            int z=lca(x,y);
            poly v=del(add(dis[x],dis[y]),dis[z]);
            v=del(v,dis[z]);
            poly now=qry(v);
            reverse(now.begin(),now.end());
            int ans=0;
            for (auto u:now) ans=ans*K+u;
            cout<<ans<<'\n';
        }
        // for (int i=29;i>=0;i--)
        // {
        //     cout<<"!"<<i<<endl;
        //     if (basis[i].size())
        //     {
        //         for (int j=29;j>=0;j--) cout<<basis[i][j]<<" ";
        //         cout<<endl;
        //     }
        // }
        // cout<<"------"<<endl;
    }
}
signed main()
{
	IOS;
	cin.tie(0);
	int T=1;
	while (T--)
	{
		BellaKira();
	}
}

詳細信息

Subtask #1:

score: 2
Accepted

Test #1:

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

input:

30 7 3
1 1 301
1 1 236
1 2 278
3 2 4
3 2 4
2 1 4 265
1 1 242
1 4 278
1 6 337
3 2 3
2 5 7 304
2 5 6 34
1 4 178
3 6 7
3 5 7
3 1 4
1 1 178
3 3 4
3 1 6
3 3 4
2 6 7 131
1 1 213
3 1 3
2 3 10 11
3 4 6
2 5 9 169
1 6 9
2 5 10 29
1 9 111
3 9 11

output:

0
0
0
0
0
0
0
0
0
0
0
0

result:

ok 12 lines

Test #2:

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

input:

30 9 3
1 1 694
1 2 251
1 2 623
2 2 4 109
3 3 4
3 1 2
2 2 4 611
1 4 595
2 2 5 477
2 2 5 363
3 1 3
2 1 5 121
1 2 225
2 1 5 214
2 3 6 706
3 3 4
2 2 3 122
2 2 3 621
3 2 3
3 2 4
2 1 5 630
1 5 598
3 4 5
3 1 3
1 2 665
2 1 2 331
2 1 6 449
1 2 387
3 3 6
3 4 6

output:

0
0
0
0
0
0
0
0
0
0

result:

ok 10 lines

Test #3:

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

input:

30 4 5
1 1 854
1 1 467
1 2 708
2 2 4 529
1 4 115
1 4 444
2 3 4 108
2 2 5 724
2 1 3 375
1 5 827
2 5 6 974
1 3 73
3 2 3
2 2 3 140
3 5 6
2 6 8 787
3 1 5
1 5 971
3 4 6
2 4 5 816
3 7 8
3 2 4
1 6 855
2 5 10 39
2 6 9 280
2 6 10 662
3 7 10
1 6 412
3 4 7
1 6 276

output:

0
256
256
256
0
0
0
0

result:

ok 8 lines

Test #4:

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

input:

30 6 4
1 1 1246
1 1 825
1 3 843
2 1 3 186
2 2 3 228
2 1 3 1187
3 2 3
3 1 4
1 3 942
3 1 2
1 5 779
2 3 4 775
2 1 2 275
2 1 3 309
2 5 6 1175
3 2 6
1 6 1084
3 4 6
1 7 176
3 5 6
2 3 8 431
3 2 6
3 1 4
1 8 725
3 7 9
3 1 4
3 6 7
3 2 4
3 1 6
1 5 972

output:

1
6
7
0
0
0
0
0
0
0
0
0
0

result:

ok 13 lines

Test #5:

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

input:

30 6 4
1 1 1050
1 2 312
1 3 665
2 1 4 49
2 1 3 394
2 3 4 1225
3 1 4
1 1 381
3 1 2
1 3 933
1 3 551
2 2 6 521
3 3 5
2 2 6 1219
3 3 7
1 6 953
1 3 403
2 1 7 624
1 8 981
3 1 2
1 9 1052
2 4 9 971
2 5 8 575
3 1 7
2 6 9 953
2 1 10 347
3 3 11
2 3 9 878
1 6 991
2 6 11 681

output:

1
0
1
1
0
0
0

result:

ok 7 lines

Test #6:

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

input:

30 4 5
1 1 48
1 2 924
1 2 587
3 3 4
2 1 3 63
1 1 600
2 2 5 747
1 5 252
2 2 5 777
2 2 3 119
1 3 914
1 1 708
2 2 3 670
2 3 5 526
3 3 7
1 5 816
1 9 401
1 2 364
2 7 10 16
2 10 11 254
1 6 641
1 10 406
2 6 10 324
1 5 29
1 12 493
2 3 15 125
1 12 95
1 4 370
2 8 16 766
1 11 307

output:

341
0

result:

ok 2 lines

Test #7:

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

input:

30 3 6
1 1 358
1 2 16
1 1 636
1 1 156
1 4 512
3 3 4
3 5 6
3 1 2
2 2 5 271
3 4 6
2 3 5 5
1 2 566
3 3 4
3 4 6
3 2 3
2 4 6 472
2 2 6 119
1 1 260
2 1 8 488
1 7 345
1 8 368
2 6 9 649
1 1 553
2 1 9 416
3 8 9
1 10 630
1 9 156
1 3 14
1 4 407
3 4 10

output:

0
0
0
0
0
0
0
0
0

result:

ok 9 lines

Test #8:

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

input:

3 8 3
1 1 401
1 2 0
3 1 2

output:

179

result:

ok single line: '179'

Subtask #2:

score: 11
Accepted

Dependency #1:

100%
Accepted

Test #9:

score: 11
Accepted
time: 2ms
memory: 4128kb

input:

996 4 8
1 1 43515
1 1 674
1 1 0
3 3 4
1 3 26873
3 3 5
3 3 4
1 2 0
1 5 26201
1 7 0
3 1 3
3 2 6
1 2 2722
1 4 674
1 10 35328
3 3 5
1 2 2048
3 10 11
2 2 8 34808
3 10 11
3 1 4
3 3 11
3 3 7
3 1 2
1 2 10753
3 12 13
3 3 4
1 12 32928
3 9 13
3 3 8
2 3 10 3
3 5 8
1 9 34978
1 13 2722
3 8 14
3 2 3
1 9 43681
3 7 ...

output:

0
26873
0
0
0
24825
0
0
0
0
1024
504
0
0
0
1024
17496
1528
504
1528
16640
504
1024
1528
1528
16640
16472
16640
16472
0
0
504
504
504
0
16640
1024
504
504
504
0
0
504
0
504
16640
0
504
0
504
16640
16640
16640
0
0
0
0
0
504
0
0
16472
0
0
1024
1024
504
504
0
504
0
16640
504
0
0
0
504
16640
0
0
504
504
...

result:

ok 459 lines

Test #10:

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

input:

997 6 6
1 1 12369
1 1 31248
3 1 2
2 1 2 43616
3 1 2
3 1 2
1 1 15625
1 4 15627
3 2 4
1 1 31251
1 1 31249
3 3 6
1 5 31253
1 3 4
1 7 31252
1 2 3
1 7 15626
3 6 7
1 4 15627
3 5 12
1 6 2
1 12 0
3 4 6
3 8 14
3 1 7
1 8 31252
1 6 4
3 12 17
1 9 31249
1 10 0
1 18 4
3 5 19
1 8 12861
1 3 16431
1 5 16155
1 16 405...

output:

12369
12366
12366
12366
0
0
0
0
0
0
0
0
0
9474
9474
9474
0
0
0
0
0
9330
9330
9330
0
9330
9330
9330
0
0
0
0
0
9330
9330
0
9330
0
0
0
0
9330
0
9330
9330
0
0
0
0
9330
9330
9330
9330
9330
9330
0
0
9330
0
0
9330
0
0
9330
9330
0
9330
9330
9330
9330
0
0
0
9330
0
0
0
9330
9330
9330
9330
0
9330
9330
9330
933...

result:

ok 454 lines

Test #11:

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

input:

1000 8 5
1 1 14822
3 1 2
2 1 2 20801
3 1 2
3 1 2
3 1 2
3 1 2
1 2 8322
1 2 2337
1 4 10659
3 3 4
3 1 2
3 1 3
1 4 18469
1 4 18469
3 5 7
3 3 4
1 6 7608
3 1 6
3 3 5
1 3 2226
1 5 26902
2 3 6 289
1 3 26672
1 1 10547
1 2 16530
3 10 13
1 3 10263
3 7 9
1 8 10257
1 8 26674
1 10 16531
1 16 26899
3 2 13
3 1 9
1 ...

output:

6498
4161
4161
4161
4161
0
4161
4161
0
0
4161
0
0
0
0
4160
4160
4160
5160
1112
5160
5160
0
4160
0
0
0
0
0
0
0
5160
5160
0
0
1112
5160
0
0
5160
0
0
0
0
0
0
5160
5160
0
5160
0
0
0
0
0
1112
0
5160
5160
0
0
0
5160
5160
5160
5160
5160
0
5160
0
0
5160
0
4104
0
0
4104
4104
4104
0
0
0
0
0
0
4104
0
4104
4104...

result:

ok 446 lines

Test #12:

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

input:

994 12 4
1 1 12377
1 2 18746
3 2 3
3 1 3
2 2 3 11
1 3 18751
3 3 4
1 1 7587
1 4 7592
1 2 18753
2 3 6 7586
2 5 7 16102
1 5 6
3 5 7
2 6 7 7591
3 4 6
2 5 6 6526
2 1 4 19821
3 3 5
3 2 8
1 1 11307
1 7 7595
3 1 6
1 9 15032
1 2 18748
2 2 10 15027
3 8 11
1 4 7591
3 4 7
3 6 11
2 2 10 15033
3 1 4
1 12 3865
1 1...

output:

0
2807
0
2796
0
2796
2796
2796
0
0
2796
2796
0
2796
2796
0
2796
0
0
2796
0
0
0
2796
2796
0
0
0
0
0
2796
0
2796
0
0
2796
0
0
0
2796
0
0
2796
2796
2796
2796
2796
0
2796
0
2796
2796
0
2796
2796
0
0
0
2796
0
0
0
0
2796
0
0
2796
0
2796
2796
2796
0
0
1932
0
1932
1932
1932
0
0
1932
1788
0
0
1932
1932
1932
...

result:

ok 459 lines

Test #13:

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

input:

995 30 3
1 1 23137
1 2 384
1 1 192
3 2 4
1 2 18728
1 5 18566
3 2 4
1 2 9364
1 3 546
2 2 6 9555
3 1 3
3 3 8
3 2 8
3 3 5
2 2 8 557
3 4 7
1 2 9741
3 6 7
3 2 5
1 8 16
1 7 541
3 3 8
3 1 8
1 2 9730
1 3 18188
3 5 11
1 1 18555
3 4 5
3 1 6
3 9 13
3 2 4
1 13 389
1 11 9725
1 11 749
1 15 18014
3 11 13
1 7 9007
...

output:

4601
4601
4590
0
0
0
4590
0
0
0
4590
0
4590
4590
0
4590
0
0
0
0
4590
0
0
0
4590
0
0
0
0
4590
0
4590
4590
4590
0
0
0
0
0
0
4590
0
0
4590
0
4590
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
4590
0
0
0
0
0
0
0
0
4590
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 445 lines

Test #14:

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

input:

1000 280 2
1 1 71565
1 2 53290
1 3 8650
3 1 2
1 4 22600
1 4 47710
1 5 58870
1 3 50500
3 2 4
1 5 53290
3 1 8
3 2 8
2 3 4 279
2 1 7 40860
3 3 9
3 4 9
1 8 56234
3 1 6
3 3 4
1 5 8663
1 1 22551
3 8 12
3 3 9
3 9 12
1 11 50597
3 10 11
3 5 6
1 7 70250
1 2 42162
1 10 44800
3 3 13
1 11 5793
2 14 15 67433
3 11...

output:

1535
0
1535
0
0
0
1400
0
1400
0
1400
0
0
0
0
0
0
1400
1400
0
0
1400
0
1400
0
1400
0
1400
0
0
0
1400
0
1400
1400
0
1400
0
1400
0
0
1400
0
0
1400
0
0
0
0
1400
0
0
0
0
0
1400
1400
0
0
1400
1400
1400
0
1400
0
0
0
0
0
0
1400
1400
1400
0
1400
1400
1400
1400
0
1400
0
1400
1400
0
1400
0
1400
1400
1400
0
0
0...

result:

ok 440 lines

Test #15:

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

input:

998 6 6
1 1 39091
1 2 0
3 1 3
1 3 15640
2 1 3 23456
3 2 4
1 3 31277
3 2 4
2 1 5 7821
1 3 15640
3 4 6
1 3 31275
1 3 15640
1 8 15638
1 4 3
3 2 4
1 8 4
3 5 11
3 6 9
2 3 8 3
3 1 7
3 7 10
1 2 31274
1 5 15638
1 8 31272
1 10 0
1 3 3
1 14 15638
3 3 11
2 4 11 31277
1 9 31273
3 10 13
3 6 12
3 15 17
3 14 18
3 ...

output:

7823
0
0
0
0
0
0
7818
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7818
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
7818
0
0
0
0
0
0
0
0
0
0
7818
0
0
0
0
0
0
0
0
7818
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
2076
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 458 lines

Test #16:

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

input:

992 8 5
1 1 26
1 1 32
1 1 24963
3 2 4
1 2 4
3 2 3
1 3 16690
1 1 16690
3 4 6
1 1 16691
1 8 16694
1 6 16642
3 1 10
3 2 3
1 9 16
2 1 7 16693
1 1 16660
2 2 10 43
1 9 51
2 3 11 54
1 4 16675
1 7 16643
1 8 55
1 15 49
3 10 13
1 10 49
1 3 33
1 2 16644
3 16 20
3 9 19
3 18 20
1 13 20
1 4 16672
3 12 20
1 22 166...

output:

8331
10
8321
0
8
0
8
0
8
8
8320
8320
0
0
0
0
0
8
8320
0
0
8320
0
0
0
8
8320
8320
0
8320
8320
8328
0
0
8
0
8
0
8320
8320
0
0
8320
0
0
8320
8
8320
0
8
0
0
0
8320
0
8320
0
0
0
8320
8320
0
0
0
8320
0
0
8
8320
0
8
8320
0
0
1152
0
1152
0
0
0
8320
0
0
0
0
8320
1152
8
8320
8320
0
0
0
0
0
8320
8320
8320
0
83...

result:

ok 447 lines

Test #17:

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

input:

1000 12 4
1 1 19140
3 1 2
1 1 17400
3 1 2
1 3 0
2 1 4 7523
3 1 2
3 3 4
3 1 2
3 1 4
1 3 3555
1 5 13920
1 6 7517
1 6 7592
1 4 15034
1 4 18439
3 3 10
1 10 14477
1 6 11003
1 9 17406
3 1 9
1 4 4037
1 4 15097
1 2 632
3 14 16
1 4 14477
3 12 15
1 11 10997
3 1 3
2 1 2 19621
2 1 11 1249
1 17 11071
3 5 13
3 4 ...

output:

1740
1740
1740
0
1740
0
0
0
1740
0
0
0
0
0
0
0
0
0
1740
0
0
0
0
0
0
0
0
1740
0
0
0
0
0
0
1740
0
0
1740
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1740
0
0
0
0
0
0
0
0
1740
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1740
0
0
0
0
0
0
0
0
0
0
0
0
1740
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

ok 479 lines

Test #18:

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

input:

991 16 4
1 1 0
1 2 35536
3 2 3
3 2 3
3 2 3
1 2 2112
1 1 2240
3 1 3
3 4 5
1 2 1056
1 4 3296
3 1 3
2 1 6 1199
3 1 6
3 1 6
1 2 3172
1 8 3297
1 2 132
1 9 2251
3 2 11
3 4 10
3 4 8
1 10 6
3 4 6
1 9 1070
1 7 3179
1 11 2244
1 14 132
1 6 8
3 8 17
1 9 1191
1 10 2112
3 2 18
3 11 12
3 2 5
1 1 12
1 8 1060
3 16 1...

output:

33296
33296
33296
33296
0
33296
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
33296
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
33296
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
33296
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
8448
0
0
0...

result:

ok 451 lines

Test #19:

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

input:

997 60 2
1 1 3578
2 1 2 2357
2 1 2 459
3 1 2
3 1 2
3 1 2
2 1 2 2825
3 1 2
1 1 1696
1 3 840
1 4 1334
1 4 2791
3 3 6
1 6 515
1 3 1332
3 6 7
1 8 2418
3 5 8
3 4 9
3 2 6
1 7 2293
1 5 148
1 6 2078
1 1 3015
1 2 1578
1 11 2293
2 4 15 3286
3 1 15
3 6 12
3 7 13
2 1 4 415
3 3 7
3 1 4
1 2 392
1 1 2938
3 8 17
3 ...

output:

60
60
60
60
0
0
0
0
60
0
0
0
0
0
0
0
0
0
60
60
0
0
0
0
0
0
0
60
0
60
0
60
0
60
0
0
0
60
0
60
0
0
0
0
60
0
0
0
0
0
60
60
0
0
0
0
0
60
0
0
0
0
0
0
60
0
0
60
0
0
0
0
60
0
0
0
60
0
0
0
0
0
0
60
0
0
0
60
60
60
0
0
0
0
60
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
60
0
0
0
0
60
0
0
0
0
60
60
0
0
0
0
0
0
60
0
60
...

result:

ok 460 lines

Test #20:

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

input:

997 280 2
1 1 0
3 1 2
3 1 2
1 1 267
3 2 3
1 3 162
3 3 4
3 2 3
1 4 216
3 2 3
1 1 238
2 2 4 60
1 1 57
1 5 39
1 5 10
3 2 7
3 6 9
1 9 268
1 9 171
3 3 5
3 5 9
1 1 110
1 12 90
1 3 6
1 14 133
1 3 202
1 1 214
3 12 14
3 4 10
3 3 7
1 5 178
3 9 14
3 8 14
1 13 44
1 1 180
1 14 43
3 1 8
1 6 23
3 17 21
2 16 17 216...

output:

0
0
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 466 lines

Subtask #3:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 817ms
memory: 97840kb

input:

198517 3 16
1 1 40710744
1 2 21885097
1 1 23592366
1 4 7387074
1 5 16074177
1 1 41027400
1 4 18082971
1 2 12822448
1 1 2286557
1 1 27896295
1 11 14532760
1 8 2357296
1 11 9190559
1 6 40503152
3 4 11
3 1 7
3 3 7
3 8 14
3 12 15
3 2 3
1 10 34606866
1 13 42718465
1 16 30353561
3 5 11
3 2 6
3 16 18
1 3 2...

output:


result:

wrong output format Output file not found: ""

Subtask #4:

score: 0
Judgement Failed

Test #26:

score: 0
Judgement Failed

input:

198891 26426880 1
1 1 0
2 1 2 0
3 1 2
1 1 0
3 2 3
3 1 2
1 2 0
1 2 0
1 3 0
1 6 0
2 1 6 0
2 3 6 0
3 2 3
1 2 13213440
1 2 13213440
1 4 13213440
3 4 10
1 1 13213440
2 3 4 0
2 3 8 13213440
1 1 0
1 12 0
1 13 0
1 3 0
3 2 11
3 2 12
2 11 14 13213440
1 6 0
2 12 14 0
2 1 2 0
1 10 0
1 12 0
2 3 13 0
3 12 14
3 1 ...

output:


result:


Subtask #5:

score: 0
Judgement Failed

Test #30:

score: 0
Judgement Failed

input:

199458 2 25
1 1 31252443
2 1 2 22827339
1 2 13517756
1 2 5635412
1 3 33397078
1 3 33542998
2 3 5 1484991
3 5 6
2 1 3 7938846
2 1 2 3665458
1 3 29150948
3 4 5
1 3 733545
1 7 4698781
1 7 21699192
1 6 10854390
3 3 8
3 4 8
1 2 6889338
2 1 12 27646676
2 6 8 24407215
1 11 20847453
3 4 13
1 6 16891344
3 4 ...

output:


result:


Subtask #6:

score: 0
Judgement Failed

Test #33:

score: 0
Judgement Failed

input:

49958 1023 2
1 1 122428
1 1 917186
2 2 3 53148
1 3 876461
2 1 3 968146
2 2 4 569341
2 3 4 199413
2 1 4 238371
1 3 127427
1 2 887225
2 1 4 776059
2 4 6 155479
2 1 6 795533
1 5 159578
3 5 6
2 2 5 758778
2 5 6 601115
3 4 7
1 4 202224
2 5 6 902346
3 1 6
3 5 7
3 3 5
1 2 791251
1 5 502214
2 6 7 929048
1 6...

output:


result:


Subtask #7:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%