QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#534336#9159. 登山ChiFAN20 540ms64148kbC++145.8kb2024-08-27 03:17:262024-08-27 03:17:26

Judging History

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

  • [2024-08-27 03:17:26]
  • 评测
  • 测评结果:20
  • 用时:540ms
  • 内存:64148kb
  • [2024-08-27 03:17:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 998244353;
const int maxn = 1e5+114;
int fa[maxn],l[maxn],r[maxn],h[maxn];
int dep[maxn];
int dp[maxn],pre[maxn];
int lim[maxn],n;
//一个点 u 可以冲刺到的点深度区间 [l_u,r_u]
//经过一个点 u 后的冲刺深度限制为 [1,lim_u]
//v 滑落到 u 再冲刺到 w
//to_u(k) u 深度为 k 的编号
//val(u,v) = \min_{l \in path(u,v)} lim_l
//pre_u = \sum_{l \in path(1,u)} dp_l
vector<int> kfa,st;
int to(int k){
    return kfa[k];
}
/*
枚举 u
dp_v <- dp_v + dp_w
dep_w \in [l_u,min(r_u,val(u,v))]
val(u,v) >= l_u
假若 r_u < val(u,v)
建出 1 \to u 路径上所有点的 lim 构成的单调栈
则可以二分确定出满足 r_u < val(u,v) 的 v 构成一条链
dep_w \in [l_u,r_u]
dp_v <- dp_v + \sum_{dep_w \in [l_u,r_u]} dp_w
dp_v <- dp_v + pre_{to_u(r_u)} - pre_{to_u(l_u-1)}
由于 lim_v >= val(u,v) >  r_u
所以处理 v 时 to_u(r_u),to_v(l_u-1) 一定已经处理好,故讲链加挂在其上即可
假若 r_u >= val(u,v)
依然可以二分确定出满足 r_u >= val(u,v) 且 l_u <= val(u,v) 的 v 构成一条链
dep_w \in [l_u,val(u,v)]
dp_v <- dp_v + pre_{to_u(val(u,v)} - pre_{to_u(l_u-1)}
对于 - pre_{to_u(l_u-1)} 的部分,由于 lim_v >= val(u,v) >= l_u,依然可以挂在 to_u(l_u-1) 上处理
现在我们只考虑 dp_v <- dp_v + pre_{to_u(val(u,v)} 怎么做
对于一个 u 从 fa_u 过来时,变化的 val(u,v) 段数均摊是 O(1) 的
每一段内所有 dp_v 增量相同
考虑对于每一段维护段内被加了多少次,然后在段被弹出时把被加的贡献转化为挂到 to_u(val(u,v)) 上的链加
被加的段是栈中一个段区间
*/
vector<int> E[maxn];
vector< pair<int,pair<int,int> > > add[maxn];//(k,u,v) k 表示 pre 贡献的系数 u,v 表示贡献到是 u->v 的链(祖先到后代)
int tr[maxn];
int L[maxn],R[maxn],dfncnt;
int g[maxn];
void listadd(int u,int v,int c){
    int x=L[v];
    while(x<=n) tr[x]=(tr[x]+c)%mod,x+=x&(-x);
    u=fa[u];
    if(u==0) return ;
    x=L[u];
    while(x<=n) tr[x]=(tr[x]+mod-c)%mod,x+=x&(-x);
    return ;
}
int listask(int u){
    int res=0;
    int x=R[u];
    while(x>0) res=(res+tr[x])%mod,x-=x&(-x);
    x=L[u]-1;
    while(x>0) res=(res+mod-tr[x])%mod,x-=x&(-x);
    return res;
}
int tree[maxn];
void seqadd(int l,int r,int c){
    int x=l;
    while(x<=n) tree[x]=(tree[x]+c)%mod,x+=x&(-x);
    x=r+1;
    while(x<=n) tree[x]=(tree[x]+mod-c)%mod,x+=x&(-x);
}
int seqask(int x){
    int res=0;
    while(x>0) res=(res+tree[x])%mod,x-=x&(-x);
    return res;
}
void dfs(int u){
    L[u]=++dfncnt;
    kfa.push_back(u);
    vector<int> pop,cnt;
    while(st.size()>0&&lim[st.back()]>lim[u]) pop.push_back(st.back()),cnt.push_back(seqask(st.size()-1)),seqadd(st.size()-1,st.size()-1,(mod-seqask(st.size()-1))%mod),st.pop_back();
    st.push_back(u);
    //r_u < val(u,v)
    //最浅的满足 val(u,v) > r_u 的点
    if(u!=1){
        if(lim[st.back()]>r[u]){
            int lt=1,rt=st.size()-1;
            while(lt+1<rt){
                int mid=(lt+rt)>>1;
                if(lim[st[mid]]>r[u]) rt=mid;
                else lt=mid;
            }
            int tp=to(dep[st[rt-1]]+1);
            //tp \to u 的链
            add[to(l[u]-1)].push_back(make_pair(mod-1,make_pair(tp,u)));
            add[to(r[u])].push_back(make_pair(1,make_pair(tp,u)));
        }
        //l_u <= val(u,v) <= r_u
        if(lim[st.back()]>=l[u]){
            int lt=1,rt=st.size()-1;
            while(lt+1<rt){
                int mid=(lt+rt)>>1;
                if(lim[st[mid]]>=l[u]) rt=mid;
                else lt=mid;
            }
            int Lt=rt;
            int tp=to(dep[st[rt-1]]+1);
            lt=1,rt=st.size();
            while(lt+1<rt){
                int mid=(lt+rt)>>1;
                if(lim[st[mid]]<=r[u]) lt=mid;
                else rt=mid;
            }
            int bk=st[lt];
            int Rt=lt;
            if(dep[bk]>=dep[tp]){
                //tp \to bk 的链
                add[to(l[u]-1)].push_back(make_pair(mod-1,make_pair(tp,bk)));
                //栈中第 [Lt,Rt] 段加
                seqadd(Lt,Rt,1);
            }
        }
    }
    for(int v:E[u]) dfs(v);
    if(u!=1){
        int k=seqask(st.size()-1);
        int tp=to(dep[st[st.size()-2]]+1);
        add[lim[u]].push_back(make_pair(k,make_pair(tp,u)));
    }
    seqadd(st.size()-1,st.size()-1,(mod-seqask(st.size()-1))%mod);
    st.pop_back();
    while(pop.size()>0) st.push_back(pop.back()),seqadd(st.size()-1,st.size()-1,cnt.back()),pop.pop_back(),cnt.pop_back();
    kfa.pop_back();
    R[u]=dfncnt;
}
void DP(int u){
    st.push_back(u);
    dp[u]=(dp[u]+listask(u))%mod;
    pre[u]=(pre[fa[u]]+dp[u])%mod;
    for(pair<int,pair<int,int> > now:add[u]){
        listadd(now.second.first,now.second.second,now.first*pre[u]%mod);
    }
    for(int v:E[u]) DP(v);
}
void work(){
    cin>>n;
    kfa.clear(),st.clear();
    dfncnt=0;
    for(int i=0;i<=n;i++) add[i].clear(),E[i].clear(),g[i]=dp[i]=pre[i]=tr[i]=tree[i]=0;
    dep[1]=1;
    dp[1]=1;
    for(int i=2;i<=n;i++){
        cin>>fa[i]>>r[i]>>l[i]>>h[i];
        dep[i]=dep[fa[i]]+1;
        l[i]=dep[i]-l[i];
        r[i]=dep[i]-r[i];
        lim[i]=dep[i]-h[i]-1;
        E[fa[i]].push_back(i);
    }
    kfa.push_back(0);
    st.push_back(0);
    dfs(1);
    DP(1);
    kfa.clear();
    st.clear();
    for(int i=2;i<=n;i++) cout<<dp[i]<<' ';
    cout<<'\n';
    return ;
}
signed main(){
    //freopen("mountain.in","r",stdin);
    //freopen("mountain.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int c,t;
    cin>>c>>t;
    while(t--) work();
    return 0;
}
/*
0
1
5
1 1 1 0
2 1 1 0
2 1 2 1
4 2 3 0
*/

Details

Tip: Click on the bar to expand more detailed information

Pretests

Pretest #1:

score: 0
Wrong Answer
time: 3ms
memory: 15848kb

input:

1
4
6
1 1 1 0
1 1 1 0
3 1 2 1
3 2 2 0
4 2 3 1
6
1 1 1 0
2 1 2 0
2 1 2 0
1 1 1 0
4 1 2 2
6
1 1 1 0
1 1 1 0
3 1 2 1
4 2 2 0
3 1 1 0
6
1 1 1 0
1 1 1 0
3 1 1 0
4 2 3 1
2 1 2 0

output:

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

result:

wrong answer 5th numbers differ - expected: '5', found: '2'

Pretest #2:

score: 0
Wrong Answer
time: 0ms
memory: 15980kb

input:

2
4
300
1 1 1 0
2 1 2 1
3 1 3 1
1 1 1 0
3 1 3 0
4 2 2 3
7 1 2 0
8 2 2 2
7 1 3 4
7 3 4 4
11 1 6 1
12 1 3 5
10 2 5 5
13 1 5 4
13 4 7 2
15 8 8 8
16 8 9 4
15 1 9 6
18 4 5 6
19 3 8 8
18 5 10 2
19 3 7 5
23 5 7 6
22 6 8 10
23 4 7 3
24 1 4 6
24 8 12 9
28 7 11 8
26 1 9 7
28 1 3 1
29 2 5 0
32 1 6 4
30 5 12 7
...

output:

19 18 35 1 38 15 998244315 0 0 15 261 261 0 525 107 0 20 490 0 0 103 192 305 0 998244328 0 378 185 998244351 998243077 2175 780 36 1827 30 1759 37 265 1130 2873 19 0 211 0 19 1047 1489 1509 998243792 8681 6589 48 2005 12377 0 10840 998243863 101 59 998243875 2022 2022 1861 1130 980 998244324 0 9679 ...

result:

wrong answer 7th numbers differ - expected: '50', found: '998244315'

Pretest #3:

score: 0
Wrong Answer
time: 0ms
memory: 15968kb

input:

3
4
300
1 1 1 0
2 1 2 1
3 3 3 0
2 1 2 1
3 1 3 1
3 1 3 0
4 1 4 1
6 4 4 2
9 3 5 1
7 3 4 2
10 2 5 4
12 1 5 2
11 1 3 2
12 3 6 6
13 6 6 3
13 3 8 0
14 3 5 0
16 3 5 5
16 6 9 5
20 2 7 3
20 3 7 9
21 7 9 2
23 3 4 8
21 4 9 6
24 11 12 2
25 3 4 1
27 7 13 5
26 1 8 3
29 2 4 6
29 6 15 14
29 5 5 10
32 6 10 11
30 1 9...

output:

20 18 40 1 233 80 39 212 229 41 190 1038 56 0 1059 713 118 0 1041 1130 0 1190 727 998244332 14 3003 903 998244329 688 1 0 0 688 10984 1742 4555 2961 5869 6175 411 0 0 2626 1041 2079 38 3644 998242412 3208 436 10728 3230 6604 2983 0 998244337 6185 0 1791 998241353 998238129 63 0 123 998237265 0 60 63...

result:

wrong answer 12th numbers differ - expected: '5094', found: '1038'

Pretest #4:

score: 0
Wrong Answer
time: 19ms
memory: 19884kb

input:

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

output:

1 1 28 29 25 2 27 1 1 25 21 0 29 21 0 25 47 140 238 0 0 266 32 998244218 153 998244328 101 20 106 33 229 102 278 0 704 185 1711 805 104 104 998244047 1 1888 1 1469 1 1350 0 998243777 1121 0 6934 2156 4753 82 1130 998243843 94 998244236 998244035 337 998228781 286 998244295 463 0 344 0 0 1514 9982436...

result:

wrong answer 4th numbers differ - expected: '83', found: '29'

Pretest #5:

score: 0
Wrong Answer
time: 15ms
memory: 18020kb

input:

5
4
5000
1 1 1 0
1 1 1 0
1 1 1 0
2 1 2 0
3 1 1 1
4 1 1 0
6 1 3 2
7 1 3 1
8 2 2 0
8 1 3 2
11 3 5 1
10 1 5 4
13 1 2 4
12 3 4 3
15 3 5 2
15 2 6 2
15 1 3 3
16 7 7 3
19 1 7 4
18 2 3 4
20 1 10 5
21 2 3 8
21 4 9 6
22 7 9 3
24 2 6 8
25 1 3 4
25 3 4 1
26 3 4 3
29 5 11 9
28 8 11 12
29 7 9 11
32 5 12 5
32 11 1...

output:

2 35 2 3 34 5 34 3 35 46 243 1 0 173 998244304 5 67 998244334 998244299 67 998244329 0 67 114 31 0 998244280 998243955 35 0 29 103 181 0 111 0 0 75 0 68 793 0 68 65 998244249 998244084 998242688 36 0 998243112 945 998244342 998243293 998243419 998244307 998243960 998243513 173 998242947 775 0 998243...

result:

wrong answer 10th numbers differ - expected: '277', found: '46'

Pretest #6:

score: 5
Accepted
time: 454ms
memory: 63480kb

input:

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

output:

7 90 1343 13340 200010 2186770 17480820 279693113 800242414 420706509 214087588 358274752 946289212 530647994 955227776 663050301 438245147 621009062 780623708 80919478 728275212 743623748 978006196 735181462 256088384 612217572 335562169 696082683 110948988 53450390 637356472 107616671 988788196 54...

result:

ok 399996 numbers

Pretest #7:

score: 0
Wrong Answer
time: 486ms
memory: 64112kb

input:

7
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
3 1 1 0
1 1 1 0
3 1 1 0
7 1 1 0
6 1 1 0
9 2 2 0
6 1 1 0
6 1 1 0
7 2 2 0
9 2 2 0
11 1 1 0
11 2 2 0
14 4 4 0
12 1 1 0
16 3 3 0
15 1 1 0
17 3 3 0
20 5 5 0
18 4 4 0
20 2 2 0
19 2 2 0
22 5 5 0
22 2 2 0
22 3 3 0
23 5 5 0
27 7 7 0
26 6 6 0
27 5 5 0
31 1 1 0
33 9 9 0
34 2 ...

output:

1 1 1 1 31 2 0 4 31 68 3 1 2 275 62 5 998244325 998244286 998244168 4 416 2 275 62 3080 998244237 275 1 1 998242628 68 998213141 998243653 998213141 998213142 998210911 68 3080 1 30051 997716627 998212028 997779598 226 68 275 998211753 275 6615067 68 997473507 32 998211447 16374166 997473576 9977795...

result:

wrong answer 7th numbers differ - expected: '2', found: '0'

Pretest #8:

score: 5
Accepted
time: 441ms
memory: 61124kb

input:

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

output:

12 23 22 21 42 62 61 19 49 7 26 7 77 76 76 156 133 114 258 102 102 41 41 48 48 36 13 6 140 118 41 203 155 155 41 61 61 61 328 279 279 123 111 111 111 225 204 90 109 252 150 109 150 109 47 47 28 28 28 6 120 120 6 18 18 59 59 18 32 32 32 73 73 73 672 631 631 352 311 32 380 483 374 408 275 395 275 234 ...

result:

ok 399996 numbers

Pretest #9:

score: 0
Wrong Answer
time: 438ms
memory: 53036kb

input:

9
4
100000
1 1 1 0
2 2 2 0
2 1 1 1
2 2 2 1
1 1 1 0
6 1 1 1
3 1 1 0
6 1 1 0
7 1 1 2
6 2 2 0
8 3 3 2
9 1 1 1
9 1 1 0
12 5 5 2
14 1 1 3
13 4 4 3
13 1 1 3
14 3 3 3
17 5 5 2
19 1 1 0
18 3 3 3
22 3 3 5
23 1 1 0
21 5 5 3
22 4 4 4
23 7 7 2
24 6 6 3
25 2 2 1
29 6 6 7
29 8 8 3
31 8 8 7
32 6 6 5
31 5 5 7
31 2 ...

output:

4 6 0 1 23 0 11 25 0 1 5 3 5 1 0 2 1 18 1 21 1 1 998244348 69 0 1 25 998244351 0 46 4 998244305 0 998244254 0 0 41 41 0 117 0 21 21 0 998244300 998244256 23 2 998244332 41 23 0 998244346 0 998244332 21 998244309 998244323 998244309 998244254 998244277 21 0 0 40 87 252 18 0 0 0 251 18 998244257 99824...

result:

wrong answer 8th numbers differ - expected: '44', found: '25'

Pretest #10:

score: 5
Accepted
time: 503ms
memory: 62596kb

input:

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

output:

27 1160 73079 5773240 508043960 401903691 408194108 913457210 404309453 850776989 162033550 491800762 693950334 88591672 90581013 261837127 124549390 607776285 954584563 426982262 910735533 125508942 301425049 369545791 349157696 256736908 276834134 449249498 408190411 362993320 980271019 745442146 ...

result:

ok 399996 numbers

Pretest #11:

score: 0
Wrong Answer
time: 512ms
memory: 60488kb

input:

11
4
100000
1 1 1 0
1 1 1 0
2 1 2 0
1 1 1 0
2 1 2 0
6 1 3 0
5 1 2 0
7 2 3 0
6 2 2 0
8 1 3 0
9 2 3 0
9 3 5 0
10 2 4 0
13 2 4 0
12 4 6 0
13 1 6 0
16 1 4 0
18 6 7 0
18 2 4 0
20 1 6 0
21 2 9 0
20 1 3 0
23 1 4 0
22 1 8 0
24 10 10 0
23 3 5 0
24 3 11 0
26 8 11 0
27 1 9 0
30 2 11 0
28 12 12 0
32 4 8 0
32 9 ...

output:

41 1 42 3 3401 998242631 84 998114824 41 2 998049879 3401 3443 998116503 4240195 3443 16507805 3442 877193233 997854042 897615507 158975714 303013872 998240910 998116585 20553483 782199952 998116544 998244310 78903794 633874346 341187800 998114824 897617230 329014208 527276957 779194087 607898604 51...

result:

wrong answer 6th numbers differ - expected: '407995', found: '998242631'

Pretest #12:

score: 0
Wrong Answer
time: 494ms
memory: 62796kb

input:

12
4
100000
1 1 1 0
1 1 1 0
3 1 2 0
3 1 2 0
4 1 1 0
4 1 3 0
6 2 4 0
7 2 4 0
9 1 4 0
8 1 3 0
11 3 3 0
11 5 6 0
12 1 2 0
14 3 3 0
13 2 7 0
16 2 3 0
17 2 4 0
17 7 9 0
17 3 8 0
20 2 6 0
21 10 11 0
21 6 11 0
21 7 9 0
23 3 4 0
24 5 11 0
26 6 9 0
26 5 7 0
27 12 13 0
29 10 10 0
28 1 3 0
31 13 15 0
32 7 13 0...

output:

1 44 119 2 3251 134 15627 327 998244352 998159295 998216350 997985614 998140253 998159295 837233 13495953 493436 164 992442535 628548085 45 7628119 379898284 7694135 421302017 424168 849399725 998159458 998159295 866668988 13472073 251474374 18427625 217304722 18408628 434136702 159615408 18493642 7...

result:

wrong answer 3rd numbers differ - expected: '3430', found: '119'

Pretest #13:

score: 5
Accepted
time: 482ms
memory: 63104kb

input:

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

output:

28 55 26 109 25 246 162 79 24 1161 1052 1188 970 2125 699 480 1822 2880 993 4442 286 21 21 3699 298 9538 1352 622 189 189 1481 1505 15694 21512 834 834 5007 968 968 14494 725 23023 12855 17501 26963 26963 4370 55916 2673 2458 139790 114009 120206 117382 44163 44163 43673 53833 619 71600 8518 22800 2...

result:

ok 399996 numbers

Pretest #14:

score: 0
Wrong Answer
time: 498ms
memory: 55716kb

input:

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

output:

38 0 2 37 1 150 112 39 34 33 109 0 226 32 75 32 998244201 998244277 998244308 0 998244307 292 30 998244352 224 371 998244352 34 1530 404 255 937 514 998244145 296 0 546 546 780 206 494 120 998244185 426 141 998244186 998244186 0 916 0 1722 857 701 4946 998244352 4138 1 939 174 39 24 1745 11913 99824...

result:

wrong answer 7th numbers differ - expected: '149', found: '112'

Pretest #15:

score: 0
Wrong Answer
time: 475ms
memory: 54460kb

input:

15
4
100000
1 1 1 0
1 1 1 0
3 1 1 1
3 2 2 0
4 1 2 0
5 1 1 2
2 1 2 0
3 1 2 0
7 3 3 1
9 3 3 1
8 1 2 1
10 1 5 1
8 2 3 0
9 1 2 1
11 3 3 3
14 1 2 2
15 1 3 1
15 2 4 0
15 1 4 3
17 3 4 2
19 5 5 2
21 4 6 4
21 6 6 2
24 2 4 6
24 3 7 4
22 3 4 0
23 1 5 5
23 5 6 6
26 2 8 3
30 5 9 8
27 4 6 1
27 3 7 2
31 6 8 7
32 5...

output:

8 69 0 2 69 1 63 266 139 1 8 70 46 256 0 37 69 1786 1 10 1450 9 2 0 1 3543 0 0 1 1 2111 910 998244344 1520 337 2 838 998243900 592 998243472 998244087 0 0 998243216 1102 12133 591 1229 998243051 3236 2377 0 998244167 893 0 69 69 69 998242554 998237318 0 998233898 11593 998244268 0 998233563 99824270...

result:

wrong answer 8th numbers differ - expected: '1791', found: '266'

Pretest #16:

score: 0
Wrong Answer
time: 465ms
memory: 57620kb

input:

16
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
4 1 1 1
1 1 1 0
2 1 2 0
7 2 3 2
3 2 2 0
6 2 2 0
8 2 3 0
11 1 5 1
11 2 5 3
11 3 3 4
14 2 6 2
14 2 3 0
12 2 3 0
12 4 5 0
16 3 7 1
19 3 7 2
18 3 4 2
21 2 4 0
22 1 3 0
21 1 6 6
21 4 5 3
21 1 7 4
23 1 10 2
26 1 6 4
23 9 10 0
25 7 8 1
25 3 9 2
27 9 11 3
29 4 11 7
33 2 6...

output:

55 2 1 0 2 109 53 1 1 152 998244283 56 2 0 574 205 998244230 369 998244352 998244066 316 139 0 41 998244187 383 998244188 56 206 165 165 0 998244218 0 42 0 0 53 998244052 43 998244012 0 998243917 0 998244135 42 998244053 0 258 408 299 518 998243929 165 0 39 998244094 998244352 998244188 998244271 99...

result:

wrong answer 10th numbers differ - expected: '2332', found: '152'

Pretest #17:

score: 0
Wrong Answer
time: 481ms
memory: 56644kb

input:

17
4
100000
1 1 1 0
2 2 2 0
1 1 1 0
1 1 1 0
5 1 2 1
5 1 2 1
6 2 2 2
7 1 1 0
8 1 1 3
8 3 4 2
6 1 3 2
9 2 4 1
8 4 4 0
11 1 4 2
10 3 3 1
11 2 5 0
14 2 3 0
17 4 4 2
14 3 4 4
17 1 4 2
19 2 6 6
17 1 1 5
18 1 5 3
23 3 7 2
22 2 3 7
24 4 6 3
23 1 7 4
23 7 7 5
27 5 6 2
26 6 9 5
28 1 7 4
30 1 9 5
29 2 6 6
29 4...

output:

2 1 1 54 51 2 49 998244306 0 53 1 4 998244260 3 51 198 59 52 0 998244300 1 44 998244312 55 1 998244303 7 72 102 2 1 2 2 583 154 0 463 128 998244215 312 154 408 4 57 5 219 2 0 1 220 3 998244304 500 405 998244300 998244147 914 998244302 405 998244302 912 998244160 351 0 561 998242762 0 102 496 0 2252 ...

result:

wrong answer 8th numbers differ - expected: '59', found: '998244306'

Pretest #18:

score: 0
Wrong Answer
time: 487ms
memory: 57320kb

input:

18
4
100000
1 1 1 0
2 1 2 1
2 1 2 0
2 1 2 0
3 3 3 1
5 1 3 1
4 2 3 2
7 1 3 1
8 2 4 0
9 1 4 1
8 2 3 3
12 2 5 3
9 2 3 2
11 1 1 1
11 2 4 1
14 1 6 2
15 7 7 0
17 2 4 4
18 6 7 1
17 2 6 6
17 5 5 1
20 2 5 7
22 1 7 3
23 6 10 7
25 4 4 6
25 8 11 7
26 2 10 3
26 6 7 6
27 12 12 2
28 1 1 0
29 8 11 11
32 3 9 12
30 2...

output:

60 2 64 1193 1 1132 3 1087 125 2211 1 61 129 2023 1193 1442 2023 0 2022 0 2446 769 1253 777 1839 190 3412 998241590 4 998229406 646 646 0 3 0 3879 9669 833 15175 998243224 0 998238096 61 18081 998229216 10375 63 2507 1611 0 358 730 1298 730 0 4234 1193 998242341 998239539 416 9788 0 1254 1145 2386 1...

result:

wrong answer 8th numbers differ - expected: '10615', found: '1087'

Pretest #19:

score: 0
Wrong Answer
time: 474ms
memory: 58080kb

input:

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

output:

38 1 37 873 5 1 998244314 117 678 5 39 3 640 1 998244115 998244231 1 1665 118 1664 712 1 3 675 3 947 637 403 998241737 998240381 37 4607 670 998244352 6396 998243403 998240836 2905 1317 3931 7962 998244352 3931 6161 1641 998243328 948 5601 445 3448 6034 1897 5557 9378 998240421 3968 1666 172 7358 99...

result:

wrong answer 7th numbers differ - expected: '37', found: '998244314'

Pretest #20:

score: 0
Wrong Answer
time: 508ms
memory: 58000kb

input:

20
4
100000
1 1 1 0
2 1 1 0
3 1 3 2
4 4 4 1
5 1 5 0
6 1 6 3
4 2 2 1
3 3 3 2
8 1 1 3
7 2 5 0
10 1 3 4
11 1 7 5
9 1 1 3
14 1 3 1
12 4 6 4
16 1 4 7
15 2 4 4
17 2 7 1
19 6 9 6
18 4 6 2
18 2 7 4
18 2 4 3
22 1 7 0
19 3 9 6
20 4 7 7
26 5 10 9
27 2 7 10
27 3 10 6
29 8 9 10
26 7 8 5
31 3 9 1
31 5 13 5
32 10 ...

output:

52 103 49 571 1190 414 200 2 97 2068 97 155 1 309 200 45 157 2599 2043 157 311 49 404 204 1839 103 0 4034 0 18357 5488 2893 52 1810 2716 155 1678 2803 27993 9816 2665 103 41 1761 53 6869 105 155 41 3776 2227 502 443 244 998239923 362 998206627 998244300 457 1499 0 457 1499 998219470 998219657 998243...

result:

wrong answer 14th numbers differ - expected: '262', found: '309'


Final Tests

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 15856kb

input:

1
4
6
1 1 1 0
2 1 2 0
3 2 3 0
3 2 2 2
5 4 4 3
6
1 1 1 0
1 1 1 0
3 1 1 1
3 1 1 0
4 2 3 1
6
1 1 1 0
2 1 2 1
2 1 2 0
2 2 2 0
2 1 2 0
6
1 1 1 0
2 1 1 1
1 1 1 0
4 1 2 1
5 1 2 2

output:

4 11 5 1 1 
1 2 1 1 2 
5 1 6 1 6 
1 0 2 1 0 

result:

wrong answer 9th numbers differ - expected: '2', found: '1'

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 16012kb

input:

2
4
300
1 1 1 0
2 1 1 0
1 1 1 0
4 1 2 1
2 2 2 0
6 1 2 1
3 1 3 0
4 1 2 1
6 1 1 1
10 2 3 0
6 2 3 2
11 2 4 0
11 4 5 2
14 4 4 5
10 1 3 2
12 3 4 0
12 2 4 1
15 7 7 5
17 3 4 1
16 4 4 0
21 2 2 5
20 2 4 2
20 2 2 1
23 3 5 1
20 3 4 0
22 4 5 0
26 5 7 1
28 1 8 1
27 2 6 6
26 1 5 2
30 1 3 6
28 1 1 4
28 2 7 6
34 2 ...

output:

34 69 3 1 236 34 104 1 173 305 28 443 36 1 69 629 104 1 594 35 1 998244283 998244054 893 964 444 735 305 35 998244318 104 0 193 998244352 1 0 1 388 0 0 998242905 998242311 0 89 998243528 69 270 998242968 0 0 998244082 3413 1892 20 290 0 998244082 1537 575 264 478 998241143 305 2658 2393 271 99824420...

result:

wrong answer 10th numbers differ - expected: '749', found: '305'

Test #3:

score: 0
Wrong Answer
time: 3ms
memory: 16236kb

input:

3
4
300
1 1 1 0
2 1 2 0
3 1 3 0
4 1 3 2
4 1 4 2
3 1 2 0
5 1 5 0
4 1 2 3
4 1 4 3
5 1 2 2
8 5 6 3
10 1 3 2
9 4 5 3
13 4 6 1
10 1 4 3
12 4 5 5
13 1 2 1
13 2 3 4
18 6 7 6
17 6 8 3
19 1 3 3
21 9 9 4
22 2 4 5
21 5 7 4
22 1 5 1
23 3 9 3
24 1 1 6
25 1 2 7
28 1 8 6
30 1 11 2
30 4 9 0
32 2 10 3
30 6 8 8
32 6 ...

output:

25 249 447 129 26 274 929 1 16 0 78 1288 26 275 25 52 130 763 1 1951 3700 851 3253 825 998244078 998244352 3253 0 6382 7211 8518 697 823 1358 2067 6488 585 998244351 6634 998243422 0 274 274 3639 998244207 0 998243356 0 2789 43736 0 27049 17175 6759 0 6759 10 998219772 3916 9481 12594 998244327 1875...

result:

wrong answer 17th numbers differ - expected: '17', found: '130'

Test #4:

score: 0
Wrong Answer
time: 18ms
memory: 17944kb

input:

4
4
5000
1 1 1 0
2 1 2 1
1 1 1 0
4 1 1 0
1 1 1 0
3 2 3 2
6 1 2 1
5 1 2 0
8 3 3 1
10 1 3 2
8 2 2 0
11 1 5 4
11 3 5 3
13 4 5 3
12 3 3 1
16 1 5 1
13 4 5 5
18 1 5 5
17 1 6 5
17 1 5 4
20 5 7 4
19 1 1 7
23 1 8 3
23 4 6 4
23 8 9 7
24 3 4 2
27 3 6 3
28 5 8 9
26 1 4 4
27 3 10 8
28 8 11 9
31 4 6 3
31 10 10 2
...

output:

3 2 1 6 41 1 40 5 42 41 93 34 4 5 52 7 33 33 2 3 6 33 998244119 998244279 4 998244001 998244239 0 0 998244232 998244322 998244167 998243555 39 998244317 108 998243515 40 79 998243022 0 998243813 0 143 998243678 0 998244084 29 998243643 998244318 0 0 998243520 998244318 998244161 998244318 998244098 ...

result:

wrong answer 4th numbers differ - expected: '2', found: '6'

Test #5:

score: 0
Wrong Answer
time: 11ms
memory: 17840kb

input:

5
4
5000
1 1 1 0
2 2 2 1
3 1 2 2
1 1 1 0
3 1 1 0
4 2 2 3
5 1 1 1
8 3 3 1
8 2 3 2
6 4 4 3
10 2 4 2
10 2 4 2
12 4 5 3
11 2 3 4
11 5 5 1
14 1 3 5
16 1 1 2
15 1 3 0
17 1 4 2
18 3 7 3
21 5 8 6
18 6 7 2
22 1 5 5
24 4 7 4
21 5 7 7
24 2 9 0
26 9 9 2
24 5 9 9
29 8 11 2
30 3 7 4
30 8 9 6
31 5 10 6
30 3 5 4
34...

output:

34 33 0 6 65 0 5 1 4 32 70 35 35 0 200 0 199 65 998244348 164 95 35 93 65 1 822 1 26 998244307 430 229 595 998243515 67 595 822 998243988 24 562 132 24 998244151 998244056 0 24 998244152 577 0 198 392 914 133 194 998243789 34 623 259 998243741 998243789 998243741 941 0 998244078 227 998243789 0 391 ...

result:

wrong answer 11th numbers differ - expected: '14', found: '70'

Test #6:

score: 5
Accepted
time: 471ms
memory: 63360kb

input:

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

output:

13 116 1159 11577 150385 1654119 16540031 198480359 787928493 734581969 103223677 120676063 963754385 618704320 378636756 206516872 241703175 693677871 68103114 817225791 671888130 60162705 601476665 456558188 30918290 836035627 422508580 961059777 721412290 780076554 866081801 542037914 961741065 6...

result:

ok 399996 numbers

Test #7:

score: 0
Wrong Answer
time: 492ms
memory: 62808kb

input:

7
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
1 1 1 0
5 2 2 0
5 2 2 0
7 1 1 0
8 1 1 0
6 1 1 0
7 3 3 0
9 3 3 0
12 2 2 0
10 2 2 0
13 1 1 0
13 4 4 0
13 7 7 0
15 1 1 0
15 7 7 0
16 7 7 0
19 1 1 0
18 8 8 0
19 2 2 0
23 1 1 0
23 5 5 0
24 8 8 0
23 6 6 0
27 3 3 0
28 4 4 0
26 12 12 0
29 6 6 0
30 1 1 0
31 12 12 0
30 9 9 0...

output:

1 1 1 21 1 36 998244267 214 998244313 1 940 1579 1 3162 998244288 1 998241641 998227969 21 998238672 21 51222 10629 940 129 128352 128495 997069430 215 3604804 998195595 36 214 5320943 976309508 112111 988542670 128352 998227969 954931639 13886469 913720150 992332233 48895719 128495 940 60845632 489...

result:

wrong answer 6th numbers differ - expected: '376', found: '36'

Test #8:

score: 5
Accepted
time: 447ms
memory: 61368kb

input:

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

output:

7 13 12 5 18 5 4 25 24 29 33 29 24 24 73 48 24 50 50 37 89 89 60 125 36 23 23 68 39 39 35 23 23 52 52 45 38 14 9 9 9 9 9 9 9 42 9 67 44 9 2 11 2 2 106 106 106 106 174 167 99 92 126 97 145 165 158 90 239 189 180 143 143 114 90 90 279 90 203 322 313 261 237 223 134 90 90 233 90 90 90 90 163 154 131 94...

result:

ok 399996 numbers

Test #9:

score: 0
Wrong Answer
time: 485ms
memory: 54824kb

input:

9
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
3 1 1 0
4 2 2 1
6 2 2 2
6 1 1 2
8 3 3 2
9 1 1 4
8 4 4 0
9 4 4 0
12 6 6 3
13 3 3 4
13 6 6 3
15 5 5 0
15 2 2 7
15 4 4 2
17 5 5 2
18 5 5 0
18 4 4 6
19 2 2 8
22 8 8 9
23 3 3 10
24 6 6 12
25 7 7 13
24 1 1 11
27 3 3 7
27 12 12 2
28 4 4 0
30 3 3 9
31 15 15 15
32 1 1 7
31 ...

output:

1 1 15 1 14 0 13 15 0 1 42 27 0 12 13 11 30 27 15 0 12 12 12 0 0 12 12 14 24 12 12 26 0 11 15 0 11 26 11 11 998244280 12 11 11 0 65 0 0 38 38 0 0 38 119 0 12 119 95 0 24 143 0 0 154 115 104 12 104 24 0 68 12 68 68 53 0 15 22 27 11 11 27 41 11 30 0 149 0 998242590 12 0 18 17 22 0 132 17 44 95 44 32 8...

result:

wrong answer 8th numbers differ - expected: '57', found: '15'

Test #10:

score: 5
Accepted
time: 490ms
memory: 62696kb

input:

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

output:

16 527 25807 1883910 167667973 634982620 705207129 488881034 887725160 151025554 347960978 855383206 80305903 380559379 538908054 777587576 260990688 523673420 353610155 624705377 700258326 228676702 200177699 984634103 68249951 263072670 517709689 650106087 34684922 592160972 944601706 376074738 79...

result:

ok 399996 numbers

Test #11:

score: 0
Wrong Answer
time: 523ms
memory: 62612kb

input:

11
4
100000
1 1 1 0
2 1 2 0
3 1 2 0
3 1 2 0
5 3 4 0
5 1 3 0
5 2 3 0
8 1 3 0
9 2 5 0
10 3 5 0
11 4 6 0
10 1 3 0
11 6 8 0
13 4 8 0
13 2 7 0
14 1 3 0
17 3 8 0
17 5 7 0
19 10 11 0
19 1 2 0
20 5 12 0
22 12 12 0
22 8 10 0
23 6 14 0
23 2 8 0
25 2 9 0
27 6 9 0
26 9 15 0
29 3 10 0
30 9 9 0
30 12 13 0
32 14 1...

output:

37 2478 2515 242769 38 5030 567166 32037925 19321752 71167675 812413 1067795 280399250 812451 52172127 479471594 123339765 486225155 309171659 717845103 152650514 84236109 32847860 95402698 669927292 205174323 319019321 851158804 460402551 36318298 620801658 267588638 754163401 393968766 510806048 6...

result:

wrong answer 6th numbers differ - expected: '245284', found: '5030'

Test #12:

score: 0
Wrong Answer
time: 540ms
memory: 64148kb

input:

12
4
100000
1 1 1 0
2 1 2 0
3 2 3 0
4 1 3 0
2 1 1 0
4 2 2 0
3 1 2 0
8 1 4 0
8 1 3 0
5 2 5 0
9 1 4 0
10 3 5 0
11 1 6 0
11 3 6 0
11 3 3 0
14 2 6 0
17 3 7 0
14 2 4 0
14 4 6 0
18 2 8 0
18 6 9 0
21 8 10 0
22 5 5 0
20 6 8 0
22 1 4 0
24 3 9 0
26 3 8 0
25 3 3 0
24 6 7 0
25 5 9 0
27 2 9 0
32 4 6 0
32 9 11 0
...

output:

69 7796 1278127 262008169 69 7796 39327 2571985 1293858 777304836 263294161 7866 964736467 1285993 1278127 758768042 282922207 42346779 23457 767622666 330090311 7866 694290575 7584224 9930144 491001530 52284789 964736467 41068652 41084244 645827165 373536207 805074670 751404631 7866 57530818 984801...

result:

wrong answer 8th numbers differ - expected: '94385', found: '2571985'

Test #13:

score: 5
Accepted
time: 498ms
memory: 63156kb

input:

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

output:

25 24 23 48 23 122 194 169 239 285 214 96 47 47 192 1948 2182 1132 385 216 455 47 1507 94 94 4391 21 779 13861 5938 14206 13992 4449 22496 12875 3304 3304 13811 13690 9811 3933 619 619 5401 13977 106342 3918 13555 35871 2821 276664 275227 172324 207717 203165 270061 269845 1838 68391 19507 19507 134...

result:

ok 399996 numbers

Test #14:

score: 0
Wrong Answer
time: 480ms
memory: 56144kb

input:

14
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
4 1 2 1
1 1 1 0
5 1 1 2
6 1 1 0
6 2 2 1
5 2 3 2
5 1 2 1
7 2 2 1
8 1 2 1
11 2 4 1
11 4 4 2
15 2 4 0
13 1 3 3
15 1 3 3
18 2 4 4
16 2 5 5
16 4 4 0
18 6 6 4
22 4 4 5
18 2 5 5
20 5 6 5
24 1 6 4
25 5 6 2
22 3 4 1
28 3 7 0
25 2 4 4
29 1 6 4
27 3 8 0
28 5 5 7
30 2 3 1
33 ...

output:

1 1 68 67 2 0 2 1 1 69 998244286 1 2 66 271 0 64 0 0 67 64 0 0 2 1 68 196 334 0 0 998244285 62 998243811 998244271 0 998244143 998243744 61 0 656 1 998244286 459 61 0 271 206 0 194 0 136 998243508 593 204 170 998244154 0 998244154 135 302 0 526 95 998244018 0 68 0 998244148 465 707 501 998244223 0 1...

result:

wrong answer 7th numbers differ - expected: '4', found: '2'

Test #15:

score: 0
Wrong Answer
time: 516ms
memory: 58520kb

input:

15
4
100000
1 1 1 0
1 1 1 0
2 1 2 0
1 1 1 0
4 1 3 1
3 2 2 1
5 1 2 0
5 2 2 1
7 2 3 1
9 1 2 0
9 2 3 0
8 1 2 1
9 1 2 0
10 3 3 2
11 2 3 1
13 2 3 3
15 3 5 4
14 4 4 2
16 2 4 0
20 4 5 5
18 1 6 4
21 2 5 6
19 4 5 4
23 3 7 4
23 3 5 0
25 3 3 8
26 4 8 8
26 3 7 6
28 6 9 5
26 6 9 2
29 8 9 7
29 6 10 1
31 4 4 5
34 ...

output:

3 5 8 46 4 4 7 44 9 55 47 3 7 5 50 0 2 2 185 40 4 40 1 11 429 0 0 998244282 46 210 5 155 99 248 998244318 0 998244312 52 52 0 772 998243857 998242542 998243989 998244227 998244227 998244251 1333 1311 904 40 890 120 36 998244023 998244338 998244285 4 789 508 998243496 1931 493 0 146 0 372 954 65 65 9...

result:

wrong answer 7th numbers differ - expected: '93', found: '7'

Test #16:

score: 0
Wrong Answer
time: 496ms
memory: 57704kb

input:

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

output:

1 1 2 60 3 60 1 2 0 3 118 5 2 60 2 55 998244350 3 998244295 5 52 56 998244000 1 998244294 53 3 998244343 998244297 1039 3 127 0 60 634 472 64 74 67 48 354 998243721 0 0 31 147 998243649 998244056 0 998243763 998244304 998244161 91 998243147 998244302 0 352 998243885 998243956 998243203 200 998244018...

result:

wrong answer 6th numbers differ - expected: '355', found: '60'

Test #17:

score: 0
Wrong Answer
time: 522ms
memory: 56712kb

input:

17
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
2 1 1 0
2 1 2 1
4 1 1 0
3 1 2 1
7 2 3 0
8 3 3 0
6 1 3 0
9 2 3 0
8 1 3 1
9 3 4 2
11 3 4 3
13 2 3 0
12 4 5 4
16 1 2 1
15 1 2 2
19 2 5 5
16 3 5 4
19 1 4 5
21 3 4 5
23 3 5 0
21 1 6 1
23 3 3 2
25 1 2 2
26 1 3 0
26 5 6 6
27 2 4 3
28 1 5 8
31 2 3 5
29 3 7 1
32 7 10 10
32...

output:

4 54 4 4 3 19 53 65 1 1 24 59 5 1 49 1 998244245 0 0 50 0 48 161 998244204 998244243 998244195 998244293 0 998244195 48 118 259 1 62 212 55 157 998244316 0 998244345 44 102 144 274 998244298 197 998244136 4 0 180 153 89 998244352 248 161 998244287 998244341 111 998244298 54 998244248 44 998244298 99...

result:

wrong answer 8th numbers differ - expected: '34', found: '65'

Test #18:

score: 0
Wrong Answer
time: 495ms
memory: 56960kb

input:

18
4
100000
1 1 1 0
1 1 1 0
3 1 2 1
2 1 2 0
2 2 2 0
5 1 3 1
6 1 1 1
6 2 3 2
6 1 3 2
9 1 4 1
10 2 3 1
12 1 3 0
10 1 4 2
11 2 5 0
12 4 5 1
14 2 4 1
15 5 6 2
16 4 5 5
18 3 3 5
18 1 6 4
18 3 4 4
21 2 4 3
21 4 7 4
23 7 9 3
23 1 5 3
25 3 5 3
26 5 6 2
25 1 7 4
29 3 4 6
30 4 11 2
29 1 3 3
29 1 5 6
32 9 12 0...

output:

47 2 1 96 44 48 0 40 3 1483 998244352 96 95 1615 48 998244352 1483 0 0 1435 0 2901 998244352 1186 998244273 998242930 3098 2617 143 9048 2427 47 1786 11121 47 1654 2073 84 1523 1878 998242778 0 998242870 6295 144 94 144 1 998242870 998242700 11628 4534 1441 1 998242921 1394 0 24785 0 7970 144 26439 ...

result:

wrong answer 10th numbers differ - expected: '2679', found: '1483'

Test #19:

score: 0
Wrong Answer
time: 499ms
memory: 55900kb

input:

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

output:

3 1 43 1 1 0 75 2 1 1 67 1 998244311 998244321 105 998244243 105 61 998244323 60 998243979 998244312 998244312 998243781 998243469 77 105 998243566 193 188 998244078 998244205 44 2 377 221 118 429 119 998244282 33 291 1 998244162 998242858 67 43 0 998243923 998243959 43 998244071 61 998243956 998244...

result:

wrong answer 7th numbers differ - expected: '515', found: '75'

Test #20:

score: 0
Wrong Answer
time: 502ms
memory: 57252kb

input:

20
4
100000
1 1 1 0
1 1 1 0
1 1 1 0
3 1 2 1
5 1 1 0
4 1 2 1
5 1 1 2
8 4 4 0
8 1 2 3
10 3 4 0
11 5 5 3
10 3 4 2
11 2 3 3
12 1 7 6
14 1 2 1
15 5 8 3
15 1 2 6
17 5 8 4
17 3 4 0
18 7 9 6
20 1 10 2
21 1 4 9
22 1 9 9
23 3 8 6
25 3 7 8
24 2 7 6
27 1 9 8
27 12 12 8
29 3 11 3
30 2 6 4
31 6 14 8
30 6 8 3
33 8...

output:

1 44 2 43 0 1 42 1 41 172 85 44 0 41 998244270 349 2 87 431 45 174 0 44 0 0 263 998244311 388 1037 998243963 85 1172 349 2 46 982 998243915 853 998243440 817 206 0 998244220 0 0 39 0 39 998243364 953 998244049 0 998242969 998244182 39 998244265 998244251 0 998244255 998238775 10769 0 998243104 4494 ...

result:

wrong answer 5th numbers differ - expected: '43', found: '0'