QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#521086#7151. Tree embeddingAllSolvedin1557WA 14ms13044kbC++173.3kb2024-08-15 21:04:332024-08-15 21:04:34

Judging History

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

  • [2024-08-15 21:04:34]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:13044kb
  • [2024-08-15 21:04:33]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<ll,ll> pii;

vector<pii>v[1005];

ll sz[1005],c0,ans,A[20][1005],n;
bool vis[1005];
ll dis[1005][1005];
map<pii,ll>mp[20],mp2[20];

void getdis(ll st)
{
    for(ll i=1;i<=n;i++) dis[st][i]=-1;
    dis[st][st]=0; queue<ll>q; q.push(st);
    while(!q.empty())
    {
        ll x=q.front(); q.pop();
        for(auto i:v[x])
        {
            if(dis[st][i.fi]!=-1) continue;
            dis[st][i.fi]=dis[st][x]+i.se;
            q.push(i.fi);
        }
    }
}

void getans(ll st)
{
    for(ll j=0;j<=ans;j++)
    {
        fill(vis+1,vis+1+n,0);
        vis[st]=1; queue<ll>q; q.push(st);
        while(!q.empty())
        {
            ll x=q.front(); q.pop();
            for(auto i:v[x])
            {
                if(vis[i.fi]) continue;
                ll c=mp2[j][{x,i.fi}];
                if(!vis[c]&&dis[st][c]==dis[st][i.fi]+dis[i.fi][c]) mp[j][{x,i.fi}]*=-1;
                A[j][i.fi]=A[j][x]+i.se*mp[j][{x,i.fi}];
                q.push(i.fi); vis[i.fi]=1;
            }
        }
    }
}
void init(ll x,ll p)
{
    sz[x]=1;
    for(auto i:v[x])
    {
        if(vis[i.fi]||i.fi==p) continue;
        init(i.fi,x);
        sz[x]+=sz[i.fi];
    }
}
ll get_cent(ll x,ll p,ll nn)
{
    for(auto i:v[x]) if(i.fi!=p&&!vis[i.fi]&&sz[i.fi]*2>nn) return get_cent(i.fi,x,nn);
    return x;
}
void dfs(ll x,ll p,ll t,ll b,ll c)
{
    if(p) mp[b][{x,p}]=mp[b][{p,x}]=t, mp2[b][{x,p}]=mp2[b][{p,x}]=c;
    for(auto i:v[x])
    {
        if(i.fi==p||vis[i.fi]) continue;
        dfs(i.fi,x,t,b,c);
    }
}
void f(ll x,ll b)
{
    init(x,0); ans=max(ans,b);
    ll nn=sz[x],c=get_cent(x,0,sz[x]);
    if(b==0) c0=c;
    if(nn==1) return;
    if(nn==2)
    {
        ll a;
        for(auto i:v[c]) if(!vis[i.fi]) a=i.fi;
        mp[b][{a,c}]=mp[b][{c,a}]=1;
        return;
    }
    init(c,0);
    vector<ll>v1,v2; ll cnt=0;
    vector<pii>tmp;
    for(auto i:v[c])
    {
        if(!vis[i.fi])
            tmp.push_back({sz[i.fi],i.fi});
    }
    sort(tmp.begin(),tmp.end());
    for(auto i:tmp)
    {
        if(i.fi+cnt<=nn/2) v1.push_back(i.se), cnt+=i.fi;
        else v2.push_back(i.se);
    }

    for(auto i:v1) vis[i]=1;
    dfs(c,0,1,b,c);
    f(c,b+1);
    for(auto i:v1) vis[i]=0;
    for(auto i:v2) vis[i]=1;
    dfs(c,0,-1,b,c);
    f(c,b+1);
    for(auto i:v2) vis[i]=0;
}


int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(ll i=1;i<n;i++)
    {
        ll a,b,c; cin>>a>>b>>c;
        v[a].push_back({b,c}); v[b].push_back({a,c});
    }
    for(ll i=1;i<=n;i++) getdis(i);
    f(1,0);
    cout<<ans+1<<'\n';
    getans(c0);
    for(ll j=1;j<=n;j++, cout<<'\n') for(ll i=0;i<=ans;i++) cout<<A[i][j]<<' ';
    /*for(ll i=1;i<=n;i++) for(ll j=i+1;j<=n;j++)
    {
        ll d=0;
        for(ll k=0;k<=ans;k++) d=max(d,abs(A[k][i]-A[k][j]));
        if(d!=dis[i][j])
        {
            cout<<i<<' '<<j<<'\n';
            for(ll k=0;k<=ans;k++) cout<<A[k][i]<<' ';
            cout<<'\n';
            for(ll k=0;k<=ans;k++) cout<<A[k][j]<<' ';
            cout<<'\n';
            cout<<dis[i][j]<<' '<<d<<'\n';
        }
    }*/
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
1 2 2

output:

1
0 
2 

result:

ok 

Test #2:

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

input:

4
1 2 1
1 3 1
1 4 1

output:

3
0 0 0 
-1 -1 1 
-1 1 1 
1 1 0 

result:

ok 

Test #3:

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

input:

10
8 2 33305
2 6 69148
3 2 78693
5 9 4671
4 9 60174
7 2 53555
9 2 44205
1 5 51522
4 10 8094

output:

5
-56193 56193 -56193 56193 0 
44205 -44205 -44205 44205 0 
122898 -122898 -122898 -34488 78693 
-60174 -60174 60174 60174 0 
-4671 4671 -4671 4671 0 
113353 -113353 -113353 113353 69148 
97760 -97760 9350 97760 0 
77510 -10900 -77510 77510 0 
0 0 0 0 0 
-68268 -68268 68268 68268 0 

result:

ok 

Test #4:

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

input:

7
3 2 84583
1 2 99813
2 6 69523
4 2 85328
5 7 95654
5 4 79707

output:

4
-99813 -99813 -99813 99813 
0 0 0 0 
-84583 -84583 84583 84583 
85328 85328 85328 0 
165035 165035 165035 79707 
-69523 69523 69523 0 
260689 260689 260689 175361 

result:

ok 

Test #5:

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

input:

7
3 1 81630
4 3 90999
7 5 34787
4 2 45864
6 4 22160
3 7 70320

output:

4
-81630 -81630 81630 0 
136863 45135 -136863 136863 
0 0 0 0 
90999 90999 -90999 90999 
-105107 105107 105107 105107 
113159 113159 -68839 90999 
-70320 70320 70320 70320 

result:

ok 

Test #6:

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

input:

9
5 9 52
7 9 97888
4 7 72858
1 6 71334
6 2 19443
8 2 31727
5 3 14365
2 7 75461

output:

4
166238 166238 -15316 166238 
75461 75461 75461 75461 
-112305 -112305 83471 112305 
-72858 72858 -72858 72858 
-97940 -97940 97836 97940 
94904 94904 56018 94904 
0 0 0 0 
107188 43734 107188 107188 
-97888 -97888 97888 97888 

result:

ok 

Test #7:

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

input:

2
1 2 20340

output:

1
0 
20340 

result:

ok 

Test #8:

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

input:

2
2 1 51883

output:

1
0 
51883 

result:

ok 

Test #9:

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

input:

8
8 7 10751
3 4 95845
6 7 62471
6 2 19671
2 3 29382
2 5 10022
7 1 3280

output:

4
-65751 59191 -65751 65751 
19671 19671 -19671 19671 
49053 49053 9711 49053 
144898 144898 105556 144898 
29693 9649 -29693 29693 
0 0 0 0 
-62471 62471 -62471 62471 
-73222 73222 -51720 62471 

result:

ok 

Test #10:

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

input:

9
4 9 36917
1 6 23007
5 4 46177
8 7 54587
1 7 71340
2 1 56998
6 3 27648
4 1 33264

output:

5
0 0 0 0 0 
-56998 -56998 56998 0 0 
-50655 50655 50655 50655 0 
33264 33264 33264 33264 33264 
79441 79441 -12913 79441 79441 
-23007 23007 23007 23007 0 
71340 -71340 71340 71340 0 
125927 -125927 125927 125927 0 
70181 70181 70181 70181 33264 

result:

ok 

Test #11:

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

input:

10
7 5 75030
7 6 72683
10 7 21009
1 10 98067
8 6 78011
2 6 37017
3 7 59811
7 9 75484
4 9 29913

output:

5
119076 -119076 -119076 119076 0 
109700 109700 35666 -109700 109700 
-59811 -59811 -59811 59811 0 
-105397 105397 -105397 105397 0 
-75030 -75030 75030 75030 0 
72683 72683 72683 -72683 72683 
0 0 0 0 0 
150694 150694 150694 5328 72683 
-75484 75484 -75484 75484 0 
21009 -21009 -21009 21009 0 

result:

ok 

Test #12:

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

input:

9
6 4 45480
1 3 73208
8 5 48334
2 8 85607
9 3 26872
6 7 38398
6 8 56313
8 3 34234

output:

5
107442 -107442 -38974 -107442 107442 
-85607 -85607 85607 0 0 
34234 -34234 34234 -34234 34234 
101793 101793 -101793 10833 45480 
-48334 48334 48334 0 0 
56313 56313 -56313 56313 0 
94711 94711 -94711 94711 38398 
0 0 0 0 0 
61106 -61106 61106 -7362 34234 

result:

ok 

Test #13:

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

input:

10
3 2 43219
1 2 36963
5 10 33305
6 9 69148
4 9 78693
2 9 4671
9 7 60174
10 9 53555
10 8 44205

output:

5
41634 -41634 -41634 -32292 36963 
4671 -4671 -4671 4671 0 
47890 -47890 -47890 47890 43219 
-78693 -78693 -78693 78693 0 
86860 86860 -86860 20250 33305 
-69148 -69148 69148 69148 0 
-60174 60174 60174 0 0 
97760 97760 -97760 97760 44205 
0 0 0 0 0 
53555 53555 -53555 53555 0 

result:

ok 

Test #14:

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

input:

10
6 7 99813
1 9 69523
3 6 85328
9 5 95654
2 10 79707
2 8 98694
6 2 81188
6 9 62924
4 6 13856

output:

5
132447 132447 -132447 -6599 69523 
81188 -81188 81188 81188 81188 
-85328 -85328 -85328 85328 0 
-13856 -13856 13856 13856 0 
158578 158578 -158578 158578 95654 
0 0 0 0 0 
-99813 99813 99813 0 0 
179882 -179882 -17506 179882 179882 
62924 62924 -62924 62924 0 
160895 -160895 160895 160895 81188 

result:

ok 

Test #15:

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

input:

10
1 2 90999
2 7 34787
2 6 45864
6 10 22160
6 4 70320
3 2 25420
2 9 2202
7 5 72292
8 7 40402

output:

5
-90999 -90999 -90999 90999 0 
0 0 0 0 0 
-25420 -25420 25420 25420 0 
116184 -116184 -24456 116184 116184 
107079 107079 -37505 107079 107079 
45864 -45864 45864 45864 45864 
34787 34787 34787 34787 34787 
75189 75189 75189 75189 34787 
-2202 2202 2202 0 0 
68024 -68024 68024 68024 45864 

result:

ok 

Test #16:

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

input:

10
9 6 14889
9 10 52
5 9 97888
9 4 72858
9 7 71334
9 8 19443
9 1 31727
2 9 14365
9 3 75461

output:

5
-31727 -31727 -31727 -31727 31727 
-14365 -14365 -14365 14365 14365 
-75461 -75461 75461 75461 0 
-72858 72858 -72858 72858 0 
-97888 97888 97888 97888 0 
14889 -14889 -14889 14889 0 
71334 -71334 71334 71334 0 
19443 19443 -19443 19443 0 
0 0 0 0 0 
52 52 52 52 0 

result:

ok 

Test #17:

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

input:

10
10 6 6075
10 2 98020
10 1 58423
2 4 99364
10 7 37755
8 7 13465
9 10 52741
3 7 91030
2 5 2008

output:

5
-58423 -58423 -58423 58423 0 
98020 -98020 -98020 98020 0 
128785 128785 -128785 -53275 91030 
197384 -197384 -197384 -1344 99364 
100028 -100028 -100028 100028 2008 
-6075 -6075 6075 6075 0 
37755 37755 -37755 37755 0 
51220 51220 -51220 51220 13465 
-52741 52741 52741 0 0 
0 0 0 0 0 

result:

ok 

Test #18:

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

input:

10
7 6 86861
5 2 30580
8 6 10447
10 2 25869
2 6 62961
1 2 16000
3 4 6458
2 3 399
3 9 4363

output:

5
-16000 -16000 -16000 16000 0 
0 0 0 0 0 
399 -399 399 399 399 
6857 -6857 -6059 6857 6857 
-30580 -30580 30580 30580 0 
62961 62961 62961 62961 62961 
149822 149822 -23900 149822 149822 
73408 73408 73408 73408 62961 
4762 -4762 4762 4762 399 
-25869 25869 25869 0 0 

result:

ok 

Test #19:

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

input:

10
10 3 10751
5 8 95845
1 10 62471
3 9 19671
8 4 29382
2 3 10022
7 1 3280
1 6 18279
10 8 30909

output:

5
-62471 -62471 62471 0 0 
20773 -20773 -20773 729 10022 
10751 -10751 -10751 10751 0 
60291 60291 -60291 1527 29382 
126754 126754 -126754 126754 95845 
-80750 -80750 44192 18279 0 
-65751 -65751 65751 3280 0 
30909 30909 -30909 30909 0 
30422 -30422 -30422 30422 19671 
0 0 0 0 0 

result:

ok 

Test #20:

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

input:

10
3 9 1937
9 6 36917
10 4 23007
5 8 46177
10 2 54587
10 6 71340
7 9 56998
8 1 27648
6 8 33264

output:

5
-60912 -60912 5616 27648 0 
125927 125927 -125927 16753 54587 
38854 -38854 34980 -38854 38854 
94347 94347 -94347 94347 23007 
-79441 -79441 79441 46177 0 
0 0 0 0 0 
93915 -93915 93915 20081 36917 
-33264 -33264 33264 0 0 
36917 -36917 36917 -36917 36917 
71340 71340 -71340 71340 0 

result:

ok 

Test #21:

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

input:

10
5 3 58531
5 8 2182
3 2 75030
7 4 72683
4 3 21009
4 1 98067
2 9 78011
2 10 37017
5 6 59811

output:

5
119076 -119076 -77058 -119076 119076 
-75030 75030 75030 75030 0 
0 0 0 0 0 
21009 -21009 21009 -21009 21009 
58531 58531 58531 58531 58531 
118342 118342 -1280 118342 118342 
93692 -93692 93692 51674 21009 
60713 60713 60713 60713 58531 
-153041 -2981 153041 153041 0 
-112047 112047 112047 75030 0 

result:

ok 

Test #22:

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

input:

10
2 6 42660
5 6 45480
9 1 73208
3 4 48334
1 7 85607
4 8 26872
4 10 38398
6 4 56313
4 1 34234

output:

5
34234 -34234 34234 34234 34234 
98973 98973 13653 -98973 98973 
-48334 -48334 -48334 48334 0 
0 0 0 0 0 
101793 101793 101793 -10833 56313 
56313 56313 56313 -56313 56313 
119841 -119841 -51373 119841 119841 
-26872 -26872 26872 26872 0 
107442 -107442 107442 107442 34234 
-38398 38398 38398 0 0 

result:

ok 

Test #23:

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

input:

14
1 8 99172
5 14 84394
3 14 7875
8 11 46747
11 12 91464
1 10 41274
4 3 51473
12 9 99888
13 14 48591
6 3 42998
12 7 9735
2 11 62362
12 3 24208

output:

5
-237383 -237383 -54455 237383 145919 
-153826 -153826 153826 29102 62362 
24208 24208 -24208 24208 0 
75681 -27265 -75681 -27265 51473 
116477 116477 -100727 116477 92269 
67206 -18790 -67206 67206 42998 
-9735 9735 -9735 -9735 9735 
-138211 -138211 44717 138211 46747 
-99888 99888 -99888 99888 99...

result:

ok 

Test #24:

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

input:

20
12 17 9662
8 18 79403
9 12 39209
12 2 88815
12 4 65532
13 11 55258
15 17 57286
17 10 31472
2 19 39326
20 8 53686
17 5 16764
2 16 79545
12 13 50718
1 14 58728
2 6 50181
20 2 7766
14 11 12309
3 13 18809
14 7 953

output:

6
177013 -177013 177013 -177013 59557 113986 
88815 88815 88815 88815 -88815 88815 
69527 -69527 31909 -69527 31909 18809 
-65532 65532 -65532 -65532 65532 0 
-26426 -26426 -7102 -7102 16764 0 
138996 138996 38634 38634 -138996 138996 
119238 -119238 119238 -119238 119238 56211 
150267 150267 150267...

result:

ok 

Test #25:

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

input:

30
3 5 28796
4 9 10034
22 12 89509
21 8 23277
10 2 3196
4 29 59345
6 20 11469
10 13 51654
10 4 71995
7 12 28072
3 23 52059
7 26 50022
4 6 93782
10 25 13380
16 3 23595
7 9 36250
9 15 83594
11 2 1106
18 24 24090
28 3 42510
27 28 96564
10 8 34047
2 19 97541
10 17 75663
10 3 40752
30 1 16408
24 7 93194
...

output:

8
138970 138970 138970 138970 57466 57466 138970 0 
-3196 3196 3196 3196 3196 3196 0 0 
40752 40752 40752 40752 -40752 -40752 40752 0 
71995 -71995 -71995 -71995 71995 71995 71995 0 
69548 69548 69548 11956 -69548 -69548 11956 28796 
165777 -165777 21787 21787 165777 71995 71995 0 
118279 -25711 -11...

result:

ok 

Test #26:

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

input:

40
18 39 61594
12 17 36186
37 33 1532
10 6 91806
23 20 60906
19 9 15159
13 38 22702
22 3 60048
28 21 62359
22 25 6011
26 35 43190
34 31 4138
30 12 49058
25 6 89047
31 19 43124
13 4 49436
25 26 41836
25 5 16956
26 14 45706
21 36 68537
12 15 55029
33 27 52251
33 26 88024
34 21 78287
12 32 65664
12 25 ...

output:

8
141228 141228 141228 141228 -48120 -141228 141228 0 
158805 158805 158805 158805 158805 -158805 158805 0 
66059 66059 66059 -54037 66059 -66059 66059 0 
194785 174695 -194785 -194785 -186509 -6915 194785 0 
-16956 -16956 16956 -16956 16956 0 0 0 
-89047 -89047 -89047 89047 89047 0 0 0 
-206817 -20...

result:

ok 

Test #27:

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

input:

54
16 26 45496
4 34 82464
15 6 98989
25 42 37516
48 10 11511
52 12 48230
47 34 75909
48 29 62311
53 6 31322
40 31 25243
42 37 43372
26 42 21924
16 5 49734
26 36 43349
47 9 73734
39 41 89591
14 44 22016
34 1 60743
42 49 26617
4 39 29014
34 7 61100
50 2 19720
34 2 64617
43 40 2358
4 8 39665
39 33 9226...

output:

8
60743 60743 -60743 60743 -60743 60743 0 0 
-64617 -64617 -64617 64617 64617 64617 0 0 
-150819 150819 -150819 -24493 -97129 29197 123974 0 
82464 -82464 82464 -82464 82464 82464 0 0 
232614 232614 -232614 42154 -232614 141622 18589 76641 
-99407 99407 99407 -99407 99407 -99407 99407 0 
-61100 -611...

result:

ok 

Test #28:

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

input:

67
54 2 27000
47 1 56096
16 62 95394
45 33 93374
14 31 20926
41 6 89398
54 24 54732
36 18 64923
58 22 72499
33 40 48515
4 65 42746
40 49 50954
33 4 30319
52 36 28368
65 5 14020
23 20 64887
48 27 91661
17 32 56902
26 3 48451
59 38 38248
17 40 27460
49 57 84654
51 60 42960
24 28 39849
52 58 8142
50 35...

output:

9
33038 -33038 -27600 33038 -27600 33038 33038 30319 0 
164321 164321 164321 -164321 136281 136281 857 164321 0 
131859 -131859 -5965 -71221 -131859 5965 131859 30319 0 
0 0 0 0 0 0 0 0 0 
56766 56766 56766 -56766 28726 28726 56766 56766 0 
-28814 -28814 28814 -28814 -28814 -28814 28814 0 0 
247168 ...

result:

ok 

Test #29:

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

input:

73
52 70 80451
44 32 1449
6 14 82173
24 38 56605
49 4 83134
2 53 62244
70 16 68371
69 50 60868
39 67 42364
17 19 94331
60 11 94001
71 51 91350
56 21 12570
30 73 2299
23 58 71318
71 72 78176
73 4 917
4 33 70353
40 20 30654
1 36 24366
8 10 59530
58 25 14218
1 67 45255
36 12 68333
47 40 12406
61 11 837...

output:

9
130886 -130886 130886 -83196 130886 -40376 40376 -16531 61786 
40479 -40479 7211 40479 7211 -15667 15667 16634 0 
-213484 -213484 41640 -118786 166135 0 0 0 0 
152575 152575 -11869 -152575 -152575 -152575 -152575 11869 70353 
326748 326748 -326748 162304 162304 -152872 -10410 198058 107233 
-47349...

result:

ok 

Test #30:

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

input:

87
49 25 39368
24 2 71698
58 17 91578
30 86 33561
78 43 11951
15 8 34603
66 76 61167
83 8 22548
48 63 91658
8 51 13731
70 3 61233
9 29 72302
63 21 52219
53 72 43756
56 13 78626
13 65 23833
8 11 91619
8 84 84693
64 8 51042
85 6 7205
40 68 60611
42 16 39505
59 50 94034
17 9 31620
72 78 73852
61 52 429...

output:

11
-139462 -139462 92220 139462 -139462 139462 0 0 0 0 0 
328032 -328032 144876 239042 237092 -53936 99406 78364 -78364 91578 91578 
-137285 90043 -137285 137285 90043 14819 61233 0 0 0 0 
150673 150673 150673 -150673 -150673 -1011 91651 -50653 150673 18390 81630 
109129 -100455 -74027 109129 109129...

result:

ok 

Test #31:

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

input:

2
2 1 27833

output:

1
0 
27833 

result:

ok 

Test #32:

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

input:

81
7 79 7136
79 21 33814
76 73 11348
18 9 98679
19 21 80484
25 68 85491
67 3 73962
63 61 99432
42 5 25124
71 45 29653
59 20 15283
42 21 8926
59 38 74175
23 49 57772
22 8 58928
13 57 35851
26 19 60247
8 1 41995
36 45 4771
60 68 9248
56 4 19565
45 7 26690
34 63 89165
18 79 19662
7 47 2497
16 73 75362
...

output:

10
244191 244191 -244191 -244191 -134377 160201 -244191 244191 -71410 136803 
-114271 99999 114271 46619 114271 -114271 1557 87581 0 0 
373360 305732 373360 287368 -219740 -373360 373360 305732 225436 73962 
166854 166854 -166854 -127724 -166854 127724 -166854 166854 -16503 81896 
67864 -67864 67864...

result:

ok 

Test #33:

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

input:

100
66 20 64331
71 93 56075
94 37 24424
22 86 23870
43 97 27051
14 51 1989
87 75 50829
58 16 63588
100 73 26141
90 52 14995
35 49 5213
86 12 47936
25 5 6213
26 87 51404
73 9 40063
37 72 57353
59 8 79465
7 4 11042
89 33 19830
100 51 63700
44 63 36365
25 63 78125
83 20 27081
73 40 90964
54 26 96279
3 ...

output:

9
192299 -192299 -64899 86287 -192299 41113 -135375 163837 0 
135756 135756 -135756 42386 -129438 -135756 -129438 135756 43526 
-115357 115357 115357 -115357 63075 -63075 115357 89216 0 
235707 -235707 129695 -108307 2295 72145 59219 51024 37220 
87497 87497 81179 81179 87497 -87497 -81179 75071 621...

result:

ok 

Test #34:

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

input:

100
56 22 62377
58 55 65266
65 51 8075
82 30 63128
41 65 98262
63 75 73348
26 78 78308
69 73 83265
32 35 51859
75 66 18818
82 23 90696
42 79 31835
38 87 46601
74 40 62693
65 64 78114
56 75 89854
39 11 40514
40 9 81703
9 92 22171
72 73 22340
56 98 67781
62 85 42175
24 83 27835
5 42 51782
38 27 54236
...

output:

11
286427 123043 286427 286427 123043 189087 123043 103875 -30031 10863 113447 
-230912 115526 230912 -51004 50440 -129468 37062 180190 0 0 0 
253831 90447 253831 253831 90447 156491 90447 51235 2565 -41777 123469 
76625 76625 -76625 -76625 76625 -76625 76625 -76625 -76625 76625 0 
-6971 -6971 6971 ...

result:

ok 

Test #35:

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

input:

100
37 33 60423
81 66 7160
16 11 67535
1 39 78194
31 45 4065
20 66 44706
82 75 5786
32 97 78750
79 37 77577
69 1 88048
66 28 33075
13 94 72629
41 92 54285
17 1 73982
78 54 16165
10 88 22354
15 18 44666
12 84 11147
35 64 319
68 28 80980
28 57 31900
49 55 30418
15 30 38989
20 31 45304
13 99 12193
57 7...

output:

10
183019 183019 -183019 -183019 -183019 -131827 -113549 140525 60236 0 
134221 134221 -134221 -55721 -55721 -83029 13749 91727 60236 0 
-248568 -248568 -47240 248568 82710 -18910 182418 33075 33075 0 
481596 -481596 481596 347014 95872 95872 93928 405581 85470 0 
-173633 -173633 -173633 122175 -113...

result:

ok 

Test #36:

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

input:

100
62 53 23877
7 67 40543
67 71 83890
13 34 25964
67 2 75276
57 9 50657
63 37 33265
50 57 74236
4 62 70592
27 62 24574
67 54 10045
100 67 56527
74 67 94674
72 57 52568
87 62 86921
97 62 54855
1 67 48819
32 67 73295
67 5 78468
57 20 39621
54 55 96020
25 16 61764
85 52 15551
70 67 6122
57 63 2854
28 ...

output:

9
-124095 26457 26457 26457 26457 -124095 124095 0 0 
0 0 0 0 0 0 0 0 0 
-174578 174578 174578 174578 174578 24026 174578 0 0 
153278 -153278 -153278 -153278 -153278 -153278 -54286 12094 70592 
-153744 -3192 -3192 -3192 153744 -153744 153744 0 0 
102722 -102722 -102722 -102722 -102722 -102722 -3730 ...

result:

ok 

Test #37:

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

input:

100
96 51 21924
11 98 49734
19 100 43349
96 29 73734
26 37 89591
91 84 22016
47 68 60743
75 10 26617
93 14 29014
89 60 61100
15 50 19720
78 85 64617
19 33 2358
53 22 39665
17 55 92268
92 86 63163
16 3 9867
83 51 2739
97 34 80808
63 64 98261
90 53 84331
50 26 50006
94 64 83601
3 90 23836
47 20 60811
...

output:

10
99186 99186 -54238 -54238 -54238 -54238 54238 -99186 99186 76712 
-79700 79700 79700 79700 -79700 -79700 79700 0 0 0 
32399 -32399 -16461 32399 32399 -16461 16461 -16461 16461 7969 
79794 -79794 79794 -63856 -63856 79794 -79794 79794 63856 7969 
-90721 51281 -90721 -90721 32281 -32281 90721 29220...

result:

ok 

Test #38:

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

input:

100
29 77 44162
71 20 58925
60 11 27000
59 97 56096
48 31 95394
13 99 93374
16 62 20926
53 32 89398
3 85 54732
71 30 64923
9 80 72499
98 95 48515
73 54 42746
53 9 50954
61 2 30319
26 100 28368
77 56 14020
77 41 64887
13 33 91661
34 70 56902
99 91 48451
57 27 38248
61 81 27460
61 22 84654
23 60 42960...

output:

10
-171778 171778 171778 171778 171778 171778 114150 -24314 98046 0 
32707 32707 -28811 31827 -27931 -31827 31827 440 0 0 
-54732 54732 54732 54732 -54732 54732 54732 -54732 54732 0 
270669 -270669 -72867 270669 72867 -124835 -72867 -25934 98851 0 
324342 -324342 324342 324342 126540 -141340 141340 ...

result:

ok 

Test #39:

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

input:

100
52 70 74912
79 46 68115
62 97 19163
63 42 28058
56 42 66605
9 57 64733
52 13 48405
21 68 84883
45 37 80451
7 47 1449
13 71 82173
41 3 56605
12 61 83134
18 25 62244
85 33 68371
36 57 60868
1 6 42364
39 29 94331
13 10 94001
9 7 91350
69 13 12570
83 7 2299
40 34 71318
41 85 78176
94 25 917
86 73 70...

output:

10
-114438 114438 -114438 114438 -114438 29710 -114438 114438 0 0 
347219 347219 347219 -347219 173343 -173343 -119815 -148531 -32961 195026 
138944 -138944 -138944 25734 -25734 82339 -82339 82339 -82339 82339 
-225750 -225750 177018 -177018 -225750 -177018 201384 0 0 0 
101296 101296 101296 -101296...

result:

ok 

Test #40:

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

input:

100
62 55 72959
99 13 34202
93 51 35518
83 85 75828
21 46 72408
29 93 3388
74 96 75883
81 70 13073
44 73 6169
83 23 70679
74 39 59144
78 11 40503
60 79 90818
86 44 40829
32 84 6422
40 75 93369
15 59 79221
31 74 99583
59 7 72150
5 93 49991
12 7 43986
67 79 90541
86 58 39368
18 78 71698
44 17 91578
38...

output:

11
-50691 50691 50691 50691 50691 -50691 -50691 50691 0 0 0 
302845 302845 147149 -302845 -214315 302845 -302845 149811 -71963 148480 0 
373943 314921 373943 373943 373943 210483 -210483 321724 -20531 292213 91619 
141193 -141193 141193 62129 -82171 3107 69043 29511 0 0 0 
-49991 49991 -49991 -49991...

result:

ok 

Test #41:

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

input:

100
19 45 3709
39 70 43393
54 24 94977
49 71 90894
89 24 10915
73 76 42043
43 38 27554
32 78 46
25 73 99183
15 68 7205
33 63 77331
39 16 14001
30 51 31206
69 13 27927
26 96 1369
85 73 25869
73 53 83374
48 10 94435
46 65 74490
48 26 8631
40 20 40810
15 39 46079
36 51 15930
13 75 32516
13 4 49535
33 1...

output:

10
73432 -73432 -73432 -73432 -73432 2236 -35598 35598 -35598 35598 
-196859 196859 -196859 -196859 -87849 49465 -19192 117287 0 0 
146569 146569 146569 -35677 -35677 -146569 -146569 -146569 35677 55446 
250448 250448 250448 -61698 -250448 -30868 -160768 -250448 151378 49535 
-155341 155341 18027 -1...

result:

ok 

Test #42:

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

input:

100
14 9 45032
64 30 88516
29 61 62092
83 11 60471
97 84 32298
87 57 90134
81 26 5662
1 99 33404
15 34 83812
35 7 98313
36 32 92767
41 40 73666
72 49 45942
89 47 56014
15 54 93649
22 21 72090
8 88 7136
49 73 33814
83 90 11348
31 99 98679
9 1 80484
88 81 85491
9 37 73962
13 95 99432
93 40 25124
55 4 ...

output:

10
-213958 213958 213958 213958 103906 -27870 213958 0 0 0 
173355 -173355 -173355 171779 100077 100077 -29175 -42527 107941 0 
74696 74696 -11304 -11304 -11304 -11304 -74696 74696 0 0 
358817 358817 358817 211485 57665 224683 -57665 208241 -121511 149028 
206933 -206933 62753 -62753 206933 206933 5...

result:

ok 

Test #43:

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

input:

694
147 589 63460
577 525 24867
168 48 46802
320 49 56053
387 45 50030
394 179 31066
25 137 52761
146 176 47924
156 69 97243
126 78 43246
299 286 98398
63 159 97810
313 340 80398
285 66 74961
471 290 91679
321 672 65088
346 145 22183
63 516 56245
262 479 75583
301 104 92046
678 270 62662
354 287 268...

output:

14
404303 272015 404303 -404303 404303 -404303 205379 -71411 393377 261089 -111391 202137 93999 93999 
410130 -410130 410130 -410130 410130 -410130 -45566 -104810 -78834 94848 -128344 157641 66144 66144 
97336 97336 -78588 97336 -97336 97336 97336 -97336 -97336 97336 97336 -97336 -78588 87962 
24839...

result:

ok 

Test #44:

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

input:

243
112 85 29656
158 90 90481
7 224 74519
234 203 84992
211 163 40562
23 207 2621
32 206 45866
139 137 88564
167 73 28471
233 118 33350
176 54 36866
232 227 54696
212 30 88043
208 192 47939
85 22 4388
203 189 54130
177 71 11667
93 6 57606
102 201 17140
149 28 62053
216 20 48661
145 158 32199
208 140...

output:

12
174597 45033 -174597 174597 -174597 -45033 47897 -81355 45033 -64782 64782 64782 
404785 275221 275221 404785 -404785 404785 133763 80561 -55837 -386997 395891 162112 
297623 168059 168059 297623 -297623 297623 26601 -26601 -162999 -297623 297623 162112 
210579 81015 81015 210579 -210579 113645 2...

result:

ok 

Test #45:

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

input:

229
166 193 54447
108 132 97263
156 17 38984
110 43 31667
23 184 79564
108 111 67697
13 31 98378
86 74 74184
178 75 95633
213 19 77916
41 73 4856
216 76 87443
56 108 43031
187 107 39032
150 174 99980
168 195 47899
74 136 46680
82 196 32622
29 14 42559
27 158 93866
49 229 85484
99 61 27912
3 25 81994...

output:

13
262551 262551 -262551 -60265 24853 262551 -262551 80889 80889 -217499 -66705 240025 0 
267058 267058 -267058 -55758 29360 267058 -267058 222006 183644 -76382 36050 244532 0 
-243226 243226 243226 154292 243226 243226 154292 154292 157393 0 0 0 0 
238661 -238661 238661 -91693 -20221 91693 -20221 2...

result:

ok 

Test #46:

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

input:

135
18 110 50257
93 82 38644
88 87 83809
119 60 33528
28 100 98246
16 3 4218
22 10 82711
124 21 9452
48 128 9313
67 4 53331
64 79 47618
37 75 70473
32 113 21071
52 107 89692
3 60 71663
115 123 59213
49 61 47261
57 19 30547
46 50 32041
23 86 63669
131 32 61464
67 116 1076
57 61 14112
44 121 11326
16 ...

output:

12
356880 -356880 -356880 -356880 -84422 356880 59213 59213 59213 59213 -59213 59213 
-161136 -161136 34196 34196 -34196 34196 -34196 -97666 97666 0 0 0 
137812 137812 137812 137812 137812 -137812 72570 72570 5514 72570 104284 0 
176695 58269 -176695 -176695 -70033 123364 123364 123364 123364 123364...

result:

ok 

Test #47:

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

input:

683
235 104 98616
92 434 23280
474 273 65503
23 560 76232
399 625 51375
95 541 97791
294 464 23918
1 522 35198
90 4 40934
299 644 78673
470 391 33958
630 101 40872
50 323 70111
296 52 95959
3 523 50951
428 463 84150
257 401 65337
551 601 25697
512 668 12532
327 378 62008
386 449 57976
451 411 21345
...

output:

16
390784 390784 191160 390784 390784 -390784 32942 390784 -390784 257158 -15822 -191160 240356 187481 0 0 
306111 284613 306111 214561 -306111 119677 306111 -306111 306111 -145485 160127 306111 20999 295362 109351 0 
224481 202983 224481 132931 -224481 -63855 224481 -122579 122579 38047 224481 1735...

result:

ok 

Test #48:

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

input:

668
60 628 90967
90 181 51755
225 381 51207
351 335 15056
315 299 97634
533 364 80940
27 328 8478
580 222 66561
131 514 68998
408 530 33026
481 46 19385
108 186 21688
16 262 36552
118 532 99424
135 553 10812
368 488 56555
232 515 96909
169 572 86653
653 365 17004
309 571 84879
558 552 3546
374 349 1...

output:

16
301762 -301762 181752 237372 301762 237372 -181752 110464 -79702 88990 46074 169227 32195 0 0 0 
-148630 -148630 83954 -99090 -148630 148630 -148630 -148630 148630 123860 0 0 0 0 0 0 
229840 165450 229840 -229840 229840 -229840 -128798 32014 32014 -41752 4511 -43881 43881 0 0 0 
-231733 -231733 -...

result:

ok 

Test #49:

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

input:

654
253 300 46023
74 450 58055
70 278 34456
466 79 61503
260 552 86524
280 333 15911
392 584 27739
542 112 4504
34 615 67012
621 618 7667
371 82 49159
512 124 7194
233 431 83098
235 541 13140
195 151 71573
191 45 57933
487 20 32085
386 60 61203
423 650 25500
17 252 54298
450 478 15503
30 258 43193
4...

output:

14
318618 128234 318618 -318618 -36470 36470 318618 -114250 260084 318618 -226854 318618 117952 0 
298359 -298359 298359 -298359 120749 -50769 -107975 -298359 57255 114663 95335 101512 0 0 
-107242 71438 107242 107242 -71438 -55264 -71438 91068 73166 73166 8087 8087 0 0 
229640 39256 229640 6026 229...

result:

ok 

Test #50:

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

input:

560
53 332 14502
304 546 51673
536 85 76888
466 391 18058
82 469 83789
209 219 81545
30 430 16897
153 372 31499
93 62 26371
37 97 38332
30 187 22007
288 58 92087
298 34 41813
278 344 64464
82 150 3559
334 547 87083
390 453 91183
271 182 59777
32 323 50174
506 509 43522
176 504 23582
528 62 95406
483...

output:

14
379652 -379652 133750 68634 127698 43856 127698 -208098 -379652 -136924 287820 -125977 125977 0 
217964 -217964 -27938 -217964 -33990 33990 -158900 -217964 -93054 -96445 155509 -125977 125977 0 
219473 219473 219473 219473 219473 219473 219473 184657 219473 184657 219473 202065 23969 169391 
2339...

result:

ok 

Test #51:

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

input:

546
206 298 75420
519 234 34209
303 439 91769
541 437 77447
220 441 66144
252 267 66928
427 429 59902
353 199 86893
74 145 4005
227 56 73170
543 33 54988
119 291 920
407 414 13805
516 124 55738
64 228 28358
415 166 96952
43 254 54136
445 132 94198
383 185 5931
197 462 65982
210 191 17224
122 352 918...

output:

14
367217 177261 367217 117865 -367217 177261 225699 303859 225699 -9739 7020 -4064 264779 0 
276527 -276527 104135 86571 86571 -276527 276527 276527 -86571 -276527 276527 181174 94978 0 
392753 392753 -392753 392753 293367 392753 -392753 282403 -392753 -8683 -53783 19273 245734 0 
-81132 -81132 811...

result:

ok 

Test #52:

score: -100
Wrong Answer
time: 8ms
memory: 12704kb

input:

763
384 629 2722
249 734 76525
750 364 69562
269 516 98782
582 366 79581
16 142 27573
263 43 13588
59 194 11024
212 64 73238
537 484 8035
252 459 98546
731 106 23446
416 552 2794
381 658 4901
213 544 64530
336 286 56704
395 169 27669
618 231 47977
693 211 69456
246 65 32408
338 109 76053
180 216 929...

output:

17
-257551 64377 257551 257551 -257551 -257551 -111501 101387 -161335 224111 184526 -179469 179469 0 0 0 0 
243493 175495 39321 243493 243493 -243493 33469 243493 -243493 82829 -33469 175495 218813 0 0 0 0 
159712 91714 -159712 44460 159712 -159712 44460 159712 -159712 159712 -102086 34088 102086 0 ...

result:

wrong answer dim is out of range