QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#393590#6837. AC AutomatonmarherAC ✓6636ms200916kbC++177.5kb2024-04-18 21:03:572024-04-18 21:03:57

Judging History

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

  • [2024-04-18 21:03:57]
  • 评测
  • 测评结果:AC
  • 用时:6636ms
  • 内存:200916kb
  • [2024-04-18 21:03:57]
  • 提交

answer

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=7e5+50;

namespace IO {
#define iL (1 << 20)
char ibuf[iL], *iS = ibuf + iL, *iT = ibuf + iL;
#define gc() ((iS == iT) ? (iT = (iS = ibuf) + fread(ibuf, 1, iL, stdin), iS == iT ? EOF : *iS ++) : *iS ++)
template<class T> inline void read(T &x) {
  x = 0;int f = 0;char ch = gc();
  for (; !isdigit(ch); f |= ch == '-', ch = gc());
  for (; isdigit(ch); x = (x << 1) + (x << 3) + (ch ^ 48), ch = gc());
  x = (f == 1 ? ~ x + 1 : x);
}
template<class T, class... Args> inline void read(T &x, Args&... args) { read(x), read(args...); }
template<class T> inline void readch(T &x) { char ch = gc(); for (; ch!='A'&&ch!='C'&&ch!='?'; ch = gc()); x = ch; }
char Out[iL], *iter = Out;
#define flush() fwrite(Out, 1, iter - Out, stdout), iter = Out
template<class T> inline void write(T x, char ch = '\n') {
  T l, c[35];
  if (x < 0) *iter ++ = '-', x = ~ x + 1;
  for (l = 0; !l || x; c[l] = x % 10, l++, x /= 10);
  for (; l; -- l, *iter ++ = c[l] + '0');*iter ++ = ch;
  flush();
}
template<class T, class... Args> inline void write(T x, Args... args) { write(x, ' '), write(args...); }
} // IO
using namespace IO;

int n,q,f[N],g[N],B,fa[N],ff[N],top[N],siz[N],son[N],dep[N],p[N],t[N],dfn[N],now[N],in[N];
vector<int>to[N],vt,tson[N];
char s[N],c[N];

int LCA(int u,int v)
{
    while(top[u]!=top[v])
    {
        if(dep[top[u]]<dep[top[v]])swap(u,v);
        u=fa[top[u]];
    }
    return dep[u]<dep[v]?u:v;
}

int st[N];

void ADD(int x,int y)
{
    to[x].push_back(y);ff[y]=x;in[x]=in[y]=1;
}

void add(int&top)
{
	ADD(st[top-1],st[top]);
	top--;
}

void rebuild(int k)
{
	int top=0;st[++top]=1;in[1]=t[0]=1;
	for(int i=1;i<=k;i++)if(t[i]!=t[i-1])
	{
		int lca=LCA(t[i],st[top]);
		while(dep[lca]<=dep[st[top-1]])add(top);
		if(lca!=st[top])ADD(lca,st[top]),st[top]=lca;
		if(t[i]!=lca)st[++top]=t[i];
	}
	while(top>1)add(top);
}

int cmp(int a,int b)
{
    return dfn[a]<dfn[b];
}

struct node
{
    int x,num;ll sum;
};

int tim,tt,dd;

struct block
{
    vector<int>p;
    node *a;
    int num,n;ll sum;// F
    int pos,ad;//G

    void clear()
    {
        vector<int>().swap(p);free(a);
        num=n=sum=pos=ad=0;
    }

    void init()
    {
        sort(p.begin(),p.end());
        a=new node[p.size()+4];
        a[0]=(node){-1000000000,0,0};
        for(auto x:p)
        {
            if(x!=a[n].x)a[++n]=(node){x,1,x};
            else a[n].num++,a[n].sum+=x;
        }
        a[++n]=(node){1000000000,0,0};
        for(int i=n-1;i>=0;i--)a[i].sum+=a[i+1].sum,a[i].num+=a[i+1].num;
        for(int i=1;i<=n;i++)if(a[i].x>0)
        {
            pos=i;
            break;
        }
    }

    void fad(int x)
    {
        sum+=x*num;
    }

    void gad(int x)
    {
        ad-=x;
        if(x>0&&a[pos-1].x>ad)pos--;
        if(x<0&&a[pos].x<=ad)pos++;
    }

    ll sol()
    {
        return sum+a[pos].sum-ad*a[pos].num;
    }

    void insert(char c,int x)
    {
        if(c=='?'&&g[x]+dd>0)p.push_back(g[x]);
        if(c=='A')sum+=f[x],num++;
    }
}d1[N],d2[N];

void clear(int x)
{
    in[x]=ff[x]=0;
    d1[x].clear();
    d2[x].clear();
    for(auto v:to[x])clear(v);
    vector<int>().swap(to[x]);
}

void GAD(int x,int w)
{
    d1[x].gad(w);d2[x].gad(w);g[x]+=w;
    for(auto v:to[x])GAD(v,w);
}

void rmk(int x,char s,char c)
{
    if(s==c)return;
    int rx=x;
    if(s=='A'||c=='A')
    {
        int w=(s=='A')?1:-1;
        d1[x].fad(w),d1[x].gad(w),x=ff[x];
        while(x)d1[x].fad(w),d1[x].gad(w),f[x]+=w,g[x]+=w,x=ff[x];
    }
    if(s=='C'||c=='C')
    {
        int w=(s=='C')?1:-1;
        d2[x=rx].gad(-w);
        for(auto v:to[x])GAD(v,-w);
    }
}

void sol()
{
    ll ans=0;
    for(auto x:vt)ans+=(s[x]=='A')*f[x]+(s[x]=='?')*max(0,g[x])+d1[x].sol()+d2[x].sol();
    write(ans);
}

char rs[N];

void chk(int x,char c)
{
    char s=rs[x];
    if(s==c)return;
    int ff=0;
    if(s=='A'||c=='A')ff|=(s=='A');
    if(s=='C'||c=='C')ff|=(c=='C');
    dd+=ff;rs[x]=c;
}

int up[N],dn[N];

void solve(int q)
{
    int bg=clock();
    vector<int>().swap(vt);
    for(int i=1;i<=n;i++)f[i]=g[i]=up[i]=dn[i]=0;
    for(int i=n;i>=1;i--)f[fa[i]]+=f[i]+(s[i]!='A');
    for(int i=2;i<=n;i++)g[i]=g[fa[i]]-(s[fa[i]]!='C');
    for(int i=1;i<=n;i++)g[i]+=f[i];
    for(int i=1;i<=q;i++)read(p[i]),readch(c[i]),t[i]=p[i],rs[p[i]]=s[i];
    dd=0;
    for(int i=1;i<=q;i++)chk(p[i],c[i]);
    sort(t+1,t+1+q,cmp);rebuild(q);
    for(int i=1;i<=n;i++)up[i]=in[i]?i:up[fa[i]];
    for(int i=n;i>=1;i--)dn[i]=in[i]?i:dn[i],dn[fa[i]]+=dn[i];
    for(int i=1;i<=n;i++)if(s[i]!='C'&&!in[i])
    {
        if(dn[i])d1[dn[i]].insert(s[i],i);
        else d2[up[i]].insert(s[i],i);
    }
    tim+=clock()-bg;bg=clock();
    for(int i=1;i<=n;i++)if(in[i])vt.push_back(i),d1[i].init(),d2[i].init();
    for(int i=1;i<=q;i++)rmk(p[i],s[p[i]],c[i]),s[p[i]]=c[i],sol();
    tt+=clock()-bg;
    clear(1);
}

int cc;
void dfs2(int x,int topp)
{
    top[x]=topp;dfn[x]=++cc;
    if(!son[x])return;dfs2(son[x],topp);
    for(auto v:tson[x])if(v!=son[x])dfs2(v,v);
}

char ss[5]={'A','?','C'};

main()
{
    read(n,q);
    for(int i=1;i<=n;i++)readch(s[i]);
    B=1000;dep[1]=1;
    for(int i=2;i<=n;i++)read(fa[i]),dep[i]=dep[fa[i]]+1,tson[fa[i]].push_back(i);
    for(int i=n;i>=1;i--)siz[i]++,siz[fa[i]]+=siz[i];
    siz[0]=0;
    for(int i=2;i<=n;i++)if(siz[i]>siz[son[fa[i]]])son[fa[i]]=i;
    dfs2(1,1);
    while(q>0)solve(min(q,B)),q-=B;
    // cout<<1.0*tim/CLOCKS_PER_SEC<<' '<<1.0*tt/CLOCKS_PER_SEC;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 16ms
memory: 138924kb

input:

5 3
AC??C
1 2 2 1
1 ?
4 A
2 ?

output:

4
3
3

result:

ok 3 lines

Test #2:

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

input:

1000 1000
AC?ACCCCC?CCA??CCCCC?A?AC?C??C?ACCCACC?C?CCC?CACACA???????C?????CC?C?AAAAACCA??AAAACACACA???AACAC?CCC?CAC?AAAACCAC???ACAA??A??A?CA?A?ACACACCAA?ACACA?AC??AC??ACAAACCC??CAA?A???CC?AA??AC???A?CCCC??CACCAACC?AA?C?AAACCCA?AAA??C?CC??CACCACAACCA?AACCC?A?CCC?CC???AA?CACCCAAC??CAA??C?AA??CA???CAAA...

output:

2344
2345
2342
2342
2768
2768
2772
2772
2772
2772
2772
2772
2772
2767
2767
2767
2767
2764
2766
2766
2769
2765
2761
2764
2767
2772
2772
2772
2772
2772
2772
2777
2777
2777
2777
2774
2771
2774
2782
2778
2778
2772
2768
2772
2772
2772
2772
2772
2774
2774
2778
2781
2781
2779
2782
2784
2787
2782
2786
2788
...

result:

ok 1000 lines

Test #3:

score: 0
Accepted
time: 5320ms
memory: 196456kb

input:

300000 300000
AAA?CA?AA?AC?A?CCA?AACCAAA???CA?ACCAACCCCAACAAA?CCAAAC?A?C??CC?C?C?CCCA?CAA?ACA??C?C?AC??CA??ACA?AA???CACAAA?CACCCCCCC?A?AAAAAC?AACCA????CCC?C?AAACCCAA?C???CCCC?AAACAAA???A?CAAC??A??A??CCCC??AA?C??ACA?AACAAA????CAA???AAAAACC?C?CCA?CCAA?AAC?CC?CA?A??CC??CCAC??C??????AAC?AA?AA?AAC?C??AAC...

output:

14995917235
14995917235
14996064601
14996083631
14995980103
14995925797
14995925797
14995925797
14995967213
14995967213
14995967213
14995876211
14995774037
14995774037
14995774037
14995876791
14995866113
14995756158
14995647554
14995647554
14995560537
14995560537
14995583619
14995583619
14995583619
...

result:

ok 300000 lines

Test #4:

score: 0
Accepted
time: 3325ms
memory: 154036kb

input:

300000 300000
?ACA???CCCA?C???AA??CAAAAACCC??A?CAC??C???????CAA?C?C?A?C???A?CC?CCAC?C?ACC??C?CAACA??CA?CA?CAACA??AACCC?CCCACACC?AAC?CA??C?C?CCCA?ACAA??AA?CCAACACCA?AC?C?CCCCCCAAA?CC??A?CCC???A?CA?ACAC???C??CCA??CCAA?AAC???CCCC??AA?C?C?C?CACAC?C?CA??AACC?A????C??CACAAAAA?C?CAACACA?ACCAC?A?CCCACACA??A...

output:

200180
200181
200182
200182
200182
200182
200182
200182
200183
200183
200183
200182
200183
200183
200183
200183
200183
200182
200183
200183
200183
200183
200183
200183
200183
200183
200184
200183
200182
200181
200180
200180
200180
200181
200181
200182
200181
200180
200180
200181
200182
200181
200182...

result:

ok 300000 lines

Test #5:

score: 0
Accepted
time: 6124ms
memory: 196320kb

input:

300000 300000
A??CCAAACAC?A?CCACA?CA??ACC?CCA?CCAACACAC?A?CCC??ACC?ACC?CA?CA?C??A?CACCCC?C?AC?AAC??A???CA?C???AC?A?A?ACCCAACC?AA?CCACCCAAAA????C?ACC?????ACACA?C?A?CCC?A?AC????AC?C?A???ACA??CAACACC????CAA???ACCAC???CCCA?A?CAA?C??CCCCA?ACCA?A?CCC?ACA?C??AA?C??ACA?AAACC?CCAACCCAC?CAAA??ACC?ACCAA??????A...

output:

15015050020
15015050020
15015135045
15015202340
15015303448
15015303448
15015282042
15015282042
15015310379
15015329461
15015377957
15015514924
15015514924
15015613521
15015724614
15015640441
15015598420
15015635210
15015635210
15015544590
15015671373
15015653717
15015706346
15015805421
15015835446
...

result:

ok 300000 lines

Test #6:

score: 0
Accepted
time: 1016ms
memory: 171328kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
...

result:

ok 300000 lines

Test #7:

score: 0
Accepted
time: 3072ms
memory: 164672kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891340
2619172
2891...

result:

ok 300000 lines

Test #8:

score: 0
Accepted
time: 3019ms
memory: 157772kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

2972868
3149825
2972868
2700372
2875914
2700372
2972868
2700372
2875914
3149825
2875914
3149825
2972868
2700372
2972868
2700372
2972868
2700372
2875914
2700372
2972868
2700372
2875914
3149825
2972868
3149825
2972868
3149825
2972868
3149825
2875914
2700372
2875914
3149825
2972868
3149825
2972868
2700...

result:

ok 300000 lines

Test #9:

score: 0
Accepted
time: 2970ms
memory: 163168kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

2733980
2504686
2733980
2504686
2733980
3006821
2775490
2504686
2733980
3006821
2733980
2504686
2775490
2504686
2733980
2504686
2733980
2504686
2775490
2504686
2775490
2504686
2775490
3006821
2733980
2504686
2775490
2504686
2775490
2504686
2733980
3006821
2775490
3006821
2775490
3006821
2775490
3006...

result:

ok 300000 lines

Test #10:

score: 0
Accepted
time: 2048ms
memory: 162960kb

input:

300000 300000
?C??C?C??C??C??CC???C???CCC?CCCCCC??C???C?CCCC????C??C????C???C???C????C?CC??CC?C???CC?C??C?C?CCC??C?CCCCC?C??C??C?CC?C?CC?CC?CCC??C?C???C??CC??CC???CC?C??CCC??C??C???C???C??C?C????CCCCCC????CC?CC?CCC?CCC?CCC?C???CC????CCC?CC??C?CC?C?C?C???CCC?CCCCC??C??C???CC??C??CCCCC?C??C?CCC???C???...

output:

2075827
1795155
1531311
1795155
2075827
1809426
2075827
1809426
1531311
1795155
1531311
1795155
1531311
1795155
1531311
1795155
2075827
1809426
2075827
1809426
2075827
1795155
1531311
1795155
2075827
1795155
2075827
1795155
2075827
1795155
2075827
1809426
2075827
1809426
2075827
1795155
2075827
1795...

result:

ok 300000 lines

Test #11:

score: 0
Accepted
time: 2068ms
memory: 156820kb

input:

300000 300000
?C??C???C?CC?C????CCCCC?C?CC?C??CC?CC?CC???C?????C????CC?C???C?CC?CCCCCC????C??CC??C?CC????????C?CC??C?C???CCC?C???CC??C????????C?C?C??C?C??CCC?C???CC???C???CC??CCCC?C????C?CCCCC???CC?CC?CCC?C??C??C??CC?C?C?C?CC??C????CCC?CC???C??CC??C?C?????CC?C??C?????????CC?CCCC??CCCC?CCCC?CC??CCC??...

output:

2157824
1877034
2157824
1896339
1617981
1896339
1617981
1896339
2157824
1896339
1617981
1896339
1617981
1896339
1617981
1896339
1617981
1896339
1617981
1896339
2157824
1896339
2157824
1896339
2157824
1877034
1617981
1877034
2157824
1877034
2157824
1896339
1617981
1896339
1617981
1896339
2157824
1877...

result:

ok 300000 lines

Test #12:

score: 0
Accepted
time: 3006ms
memory: 155640kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

2735497
2557038
2735497
2557038
2735497
2557038
2735497
2557038
2828577
2557038
2735497
3008607
2828577
3008607
2828577
3008607
2735497
3008607
2828577
2557038
2828577
2557038
2828577
2557038
2828577
2557038
2828577
2557038
2735497
3008607
2735497
3008607
2735497
2557038
2735497
3008607
2735497
2557...

result:

ok 300000 lines

Test #13:

score: 0
Accepted
time: 2041ms
memory: 154368kb

input:

300000 300000
??C?CC?CCCCC?CC?????C??C?CCCCC?CCC?C?CC????CC?CCCC?C??C?C??CC?CC??C?C?CC?C?C?C?C?????C?CCCCCCCCCC??CCCC?CC?CC?????CCC?C?CC??C??CC?????CC?C?C?CC?C?C????CCCC?C?????C????C?C???C?C????CC?C?C?C?CCC??C?CCCCCCCC????C?C??C?C?C??CCC?C???CC?CC?????CC?CC?????C??C???CCC????CCCCC??CCC???C??C??C?C??...

output:

1485826
1212139
1485826
1212139
1400502
1677115
1485826
1677115
1400502
1677115
1485826
1212139
1485826
1212139
1485826
1677115
1485826
1677115
1485826
1212139
1400502
1677115
1400502
1212139
1485826
1212139
1485826
1677115
1400502
1677115
1400502
1212139
1485826
1212139
1485826
1212139
1485826
1212...

result:

ok 300000 lines

Test #14:

score: 0
Accepted
time: 2000ms
memory: 162620kb

input:

300000 300000
C??CC?????CCC?CCCC????CC?C?C???CCC????C???CC?CC?C???CC?????????CCC?C?C????CC??C?????CC?CCC??C????CC?C???CC??CC??CCC??CCC?C??C?C?CC??CCCC???CC??C?CCC?CCCCCC??CCC?C????C?CCCC??CCC?C?CCCC?C?C???C????CCCCC???C?????CC??CC??CC?C?CCCC??C?CC????C?C??C??CC?C?C?CCCCC?C?CC?CCCC??C???C??C??C?CCCC?...

output:

1974842
1695078
1430018
1695078
1430018
1695078
1974842
1706826
1974842
1706826
1430018
1706826
1974842
1706826
1430018
1706826
1974842
1695078
1974842
1695078
1430018
1695078
1430018
1706826
1430018
1706826
1974842
1695078
1430018
1706826
1430018
1706826
1430018
1706826
1430018
1695078
1430018
1706...

result:

ok 300000 lines

Test #15:

score: 0
Accepted
time: 2042ms
memory: 154688kb

input:

300000 300000
CC?C?CC?CC?C?CC??C???CCCCC?C??C?CC????????CCCC????CC???C?CC?C???CCC??C?CC??C???C?C?CC??CC??C???CCCC???C?C?C?CC??CCC?CCC?CCCCC???????C?C???C?C?????CC?CCCC?C?C???C?????????CCC??CC?CCCC??C?C?CC???C??CC???CC?C?CC??C????CCCC???C?CC?C?CCCCCCCC?C?CCC???CCCCCC?C??C???????C??C????CC??C??C?C??CC...

output:

1728837
1451650
1663426
1942865
1728837
1942865
1663426
1942865
1663426
1942865
1663426
1942865
1663426
1942865
1728837
1451650
1663426
1451650
1663426
1942865
1663426
1451650
1728837
1942865
1663426
1942865
1728837
1942865
1728837
1451650
1728837
1942865
1663426
1451650
1728837
1451650
1663426
1942...

result:

ok 300000 lines

Test #16:

score: 0
Accepted
time: 3105ms
memory: 164576kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

3019536
2746517
3019536
3285983
3010822
2746517
3010822
3285983
3010822
2746517
3010822
3285983
3019536
3285983
3010822
3285983
3019536
3285983
3019536
2746517
3019536
3285983
3019536
3285983
3010822
2746517
3010822
3285983
3010822
3285983
3019536
2746517
3019536
3285983
3010822
2746517
3019536
2746...

result:

ok 300000 lines

Test #17:

score: 0
Accepted
time: 2068ms
memory: 154468kb

input:

300000 300000
C???C?C?CCCC?C??C??CCC??CCC??C?CCC???C?C??CC?C?CC?CC??C?C????CCC??C??CC?????CC???C????CCCCC??CCCC?CC??CCC???CC?????CC????CCC???C??C?C?????C?CC?CC?CCCCCC???C?CCCC???C??????CC?C??C??C?C??C?C?????????C??CC?CC??C?????C??CC?C?CCCCCCC?C??C?C?C?C?CCC???CCC?CCC????C?C?CC?CC?CCC?C??CCC?????CCCC...

output:

1891146
1702030
1891146
1702030
1891146
1612503
1425186
1702030
1891146
1702030
1425186
1612503
1425186
1612503
1891146
1612503
1891146
1612503
1891146
1612503
1891146
1612503
1425186
1612503
1425186
1702030
1891146
1612503
1425186
1702030
1425186
1702030
1891146
1612503
1891146
1702030
1425186
1702...

result:

ok 300000 lines

Test #18:

score: 0
Accepted
time: 2052ms
memory: 162964kb

input:

300000 300000
??CC?????CCCCC?????C?C?C?C???CC???CC???C?C???C??????C?C?C????CC?CCCC?CC?CC?C??CCC???CC???????CC???CC?C?CC?CC?C?CC?C?C?????C????CC?C?CCC????CCC?????C??CCCCC??C?C?C?C???CCCCCC??CC?C????CCCCC?CC?CC?CC???C?CCC?CC?CC?C???C?C?C??C?C?C?C????C?CCC?CC??C?CC??C?C??CCCC??CCCCC?CC?CC????CCC????CCC...

output:

1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915088
1635795
1915...

result:

ok 300000 lines

Test #19:

score: 0
Accepted
time: 2023ms
memory: 162912kb

input:

300000 300000
?CCC?C??????CC?CCCCCCCC??C??CC???CC?CCCC?CC????CCC?C?C??CCC??C???CCC?CCCC?CCC?C?C??CC??CCCC?CCC?C???CC??CCC??C????C??C????C??C?C?CC??????CCC?CCCC????C?CC?C??CCCC????CCC??CC???C???C?CC??C?CC?C??C????CCC??C???C?CCC??C??????C???C?C????CC?C???C??C????C??CC???C?C?C?CCCCC?C?????CC?CCC??CC?CC...

output:

1446155
1708168
1987846
1722916
1446155
1722916
1987846
1708168
1987846
1722916
1987846
1708168
1987846
1722916
1446155
1722916
1446155
1722916
1987846
1722916
1987846
1722916
1987846
1708168
1987846
1722916
1446155
1708168
1987846
1708168
1987846
1722916
1987846
1708168
1987846
1708168
1987846
1708...

result:

ok 300000 lines

Test #20:

score: 0
Accepted
time: 5292ms
memory: 159424kb

input:

300000 300000
C??AA??C?AACC?CC?CAA??AAAAACAA??CAAAACACCCCA?CC??C?CC?CCCAAA?ACC?ACA?AA??AC?CA??AAAC?AC?A?CA??ACC??ACACC??CCA??A?C?CCCA???A???A?ACCAAC?CA??C??AA?A?ACCACA???CCACCCACAACAA??C??C?CACA??AA?ACAA??A??CCAA?CAA?AC?AC?CCCA?C?C???C?CCCC??CCACAC??CC?CCACA?CCA?AACC?AC???ACAC?AA?ACAACA?ACAAACA?C??C...

output:

1446727
1446731
1446741
1446749
1446749
1446755
1446761
1446757
1446757
1446757
1446757
1446757
1446763
1446754
1446754
1446754
1446754
1446754
1446751
1446751
1446751
1446757
1446760
1446762
1446762
1446762
1446762
1446762
1446772
1446765
1446765
1446765
1446768
1446768
1446771
1446771
1446771
1446...

result:

ok 300000 lines

Test #21:

score: 0
Accepted
time: 4424ms
memory: 158512kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

3167927
3167921
3167910
3167904
3167893
3167889
3167882
3167870
3167870
3167862
3167857
3167846
3167837
3167822
3167809
3167803
3167792
3167783
3167769
3167759
3167750
3167741
3167735
3167730
3167713
3167704
3167689
3167689
3167684
3167668
3167656
3167648
3167636
3167636
3167625
3167611
3167599
3167...

result:

ok 300000 lines

Test #22:

score: 0
Accepted
time: 5694ms
memory: 164684kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

3008613
3008613
3008613
3008613
3008613
3008613
3008613
3008613
3008613
3008613
3008613
3008613
3008613
3008537
3008537
3008537
3008537
3008537
3008537
3008537
3008537
3008537
3008537
3008537
3008537
3008533
3008533
3008533
3008533
3008533
3008533
3008533
3008533
3008533
3008533
3008533
3008533
3008...

result:

ok 300000 lines

Test #23:

score: 0
Accepted
time: 5785ms
memory: 167960kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

2861906
2861906
2861906
2861906
2861906
2861906
2861906
2861906
2861906
2861897
2861885
2861868
2861868
2861858
2861850
2861850
2861850
2861850
2861835
2861829
2861829
2861821
2861816
2861816
2861807
2861807
2861798
2861797
2861788
2861788
2861779
2861768
2861768
2861768
2861760
2861760
2861747
2861...

result:

ok 300000 lines

Test #24:

score: 0
Accepted
time: 1868ms
memory: 154124kb

input:

300000 300000
A?????CAA??A?ACCACCCCA?ACAA??CC?C?C?C?AAAC?A?A?CAAAACA??CAA???CAA?C?AAAA?CAA?C?C?ACA??C?C??CCC?ACA?A?A?C?AA?CACCCC??A?AACA?C??C?A?CC?C?C?A?A??A??C?CA?CA?A?AAA????A???AAC?CC?C?CACC?C?C?CA?C?CACCCC??????ACCAACCC?AA?AAA???AACAC??C?C?AA?AA?A?C?AA?AAC?CAC??AC?A???CCC????CCA???ACAC?AA?A?A?AC...

output:

1586159
1586159
1520065
1586159
1478768
1586159
1520065
1586159
1586159
1586159
1520065
1586159
1520065
1520065
1586159
1586159
1586159
1586159
1586159
1586159
1586159
1520065
1520065
1329238
1329238
1329238
1394959
1394959
1394959
1586159
1586159
1586159
1520065
1520065
1520065
1520065
1520065
1586...

result:

ok 300000 lines

Test #25:

score: 0
Accepted
time: 1552ms
memory: 195008kb

input:

300000 300000
??CA?ACCCCCCC?C?ACC??ACACA?ACA????CAA?C?AC?A???A?CCCA?A?CC?CCA??AC???AACAC?ACAAACCAA?AA?C??AA?AACAA???A?AAAC??A?CCA?????ACC?C??A?C?AAAAC??AA?ACCCC?CCACCCCA???AAACC?AAC?A??CAAC?AA??C??CACCAC??ACCA?AA?CC?AA?AAA??CC??AC?AA?AA??CAAACAC??CAAA?AA?AACAC??ACC?AAA??CAC?CAAAC?CCCCCA?AA?AA??AC?AC...

output:

15019584772
15019584772
15019584772
15019684753
15019784735
15019784735
15019784735
15019684754
15019684754
15019684754
15019684754
15019784735
15019784735
15019684753
15019684753
15019684753
15019684753
15019784735
15019684755
15019584773
15019684754
15019784735
15019784735
15019784735
15019684755
...

result:

ok 300000 lines

Test #26:

score: 0
Accepted
time: 1283ms
memory: 199312kb

input:

300000 300000
CCCCCACACAAACACAAACAACCCAAACAAAACCCAACCCACCACCACCAAAACACCCAAACAACAAAAAACACAAACCCCCACCAACCACAAAACACCCCACCAAAAAAACAAACACACACCACACCAAACCCACAACACAAAACCACCACAAACCACACCAAACCACCACCAAAACCAACAACACAAAAAACCAACACACAACAACACAAAACCCACCCACAACCACAAACCACCCAACCCAAAAACAAACCCACCCAAAACACCAACAAACAAACCAAAACAA...

output:

11250190690
11250290857
11250391020
11250391020
11250491189
11250491189
11250491189
11250591342
11250691501
11250691501
11250691501
11250691501
11250691501
11250791657
11250791657
11250791657
11250791657
11250891817
11250891817
11250891817
11250891817
11250891817
11250891817
11250991979
11250991979
...

result:

ok 300000 lines

Test #27:

score: 0
Accepted
time: 1568ms
memory: 161120kb

input:

300000 300000
CC?CAAA???CC??ACC?C???C?CCACA??C?ACAAC?AAC?A?C??A?CC?CA?A???CCACAAAC???A?AAA??CACC?A??CC???CCCCACACAAA?AAA?A?CC???AACCCCC??ACC?AAAAA?AC?C?A?C?A?AA?C??AC?AAACCAAAC???A???CACAAA???CAAAC?CAAAA?AAAACCCA??CA?CCCC?AACAC?C?A?CAAC??CCAC?ACAA???ACAA?ACACAA?AC?AAA?C??CCAAAAAACAC?CCA?AACA?A??C??A...

output:

371245400
371243347
371245400
371245400
371245400
371243347
371245400
371243347
371245400
371243347
371245400
371245400
371243347
371245400
371245400
371245400
371245400
371243347
371245400
371245400
371245400
371245400
371245400
371243347
371245400
371243347
371245400
371245400
371245400
371243347
...

result:

ok 300000 lines

Test #28:

score: 0
Accepted
time: 1617ms
memory: 161288kb

input:

300000 300000
AC?AC??C???CAAACCC?CA?C?C?CAC??CAACA???A???C?CAA?CAC?ACCAACC?CCC?AC??C?AA?A?ACAAC?C?AAC?AAAC?C??CCACCCC?AACC?A?AC?A?C?ACC?C?CCAC???ACAC?CCCCAA??C??CAAC?CCACCACCCA??C?CA??A?CC?A???CCCC?C??CAACCACA?A??AAACCACA??CCAA?C?AC?ACC???CCAACCC?????AACCAA?CA??CC?CACACAA?A?CAA?AACCA?CAAC??A???CAAAC...

output:

470903990
470903990
470901190
470903990
470903990
470903990
470903990
470901190
470901190
470903990
470903990
470901190
470903990
470901190
470903990
470903990
470901190
470901190
470901190
470903990
470903990
470903990
470903990
470903990
470903990
470901190
470903990
470903990
470903990
470901190
...

result:

ok 300000 lines

Test #29:

score: 0
Accepted
time: 1233ms
memory: 167140kb

input:

300000 300000
??CC??CCC????C?C?CC?C?????C?C?CC?CCC?CCC?C?CC????CCC?C????C?CC??CCCCCC???C???C?C?C?C?C?CC??C?????CCC?C?C???CC?C?C???CCC?C?CC??CCCC??C??CC??C?C?CC??CCCC?C?CC?????C?C??CCC???CC?C??CCCCCC????C??????C??CC?C?C???CCCCCC??C??C?CCCCCC???CCCCCC?CC?CCC?C?C??C??C?CCC????CCC??C?CCCCC??CCC?CCCCC?C?...

output:

5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
5221101235
522...

result:

ok 300000 lines

Test #30:

score: 0
Accepted
time: 1412ms
memory: 183348kb

input:

300000 300000
C??CCC??C?C????C????CC?C?C??C????CCC??CCC??C?CCCCC?C?CC?C???CC??CCCCCC??C??C?C?C???CC?CC????CCCC??CCC??C?C??CCCC??C????CCCC?CC?CCC???CC??C??C???CC?CCCCC??CCC??C?C?CCCC??????C??C?CCC?C?CCCC??????C?C?CC??CCC???C???C??C?CCC?CC?C?CC?C????CCCCCCCC?C?CCCCCC??C??C?CC?C??CCCC?CCCCC?CC?CC?C???C...

output:

13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
13525771476
...

result:

ok 300000 lines

Test #31:

score: 0
Accepted
time: 1324ms
memory: 168604kb

input:

300000 300000
????C???C??C??CCC?CCCCCC??C??CCCCC?C?C???C?C?CC?CC??C?CC?C??C???C????CC?C?CCCC?C??CCC???????????CC?CCC???C??CC?CC??CC?C??C?C???CCCCCCC?C?CCC?CCC?C?C??CCCC?????CC??C?C???C??CC?C?C?C??C??CCC?C?C??CC?CCC?C?CC??CCC?CCCCCCCC?CC??CC?????C?C??CC??C?CCC?CCC?????C??C??CC??C?????C?CCC??CCC????C?...

output:

3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
3239074691
323...

result:

ok 300000 lines

Test #32:

score: 0
Accepted
time: 1354ms
memory: 168692kb

input:

300000 300000
???CCCCCCC?C?C?C?????CCCC?C??C?CC?C?CC??????CC???CC??C???C?CCCCC?CC??C??C??CCC???C??CC???CC??C?C?CC???C???C?????CCC?C?C??CCCC?CCCCC?C?CCC??C??CC?C??CC?CC?C?CCCCC??C?CC??CCCCCCCC??CC?CCC?C?C?C??????????C?C?C???CC??CCC?CC?CCCC?CCC??C???CCC??CC?CCCCCCC???CCC?C??????C??CCC?CCCC????CCCCCC?C...

output:

6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
6342727579
634...

result:

ok 300000 lines

Test #33:

score: 0
Accepted
time: 1376ms
memory: 178832kb

input:

300000 300000
C??CCCCCC??CCCC?C???C?CC?????CCCCC?????CC??CC??C??CC???CC??C???CCCC???CC???C?CC??CCC?CC?????C??C?CC?C?C??C?CCCCCC?C??CC??C?C?C?CCC??CCC??????CC??C?C??C????CC????C??CCCC???CCCC?C??C??C??CCC?C?CCCC???CC??C??CC?C?CC??C?C??CCC??C??C?CC?CC?C????????C??C?CC?C?CCCCC?C????C?C?C?????C??C?CC??C?...

output:

11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
11216233327
...

result:

ok 300000 lines

Test #34:

score: 0
Accepted
time: 3793ms
memory: 179116kb

input:

300000 300000
?CCC???????CCCCCC?CCC????CCCCC?CC??????C?C??C?CC?C?C?C?CCC????CCC?C??C???CCC?C?C??CCC?CCC??C??CC?CC??C?CC?????CC?CCC??CC?C??CCCCC???????CCCC???C??CC?C?????C?CC??C?CC?CC?C?C??C??CC??C????CCCCC??C?C???CC???????CCC??????C?CCC?C?CC?CCCCC???CC?C?CC?????CCCCC?CC?CC?CC?CCC?C?C?CCC?CCCC????CCC...

output:

13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
13745882773
...

result:

ok 300000 lines

Test #35:

score: 0
Accepted
time: 6636ms
memory: 167044kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
10018652160
...

result:

ok 300000 lines

Test #36:

score: 0
Accepted
time: 2348ms
memory: 182436kb

input:

300000 300000
C???C??C??C?C??CCCCCC?CCC??C?C?C?C??C?CC?CC?C???CCC?C??CC?????CC????CC??C?CCC??C?C?CCCC??C?CC?CCCCC?CC?????C??C?CCCCC?CCC?C?CC????CC?CCCC?C??C?C??CC?CC??C?C?CC?C?C?C?C?????C?CCCCCCCCCC??CCCC?CC?CC?????CCC?C?CC??C??CC?????CC?C?C?CC?C?C????CCCC?C?????C????C?C???C?C????CC?C?C?C?CCC??C?CCC...

output:

13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
13538785511
...

result:

ok 300000 lines

Test #37:

score: 0
Accepted
time: 1961ms
memory: 169308kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
6150914352
615...

result:

ok 300000 lines

Test #38:

score: 0
Accepted
time: 1624ms
memory: 169576kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
11904000000
...

result:

ok 300000 lines

Test #39:

score: 0
Accepted
time: 1466ms
memory: 175684kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
19840320000
...

result:

ok 300000 lines

Test #40:

score: 0
Accepted
time: 1429ms
memory: 159196kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
1202880000
120...

result:

ok 300000 lines

Test #41:

score: 0
Accepted
time: 1658ms
memory: 166736kb

input:

300000 300000
??????CC???CCCC??C?CC????CCC?CC???C??CC?CCCCC?C??????CC??C?CCCC?CC?CC??CC?C?C???CCCC???C??C?CC?C?C??C????C?CC?CC????C?C??CCC?C???CCCC?CC??C?CC?CCC?CCCCCCC?CCCC?CC???????CCCC???C?C?CC?CC??CC????C?C???CC??CCCCC?CC???CC?C?C???C??C?CCCCC??CCCC???CC?C??C?C???C?CCCC??C??CCC??CC???CCCCCCCC??C...

output:

356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
356828931
...

result:

ok 300000 lines

Test #42:

score: 0
Accepted
time: 1638ms
memory: 163300kb

input:

300000 300000
C?C?C??CCC?C??C?C?CCCCCCCCC???CCC?CCC?CC???CCCC?CC?C?CC??CC?C?C?CC??C???C?C???????C?CC??C?C?CC???C????C?C?C???CCCCCC?C?C?CCCC??CCC?C??C??CC?CCCCC?CC?C??C??C?C????CC?CCCCC??CC???CC?CCCCCCC???C?C?CCC?C??C??CCCCC?C?C?C??C?CCCCC?CC?CCCCCCCC????C??CC?C?CCCCC???C?C??????C????CC?CC??C??CC??CC...

output:

376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
376580169
...

result:

ok 300000 lines

Test #43:

score: 0
Accepted
time: 1623ms
memory: 161076kb

input:

300000 300000
?????C?CCCCCC??CC?C????C??C??CC??C?C?CCC????CCC?CC?C??C?C?CC?CCCC?C??C??CCCC?C?CC???C?CCC????C??CC?C??C???C???????C????C??CCCCCCC????CCC?C?C??C??CC??CCCC?C?CCC??CC?????C??CCC??C?C?CCC?CC?C?????CC????CCC??C?CC?C?CCC?C????CC?CC???CC??CCC????????CC?????C?C??C?CC?CCCC?CC???C?C??C???C?C?C?C...

output:

390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
390611353
...

result:

ok 300000 lines

Test #44:

score: 0
Accepted
time: 1711ms
memory: 166484kb

input:

300000 300000
??C?CCC?C??C?CCCCCCC??C?C?CCC??CCC?CC?CC??C??CC?C???CCC???C????C??C?CC?C?C?CC???CCCC??CCC?CC??CCCCCC??C??C?C?????C????CC?C???CCCCCCC??C?C?C?CCC?C?C?C?????????CCCC?CC??CCCC?????????C???CCC?CCCC?C?C???C??C??C?C?C??C?CCC?C?C????CCCCC??CC?C??C?CC????C?C??C??CCC??CCCCC?C?C??CCC??C?C?C?C????...

output:

262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
262017313
...

result:

ok 300000 lines

Test #45:

score: 0
Accepted
time: 3143ms
memory: 167392kb

input:

300000 300000
C?C?CC???C???CC????C?CCC??CC??CCCC?CC?CCC?CCCC?CCC??C?CCCCC?C???CCC?CCCC?CC??CCCC????CCC?????C?CC????CCCCCC?C????CC??C??CC?C??C?CCCCCC?CC??C???CCCCCC?CC??C????C????CCCCCC?C??C??C?CC?C??????C??CC???CCCCCCCC?CCCCCCCCCCC????CCC??CC??CCC?????C?CCCCC??C?CC??CCCCC?CCCCC???????CC??CC??CC?????...

output:

267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
267189549
...

result:

ok 300000 lines

Test #46:

score: 0
Accepted
time: 2356ms
memory: 168012kb

input:

300000 300000
?C???CCCCCCC?CCC???CCCC?CCCCCCC?????????CCCCCCCC????C?CC???CC?C??CCCC?CC?C?C?CCC????CC?C??CC?C?CCCCC???C?CCCCCC??C????CCCC?C??CC????C?C??????CC?C??C????C?CC??CCC?CC????C?CC?CCCC?CCC?C??????C???????CC?C?CC??CCC????CCCCCC??????C?CC??CC?CC???CC??C?CC?C?CCC??C?C???C?CC?C??C??C?CCC?CCCC???C...

output:

386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
386616272
...

result:

ok 300000 lines

Test #47:

score: 0
Accepted
time: 2383ms
memory: 163792kb

input:

300000 300000
?CCC?CC?C???CC???C??CC??C???CC??C?CC?CCC?C???C?C????CC?C???C?CC?????CC??CC?C?C?C??C??CC???C?CC??????CC?C?C??CCCCC?????CC??CC????C?CC????CCCCC?C???C???C?C??C??CCC?CCCC???C?C?C??CCCC????CCC???CCCC??C??C??CCC?CC?CC?CC????C??CC???CCC?C??CCC????C?CC??C?CC?C?C??CC??CC????CC?C??C?CCC?CCC??CC?...

output:

359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
359624722
...

result:

ok 300000 lines

Test #48:

score: 0
Accepted
time: 2341ms
memory: 164008kb

input:

300000 300000
C??CCCC??????CCCC??CCC???CCCCC??C?????C?C?C????C?C?C?C?CC??C?CCC???CC?C?CC?C?CCC??CCCC?CC?C?C?????C??CCCCC??CCCC?CCCCCC?C?C?C?????C?????C?CCC???????CC??C?CCCC?C?C????CCCCC?C???C?CCCCCCC?CCC??CC?C??C???C??C?CCC?C?C??C??C?CC?C?CC??C??CC??CCC?????CC??CC?CCCCCC??CCCC???C?????CC?????C??C??C...

output:

377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
377887901
...

result:

ok 300000 lines

Test #49:

score: 0
Accepted
time: 1403ms
memory: 166456kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
...

result:

ok 300000 lines

Test #50:

score: 0
Accepted
time: 1415ms
memory: 166992kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
...

result:

ok 300000 lines

Test #51:

score: 0
Accepted
time: 1381ms
memory: 163452kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
...

result:

ok 300000 lines

Test #52:

score: 0
Accepted
time: 3654ms
memory: 167000kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
226740000
...

result:

ok 300000 lines

Test #53:

score: 0
Accepted
time: 2841ms
memory: 163272kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
401120000
...

result:

ok 300000 lines

Test #54:

score: 0
Accepted
time: 2058ms
memory: 164660kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
890539375
...

result:

ok 300000 lines

Test #55:

score: 0
Accepted
time: 2081ms
memory: 164116kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
699120000
...

result:

ok 300000 lines

Test #56:

score: 0
Accepted
time: 2032ms
memory: 165864kb

input:

300000 300000
?CAC??CC??C?A?ACCA?AA?A??CA?AAA?ACAA?A?A?C??C?CCACCCA?C?ACCACA?CAAACCA???AAA?CCAAACA?A?ACCACCC??AAACA?A?AAC?C?AC??CAAACC?A???C??CCA?CCC??C?A?ACACAACCC??AA?CCCA?ACC?A?AAAC?AC?ACCCC???A?CCC?A???A?AA?C?AC??ACCCACCCCCAC?A?C?CC?ACAACAAACCA????A?AA???A?CCC?A?A?AA?C?CC????CCCCCCC?ACCA?A???C??...

output:

648652693
648648958
648648958
648648958
648652734
648649995
648649995
648652806
648656583
648656583
648660337
648664004
648667704
648670443
648674118
648674118
648674118
648670451
648666757
648669597
648669597
648672402
648672402
648676165
648676165
648679946
648679946
648677176
648680912
648683703
...

result:

ok 300000 lines

Test #57:

score: 0
Accepted
time: 1751ms
memory: 168584kb

input:

300000 300000
ACA?ACCACAA?A?CCCA?ACCAA?C??A?AA??AA?CC?CACC?CCAC?AACA?A?C?C?ACA?????CCCC?C?CA?C???AA?A??CC??AAA?C?CAC?CCAAAA??CAAAAC?A???A?CC???ACC?ACAACACCCCCC?C?CA?AA??AAC?CCCCCC?AACCC?AC?C???ACA?CA?ACC?CCCACAACCA?CAACCA??AAC???AAAC??AACAC?CCCCAAA??CACACC??C?C?ACA?ACA??AAC?AC?C?CA?ACAACCA??AA?C?C?C...

output:

1109207684
1109201361
1109201361
1109194992
1109194992
1109190259
1109195053
1109188711
1109193525
1109187191
1109193525
1109193525
1109193525
1109188751
1109193484
1109187108
1109187108
1109193477
1109193477
1109193477
1109188697
1109188697
1109193389
1109188631
1109188631
1109193405
1109188582
110...

result:

ok 300000 lines

Test #58:

score: 0
Accepted
time: 1624ms
memory: 163200kb

input:

300000 300000
?CCACACC??AACAAA?CCAAACC?CCC?AACAACAC?A??A?CCC???AACCA?C????C?AA?CA?AC???AA?A?ACCCAA?AACC?AAC???A?A?ACCCA?AACCCAA??CACCC??AA??C?AC?C?A?CC?A?CAACAC?C????AAACA?C??C?A?CCCCC?CA?CAACA?ACCCC?CC??AC???CCA??AAA?A?CCCACA?ACAACCCC????C?C?CAAA?CC?C????CCACACC?A?C?CAACCAACCC??C?C?A????A??AAAA????...

output:

653023096
653019360
653023096
653023096
653019360
653023096
653023096
653019360
653023096
653023096
653019360
653023096
653019360
653023096
653019360
653023096
653023096
653019360
653023096
653019360
653023096
653019360
653023096
653023096
653019360
653023096
653019360
653023096
653019360
653023096
...

result:

ok 300000 lines

Test #59:

score: 0
Accepted
time: 1602ms
memory: 162884kb

input:

300000 300000
AAAACC?C???C?CAACCCC?CCAC?CAAACC??CCC??CCCCA???CCCCAA?????AC??CCACC?C?AA???AA?C?AC??AAAAA?CCA?CCAAAAAC?ACCCAAA??CC??C?C?C?A??CCACAC?CCCACA?CAC?CAACA?CAAA?A??ACA?CC???C??CA?C?C?CCC?AA?AA?AAAA??A?C??A?CCC?CC?C??AA?A?????C?AC?AAA?CA?CA?ACAC?AA???CAAAAA?A??C?A?ACC?CCCACA?A?AC?A?AAC??CA?ACA...

output:

1119408992
1119415349
1119408992
1119415349
1119415349
1119408992
1119415349
1119408992
1119415349
1119415349
1119415349
1119408992
1119415349
1119415349
1119415349
1119415349
1119415349
1119408992
1119415349
1119415349
1119408992
1119415349
1119408992
1119415349
1119408992
1119415349
1119408992
111...

result:

ok 300000 lines

Test #60:

score: 0
Accepted
time: 6384ms
memory: 200916kb

input:

300000 300000
C?CCC??C?C??CC?CCCC?C????C??CCC??????CCC?CC???C?CCCCC??CCCC??C??CC??CC?????C??????CC??C?????C?C?C?C?C??CCCCCCC?C?CC?CCC?????CC?C???C?CC?CC???C?C????CCCCC??C?C?C??CC?C?CC??CCCCCCCC?????C?C???C?C?????CC??CC??C?CC?C?CCC??CC?C?C??C?C??C????C???CCCC?C??C???C????C??CC?CCC?C?C??C?C???CCC???CC...

output:

14998070534
14998070534
14998007100
14998172540
14998241942
14998359195
14998504022
14998504022
14998504022
14998346520
14998504013
14998585000
14998410463
14998410463
14998452764
14998441709
14998611519
14998611519
14998611519
14998634588
14998789900
14998793480
14998955837
14998775250
14998586888
...

result:

ok 300000 lines

Test #61:

score: 0
Accepted
time: 2972ms
memory: 163936kb

input:

300000 300000
AA????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
1317667500
131...

result:

ok 300000 lines

Test #62:

score: 0
Accepted
time: 3081ms
memory: 168240kb

input:

300000 300000
AA????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
142...

result:

ok 300000 lines

Test #63:

score: 0
Accepted
time: 3353ms
memory: 167700kb

input:

300000 300000
AA????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620360000
1620354310
1620354310
1620354310
1620354310
1620354310
1620354310
162...

result:

ok 300000 lines

Test #64:

score: 0
Accepted
time: 3082ms
memory: 164672kb

input:

300000 300000
AA????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
2041600000
204...

result:

ok 300000 lines

Test #65:

score: 0
Accepted
time: 2150ms
memory: 158720kb

input:

122211 159587
ACC?A?AACCC?CCC???CCA?AACC?C?C?CCCCACCC?C?CC??CA?CA?CCACA??C?CC??C?AACACCAC??ACC???CAA??CAACCA?C?CCCACA?CCAC?CAAA?ACAC???CCCCAAC?A?CCCCAC?C?CACC?A?ACC?A?CAAACCCC?A??CCAC?C??AACCACAAAA??A?C?ACCAACAAC?CAC?C??CACACCAC?CA?AC?CCC??CCACC??ACA?AAA?A?CAACAA???CC?AC?A?CA?A?ACC?C?A?AAC?A?AAA?CAA...

output:

495494
495494
495502
495506
495506
495506
495497
495497
495494
495492
495486
495478
495478
495478
495473
495478
495478
495471
495471
495466
495466
495466
495466
495466
495463
495463
495490
495490
495482
495482
495478
495478
495478
495475
495475
495513
495513
495513
495523
495523
495529
495529
495538...

result:

ok 159587 lines

Test #66:

score: 0
Accepted
time: 2342ms
memory: 173284kb

input:

163654 155551
ACAAACC?ACACAC?ACC?C?A?CCCA?ACAAA?AAAACA?CACCC??CC??CAAAA?AAAA???ACA?CACCCA??CC?AAAACAA??A???AAC?C?CAC??AA?C?A???C?A?CACC???ACA?C?CC??A?AC?ACACC?C?CC?AC?AACAC?A?CCCC?AAACAAC?A?CACACA??C?CCC?CACCA???CA???AC?C?CACAAA?A?C?CCA?AAACA??CCCA?AC?CCC?A??A??AC??A?ACA?CCCC?CCC?ACAC??AA?C?ACC????A...

output:

4452490397
4452490397
4452539260
4452573871
4452573871
4452500700
4452500700
4452500700
4452500700
4452500700
4452530009
4452530009
4452530009
4452530009
4452530009
4452530009
4452543734
4452543734
4452543734
4452543734
4452583144
4452529076
4452529076
4452474525
4452478596
4452478596
4452478596
445...

result:

ok 155551 lines

Test #67:

score: 0
Accepted
time: 915ms
memory: 147372kb

input:

131313 111111
AA?CACC?AACAC??CA???CA??C?C????AAAACAC?????ACCC?AA?A??ACCAA?A??A?CC?C?CAACAC??AAAC?CCCC??AACA?AACAA????A?AACA??CCCCCAC?CCA?AC?A?AC?AA?A?AC??A?AAC??C??CCACACACACC?AA?ACA?CCCA?CACA?AACC?ACA?AACCAACCAAAC??CCAC?A????AAA?ACA?A??CC??AC?A?AAC?CAA?CA???CAAA??C?CA?AAAC?C?CCCA?C??AA?CC?CC?CC?CAC...

output:

87550
87551
87551
87550
87550
87549
87550
87551
87551
87552
87552
87551
87550
87550
87550
87550
87550
87549
87549
87549
87549
87549
87549
87549
87549
87550
87550
87550
87551
87551
87551
87551
87551
87552
87552
87552
87551
87551
87551
87551
87551
87551
87551
87551
87551
87551
87551
87551
87550
87550
...

result:

ok 111111 lines

Test #68:

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

input:

1 1
C
1 C

output:

0

result:

ok single line: '0'

Test #69:

score: 0
Accepted
time: 1121ms
memory: 177896kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
18814192180
...

result:

ok 300000 lines

Test #70:

score: 0
Accepted
time: 3051ms
memory: 160280kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071699
2798277
3071...

result:

ok 300000 lines

Test #71:

score: 0
Accepted
time: 2019ms
memory: 155936kb

input:

300000 300000
C??C?CCCCCCCC?????C?C??C??C??CC??CC???C?CCCCC?CC?C??C?CC??C??C?C?C?C?CCCCCC?CC???CC??C?C?CC?C?C???CCCCCCCCCC?C?C???C?C???C??CCC???C????CCC??CCC?CC?CC?CC????C?CCC???C??C??????C?C???CCCCC?CC??CC?C????C?CCCC?CC???????C???C?C?C?CC?C?CC???CCC?C??C?C????CC?CC?C???CC?C?CC???CC?CC?CC????CC??C?...

output:

1785000
1555695
1280958
1507087
1785000
1555695
1785000
1507087
1280958
1507087
1785000
1507087
1280958
1555695
1785000
1555695
1280958
1507087
1785000
1507087
1280958
1555695
1280958
1555695
1785000
1507087
1785000
1507087
1785000
1555695
1785000
1507087
1280958
1555695
1785000
1555695
1785000
1555...

result:

ok 300000 lines

Test #72:

score: 0
Accepted
time: 2084ms
memory: 166920kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
708887459
...

result:

ok 300000 lines

Test #73:

score: 0
Accepted
time: 3020ms
memory: 155844kb

input:

300000 300000
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

2850941
3124929
2850941
3124929
2888870
3124929
2888870
3124929
2850941
2616813
2850941
3124929
2850941
2616813
2850941
2616813
2850941
3124929
2888870
3124929
2850941
3124929
2888870
3124929
2850941
3124929
2850941
2616813
2850941
2616813
2888870
3124929
2850941
3124929
2888870
3124929
2888870
3124...

result:

ok 300000 lines

Test #74:

score: 0
Accepted
time: 3095ms
memory: 167228kb

input:

300000 300000
A?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????...

output:

1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
1424750000
142...

result:

ok 300000 lines