QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#290947#7963. 多折较差验证FamiglistmoAC ✓283ms396796kbC++141.5kb2023-12-25 21:57:562023-12-25 21:57:57

Judging History

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

  • [2023-12-25 21:57:57]
  • 评测
  • 测评结果:AC
  • 用时:283ms
  • 内存:396796kb
  • [2023-12-25 21:57:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=5005;

char buf[1<<23],*p1=buf,*p2=buf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
int read(){
    int s=0,w=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();};
    while(isdigit(ch))s=s*10+(ch^48),ch=getchar();
    return s*w;
}

int f[N][N],g[N][N],lp[N][N],rp[N][N],L[N],R[N];
char s[N];
int n;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);

    cin>>n>>(s+1);

    for(int i=1;i<=n;++i){
        f[i][i]=1,g[i][i]=0,lp[i][i]=rp[i][i]=i;
        L[i]=R[i]=i;
        while(s[L[i]-1]!=s[R[i]+1])--L[i],++R[i];
    }

    for(int r=1;r<=n;++r){
        for(int l=r-1;l;--l){
            
            if(((r-l+1)&1)&&L[(l+r)/2]<=l)
                f[l][r]=f[l][(l+r)/2-1]+1,
                g[l][r]=g[l][(l+r)/2-1],
                lp[l][r]=rp[l][r]=(l+r)/2;
            else {
                lp[l][r]=lp[l][r-1];
                rp[l][r]=rp[l+1][r];

                f[l][r]=min(f[lp[l][r]+1][r],f[l][rp[l][r]-1])+1;
                g[l][r]=1e9;
                if(f[l][r]==f[lp[l][r]+1][r]+1)
                    g[l][r]=min(g[l][r],g[lp[l][r]+1][r]+abs(l+r-2*lp[l][r]));
                if(f[l][r]==f[l][rp[l][r]-1]+1)
                    g[l][r]=min(g[l][r],g[l][rp[l][r]-1]+abs(l+r-2*rp[l][r]));
            }
        }
    }

    cout<<f[1][n]<<" "<<g[1][n]<<endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 168ms
memory: 396252kb

input:

5000
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...

output:

5000 12497500

result:

ok single line: '5000 12497500'

Test #2:

score: 0
Accepted
time: 167ms
memory: 394764kb

input:

4991
^^vv^v^^^^vvv^^^^^^vvvv^^^^^^^vv^^^^^^^^v^^^^^^v^^^v^^v^^^v^^^^^v^^v^^^^^^^^vv^^^^^^^^^^vvvvvvv^v^^^^^v^v^^^^^v^^^^^^^^^^^v^^^^^vv^v^^^^^v^^^^vvv^^^v^^^^v^^^^^vv^^v^^^^^^^v^^^^^^^^^v^v^^^v^^v^^^^^v^^^vv^v^^^v^^^v^v^v^^^^v^^^vv^^^^vv^^v^^v^^^^^^^v^^^^^^v^^^^v^^^^^^v^^v^v^^^^^^^^v^^^^^v^^^v^v^^^^...

output:

2748 6735487

result:

ok single line: '2748 6735487'

Test #3:

score: 0
Accepted
time: 162ms
memory: 395320kb

input:

5000
vvvvvv^v^vvvv^^^vv^^v^v^^^vvvv^v^v^v^v^v^v^vvvvvvvv^^vvv^vvvvvvvvvvvv^vvvv^^^^vvvv^vv^^vv^vvv^vvvvvvvv^^vv^^vv^vvvvv^vvv^vvvvvvvvv^v^^vv^v^vvvvv^v^v^vvvv^vvv^vvv^^vvvvv^^vvvvvvv^v^vvvvv^v^^^^v^vvv^v^vv^vvvvv^vv^vvvvvv^vvvvvv^vvvvvv^vvv^^vvvvvvv^^^^vv^vv^v^vvvv^vv^vvv^vvv^vvv^vvvvv^^^^vvvv^vvvvv...

output:

2793 6922268

result:

ok single line: '2793 6922268'

Test #4:

score: 0
Accepted
time: 168ms
memory: 395640kb

input:

4996
vv^^vvvv^^v^^^vvvv^vv^vvvvv^vv^^^vvvv^vv^^^vvv^^v^vvvvv^vvv^v^^vv^^vv^vvvvv^v^vvvvvv^^vv^v^vvv^^vv^vvvvvv^vvvv^vvvvvvvvvvvvv^vvvvv^vvv^vvv^vvv^^vv^vv^vvvvvvv^^vvv^vv^vvvv^vvvvvv^vv^vvvv^v^vvv^v^^vvv^vvvv^^vvvvvvvvvvv^^vv^v^vv^vv^vv^^v^v^^^^vvvvvv^^vvvv^vvv^vvv^v^vv^vvvvvvvv^vvv^v^^vv^vvv^vv^v^v...

output:

2784 6803847

result:

ok single line: '2784 6803847'

Test #5:

score: 0
Accepted
time: 168ms
memory: 395176kb

input:

5000
vvvvvvvvvvvvvvvvvvvvv^^vvvvvvvv^vvvvvvvvvvv^vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv^v^vvvv^vv^vvvv^vvvvvvvvvvvvvvvvvvvvvv^vv^vvvvvvvvvvvvvvvvvvvvvvvvvvvv^^vvvvvvvvvvvvvv^vvvvvvvv^vvvvvvvvvvvvvvvvv^vvv^vvvv^vvvvvvvvvvvvvvv^v^vvvvv^vvvvvv^vv^vvvvvvvvvvv^vv^vvvvvvvvvvvvv^vvvvvvvvvvvvv^vvvvvvvvvvvvv^vvvv...

output:

4052 10043778

result:

ok single line: '4052 10043778'

Test #6:

score: 0
Accepted
time: 159ms
memory: 395956kb

input:

4992
vvvvvvvvvv^vvvvvvvvvvvvvvvvvvv^vvvvvvvvvvvvvvvvv^vvv^vvv^vvv^vvvvvv^vvvvvvvv^v^vvvvvvvvvvvvvvv^vvvvvv^vvvv^vvvvvvvvvvv^v^^vvvvvvvvvvvvvvvvvvvvv^^vvvvvvvvvvvv^vv^vvvvvv^vvvvvvvvvvv^vvvvvvvvvvvvvvvvvvvvvvvvvvvv^vvv^v^vvvv^vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv^vvvvvv^v^vvvvvvvvv^vvvvvvvvv...

output:

4094 10183595

result:

ok single line: '4094 10183595'

Test #7:

score: 0
Accepted
time: 173ms
memory: 396336kb

input:

4992
^^^^vvvvvvvvvv^^^^^vv^^^^^^^^^^vvv^^^^^^vvvvvvv^^^vv^vvvvvvvvv^vvvvvvvvv^^^^^^^^^vvvvvvvvvv^^v^vvvvvvv^^^vvvvvvvvv^^^^^^^^^^vvvvvvv^^^^^vvvvvvvvv^^^^^^^^vvvv^vvvvvvvv^^^^^^^^^^vvv^^^^^^^vvvv^^^^^^^^^vvvvvvv^^^^^^^^vvvv^^^^^vvvvvvv^^^^^^^^vvvvvvvvvv^^^vvvvvvv^^^v^^^^^^^^^vvvvvvvv^^^^^vvv^^^^^^^^...

output:

1513 3793047

result:

ok single line: '1513 3793047'

Test #8:

score: 0
Accepted
time: 177ms
memory: 396208kb

input:

4999
vvvvvvv^^^^vv^^^^^^^^^^vvvvvvvvv^^^^^^^^^^v^^^^^^^^^vvvv^vvvvv^^^^^^^^^vvvvv^vvv^^^^^^^^vvvvv^^^^^^^vvvvvvvvv^^^vvvv^^^^^^^^^^vvvvvv^^^^^vvvv^^^^^^vvvvvvvvv^^^^^^v^^^^vvvv^^^^^^^^^vvvv^^^^vvvvvvv^^^^vvvv^^^^^^^^vvvvvvvv^^^^^^^vvvvvvvv^^^^^^vvvvvvvvvv^^^^^vvvv^^^^^vv^^^^^^vvvvvvvvv^^vvvv^^vvvvvv...

output:

1641 3991610

result:

ok single line: '1641 3991610'

Test #9:

score: 0
Accepted
time: 178ms
memory: 395724kb

input:

4997
vvvvv^^^^vv^^^vv^^vvvv^^^^^vvvvvvvvvv^^^^^^^^^vvvv^^^^^^^^^vvvv^vvvvv^vvvvvvvvvv^^^^^vvv^^^^^^^^vvvv^^^^vvvvvvvvv^^^^^^vv^^^^^^^^^vv^^^^^^^vvvvvvvvv^^^^^^vvvvvvv^^^^^^^vvvvvvvvv^^^^^^^^vvvvvvv^^^^^^^^^^vvvv^^^v^^^^^vvvvv^^^^vvvvvv^^^^^^^^^vvvvvvv^^^^^vvvvvvv^^^^^^^v^^^^^^^^^vvvvvvvv^^^^vvv^vvvv...

output:

1572 3933114

result:

ok single line: '1572 3933114'

Test #10:

score: 0
Accepted
time: 171ms
memory: 395524kb

input:

4999
^v^^^^^^^vvvvvv^^^^^^^^^^vvvvvv^^^^vvvv^^vvv^^^^^^^^^vvvvv^vvvvvvvvv^^vvv^^^^v^^^^^^^^^^vv^^^^^^^^^v^^^^^^vvvvvvvv^^^^^vv^^^^^^^^^vvvvvvvvvv^^^^^vv^^^^vvvvvvv^^^^^^^^^^vvvvvvv^^^^^^vvvvvvvv^^^vvvv^^^^^^vvvvvv^^^^vvvvvv^^^^^^v^^vvvvvvv^^^^vv^^vvvvv^^^vvvv^^^^vvvv^^^vvvvvvvvvv^^^^^^^^^vvvvv^^^^v^...

output:

1485 3659494

result:

ok single line: '1485 3659494'

Test #11:

score: 0
Accepted
time: 274ms
memory: 395068kb

input:

5000
v^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^v^^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^v^^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^v^^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^v^^vvv^^...

output:

13 2184

result:

ok single line: '13 2184'

Test #12:

score: 0
Accepted
time: 167ms
memory: 395096kb

input:

5000
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv...

output:

5000 12497500

result:

ok single line: '5000 12497500'

Test #13:

score: 0
Accepted
time: 283ms
memory: 396748kb

input:

5000
v^^vv^vv^^^v^^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^v^^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^v^^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^v^^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^v^^vvv^^vv^v...

output:

13 2580

result:

ok single line: '13 2580'

Test #14:

score: 0
Accepted
time: 154ms
memory: 331316kb

input:

4095
vv^vv^^vvv^^v^^^vv^vv^^^vv^^v^^^vv^vv^^vvv^^v^^vvv^vv^^^vv^^v^^^vv^vv^^vvv^^v^^^vv^vv^^^vv^^v^^vvv^vv^^vvv^^v^^vvv^vv^^^vv^^v^^vvv^vv^^vvv^^v^^^vv^vv^^^vv^^v^^^vv^vv^^vvv^^v^^vvv^vv^^^vv^^v^^vvv^vv^^vvv^^v^^^vv^vv^^^vv^^v^^vvv^vv^^vvv^^v^^vvv^vv^^^vv^^v^^vvv^vv^^vvv^^v^^^vv^vv^^^vv^^v^^^vv^vv^^...

output:

12 0

result:

ok single line: '12 0'

Test #15:

score: 0
Accepted
time: 153ms
memory: 329716kb

input:

4095
v^^vvv^^v^^^vv^^v^^vvv^vv^^^vv^vv^^vvv^^v^^^vv^vv^^vvv^vv^^^vv^vv^^vvv^^v^^^vv^^v^^vvv^vv^^^vv^^v^^vvv^^v^^^vv^vv^^vvv^vv^^^vv^^v^^vvv^^v^^^vv^^v^^vvv^vv^^^vv^vv^^vvv^^v^^^vv^vv^^vvv^vv^^^vv^^v^^vvv^^v^^^vv^^v^^vvv^vv^^^vv^^v^^vvv^^v^^^vv^vv^^vvv^vv^^^vv^vv^^vvv^^v^^^vv^^v^^vvv^vv^^^vv^vv^^vvv^...

output:

12 0

result:

ok single line: '12 0'

Test #16:

score: 0
Accepted
time: 263ms
memory: 395768kb

input:

4994
^vv^^^vvv^vv^vv^^v^^^^vvv^vv^^v^^v^^^vvv^^v^^v^^vvvv^^^vv^vv^vv^^^vvv^vv^vv^^v^^^vvvv^vv^^v^^v^^^vvv^^v^^v^^vv^vv^^^vvv^vv^vv^^v^^^^vvv^vv^^v^^v^^^vvv^^v^^v^^vvvv^vvvvvvv^vv^^vvv^^v^^^^^^^v^^^^vv^vv^vv^^^vvv^vv^vv^^v^^^vvvv^vv^^v^^v^^^vvv^^v^^vv^vv^vv^^^vvv^vv^vv^^v^^^^vvv^vv^^v^^v^^^vvv^^v^^v^...

output:

27 2053

result:

ok single line: '27 2053'

Test #17:

score: 0
Accepted
time: 269ms
memory: 396236kb

input:

4992
v^^^vv^^v^^vvv^vv^^^vv^vv^^vvv^^v^^^vv^vv^^vvv^vv^^^vv^^v^^vvv^^v^^^vv^vv^^vvv^vv^^^vv^vv^^vvv^^v^^^vv^^v^^vvv^vv^^^vv^^v^^vvv^^v^^^vv^vv^^vvv^vv^^^vv^vv^^vvv^^v^^^vv^vv^^vvv^vv^^^vv^^v^^vvv^^v^^^vv^vv^^vvv^vv^^^vv^vv^^vvv^^v^^^vv^^v^^vvv^vv^^^vv^^v^^vvv^^v^^^vv^^v^^vvv^vv^^^vv^vv^^vvv^^v^^^vv^...

output:

14 2351

result:

ok single line: '14 2351'

Test #18:

score: 0
Accepted
time: 273ms
memory: 396556kb

input:

4997
^^v^^^v^^^^^^vvv^^^vv^^^vv^^v^^vv^^vvv^^vvv^^^^vvv^^^vv^^^vv^^vv^vv^^vvv^^vvv^^^vvvvv^^^^vvv^^^vv^^^vv^^v^^vv^^vvv^^vvv^^^vvvv^^^vv^^^vv^^vv^vv^^vvv^^vvv^^^vvvvv^^^^vvv^^^vv^^^vv^^v^^vv^^vvv^^vvv^^^^vvv^^^vv^^^vv^^vv^vv^^vvv^^vvv^^^vvvv^^^^^vvv^^^vv^^^vv^^v^^vv^^vvv^^vvv^^^vvvv^^^vv^^^vv^^vv^vv...

output:

28 671

result:

ok single line: '28 671'

Test #19:

score: 0
Accepted
time: 267ms
memory: 396484kb

input:

4999
^v^^^v^^^^v^v^^v^v^vvvv^vvv^v^vv^^^v^v^^^v^^^vvvv^vvv^v^vvv^^v^v^^^v^^^^v^v^^^vv^^v^^vvv^v^vvvv^vvv^v^vv^^^v^v^^^v^^^^vvv^vvv^v^vvv^^v^v^^^v^^^^v^v^vv^v^vvvv^vvv^v^vv^^^v^v^^^v^^^vvvv^vvv^v^vvv^^v^v^^^v^^^^v^v^^^vvvv^v^vvvv^vvv^v^vv^^^v^v^^^v^^^^vvv^vvv^v^vvv^^v^v^^^v^^^^v^v^^v^v^vvvv^vvv^v^vv^...

output:

35 2652

result:

ok single line: '35 2652'

Test #20:

score: 0
Accepted
time: 273ms
memory: 396564kb

input:

4999
^v^^v^^vvv^^^^^^^^vvvvvvv^^^v^^vvv^^^^^^^vvvvvvvv^^^v^^vvv^^^^^^^^vvvvvvv^^^vv^vvv^^^^^^^vvvvvvvv^^^v^^vvv^^^^^^^^vvvvvvv^^^v^^vvv^^^^^^^vvvvvvvv^^^vv^vvv^^^^^^^^vvvvvvv^^^vv^vvv^^^^^^^vvvvvvvv^^^v^^vvv^^^^^^^^vvvvvvv^^^v^^vvv^^^^^^^vvvvvvvv^^^v^^vvv^^^^^^^^vvvvvvv^^^vv^vvv^^^^^^^vvvvvvvv^^^vv^...

output:

29 5816

result:

ok single line: '29 5816'

Test #21:

score: 0
Accepted
time: 267ms
memory: 395960kb

input:

4999
^^^vv^vv^^^vv^vvv^^v^^vvvv^^^vv^vv^^^^^vv^^^vvvvv^^v^^vvv^^^^vv^vv^^^v^^vvv^^v^^vvvv^^^vv^vv^^^v^vv^vvv^^v^^vvv^^^^vv^vv^^^vv^vvv^^v^^vvvv^^^vv^vv^^^^^vvv^^vvvvv^^v^^vvv^^^^vv^vv^^^v^^vvv^^v^^vvvv^^^vv^vv^^vv^vv^^^v^^vv^^v^^vvv^^^^vv^vv^^^vv^vvv^^v^^vvvv^^^vv^vv^^^^^vv^^^vvvvv^^v^^vvv^^^^vv^vv^...

output:

21 1650

result:

ok single line: '21 1650'

Test #22:

score: 0
Accepted
time: 269ms
memory: 396440kb

input:

4991
^^vv^vv^^^vv^^v^^vvv^vv^^^vv^^v^^^vv^vv^^vvv^^v^^vvv^vv^^vvv^^v^^^vv^vv^^^vv^^v^^vvv^vv^^vvv^^v^^^vv^vv^^vvv^^v^^vvv^vv^^vvv^^v^^^vv^vv^^^vv^^v^^vvv^vv^^^vv^^v^^^vv^vv^^vvv^^v^^vvv^vv^^^vv^^v^^^vv^vv^^^vv^^v^^vvv^vv^^vvv^^v^^^vv^vv^^vvv^^v^^vvv^vv^^^vv^^v^^^vv^vv^^^vv^^v^^vvv^vv^^^vv^^v^^^vv^vv...

output:

13 2490

result:

ok single line: '13 2490'

Test #23:

score: 0
Accepted
time: 166ms
memory: 396780kb

input:

5000
^^^v^v^vv^^vv^^v^v^vvvv^^^vv^^vvvvvv^vvvvvvvvvvvv^vvvvvv^^^^v^vv^vvv^^v^^^^v^vvvvvvv^^v^vv^^vvvvvv^vv^^v^^^^^v^^vv^vvvv^^vvv^^^vvvvv^v^vv^^vvv^v^v^vvvv^vvv^^^vv^v^vvv^^^v^^vv^vv^^v^^^^vvvv^vvv^^vv^vv^v^v^vvv^vvv^^^v^vv^^v^^vv^vvv^^v^^vvv^vvv^vv^^v^v^vvv^^^^vv^v^vvvvv^vvv^^vvvvv^v^^vv^^^^^^^v^^v...

output:

2264 5574395

result:

ok single line: '2264 5574395'

Test #24:

score: 0
Accepted
time: 266ms
memory: 396796kb

input:

4996
v^^^v^^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^v^^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^v^^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^v^^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^v^^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^vv^...

output:

13 2218

result:

ok single line: '13 2218'

Test #25:

score: 0
Accepted
time: 275ms
memory: 395420kb

input:

4995
vvv^^vv^vv^^^v^^vvv^^vv^vvv^^v^^vv^^^vv^vv^^^v^^vvv^^vv^vvv^^v^^vvv^^vv^vv^^^v^^vv^^^vv^vvv^^v^^vv^^^vv^vv^^^v^^vv^^^vv^vvv^^v^^vvv^^vv^vv^^^v^^vv^^^vv^vvv^^v^^vv^^^vv^vv^^^v^^vvv^^vv^vvv^^v^^vvv^^vv^vv^^^v^^vvv^^vv^vvv^^v^^vv^^^vv^vv^^^v^^vv^^^vv^vvv^^v^^vvv^^vv^vv^^^v^^vv^^^vv^vvv^^v^^vv^^^vv...

output:

13 2575

result:

ok single line: '13 2575'

Test #26:

score: 0
Accepted
time: 274ms
memory: 395140kb

input:

4999
vvv^^v^^vv^^^vv^vvv^^v^^vvv^^vv^vv^^^v^^vv^^^vv^vv^^^v^^vvv^^vv^vvv^^v^^vv^^^vv^vvv^^v^^vvv^^vv^vvv^^v^^vv^^^vv^vv^^^v^^vvv^^vv^vvv^^v^^vv^^^vv^vvv^^v^^vvv^^vv^vv^^^v^^vv^^^vv^vv^^^v^^vvv^^vv^vv^^^v^^vv^^^vv^vvv^^v^^vvv^^vv^vvv^^v^^vv^^^vv^vv^^^v^^vvv^^vv^vv^^^v^^vv^^^vv^vvv^^v^^vvv^^vv^vv^^^v^...

output:

13 1662

result:

ok single line: '13 1662'

Test #27:

score: 0
Accepted
time: 276ms
memory: 395544kb

input:

4996
vv^^^vv^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^v^^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^v^^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^v^^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^v^^vvv^^v^^vv^^^vv^vvv^^vv^vv^^^vv^vvv^^v^^vv^^^v^...

output:

13 2457

result:

ok single line: '13 2457'

Test #28:

score: 0
Accepted
time: 271ms
memory: 395988kb

input:

4997
vv^^^vv^^v^^vvv^vv^^^vv^vv^^vvv^^v^^^vv^^v^^vvv^^v^^^vv^vv^^vvv^vv^^^vv^^v^^vvv^vv^^^vv^vv^^vvv^vv^^^vv^^v^^vvv^^v^^^vv^vv^^vvv^^v^^^vv^^v^^vvv^vv^^^vv^vv^^vvv^^v^^^vv^^v^^vvv^^v^^^vv^vv^^vvv^vv^^^vv^^v^^vvv^vv^^^vv^vv^^vvv^vv^^^vv^^v^^vvv^^v^^^vv^vv^^vvv^vv^^^vv^^v^^vvv^vv^^^vv^vv^^vvv^^v^^^vv...

output:

13 2235

result:

ok single line: '13 2235'

Test #29:

score: 0
Accepted
time: 272ms
memory: 396384kb

input:

4991
^vv^^^vv^^v^^vvv^vv^^^vv^^v^^^vv^vv^^^vv^^v^^vvv^vv^^vvv^^v^^^vv^vv^^^vv^^v^^vvv^vv^^^vv^^v^^^vv^vv^^vvv^^v^^vvv^vv^^vvv^^v^^^vv^vv^^^vv^^v^^vvv^vv^^^vv^^v^^^vv^vv^^^vv^^v^^vvv^vv^^vvv^^v^^^vv^vv^^vvv^^v^^vvv^vv^^^vv^^v^^^vv^vv^^vvv^^v^^vvv^vv^^vvv^^v^^^vv^vv^^vvv^^v^^vvv^vv^^^vv^^v^^^vv^vv^^^v...

output:

13 1932

result:

ok single line: '13 1932'

Test #30:

score: 0
Accepted
time: 262ms
memory: 396700kb

input:

4991
v^^v^^vvv^^vv^vv^^^v^^vv^^^vv^vvv^^v^^vvv^^vv^vvv^^v^^vv^^^vv^vvv^^v^^vvv^^vv^vv^^^v^^vv^^^vv^vv^^^v^^vvv^^vv^vvv^^v^^vv^^^vv^vv^^^v^^vvv^^vv^vv^^^v^^vv^^^vv^vvv^^v^^vvv^^vv^vvv^^v^^vv^^^vv^vvv^^v^^vvv^^vv^vv^^^v^^vv^^^vv^vv^^^v^^vvv^^vv^vvv^^v^^vv^^^vv^vvv^^v^^vvv^^vv^vv^^^v^^vv^^^vv^vvv^^v^^v...

output:

13 2369

result:

ok single line: '13 2369'

Test #31:

score: 0
Accepted
time: 170ms
memory: 396692kb

input:

5000
^vvvvvvv^^vvv^^^v^^v^vvv^v^^^vv^^vvvvvv^^^vvv^^^v^^vvv^^^v^v^v^vv^v^^v^v^v^^v^^^vv^vvv^^^v^vvvvv^v^vvvvvvvvv^^^^v^vv^^vvv^v^vvvv^v^vv^^^^^^vv^^^^^^vv^vv^v^^^v^v^^^^^v^^v^^^^^vvvvv^vvv^v^^vv^v^^vvvvv^^^^vv^vvv^^v^v^^vv^vv^^^^v^vv^^v^^^v^^^^^^^v^v^vv^^^v^^^v^^vv^^^v^^^^^v^^^v^^vvvvv^v^^^v^vvv^v^v...

output:

2188 5310449

result:

ok single line: '2188 5310449'

Test #32:

score: 0
Accepted
time: 174ms
memory: 395660kb

input:

5000
^vv^^^^^^vv^vv^v^^vv^^^vv^v^v^^^^^^^^v^^vvv^v^^^^v^v^^^^^^^v^^^vv^^vvv^v^^^^vv^^vvvv^v^^^^^vvvvvv^vv^^^v^vvvvv^vvv^^^^v^vvvv^^^^^^^v^vvvvvv^v^^^^^vvvvv^v^^^^v^^^v^vv^vv^vvv^v^^^v^vv^v^^v^^v^vv^vvvv^^^vv^vvv^^^^vv^^^vv^v^v^v^vvvv^^^vv^^^vvvvvvv^v^vvvv^^^vv^v^^v^v^vvv^vvv^vvvvvv^v^^vvvvv^^vv^vv^v...

output:

2146 5271567

result:

ok single line: '2146 5271567'

Test #33:

score: 0
Accepted
time: 171ms
memory: 396208kb

input:

5000
^v^v^v^vvvvvvvv^^v^v^^vv^^v^^^v^v^^^v^v^^vvvvv^vvv^^^^v^^^vvvvv^^v^v^v^^^v^v^^vv^^v^^^^v^v^vv^v^^v^^v^^vv^^vv^^^vvvv^v^vvv^^vv^v^^^^^vvvv^v^^^vv^vv^vvv^v^^vv^v^^^v^v^^^^vv^v^^^v^^^vv^vvv^^^v^vvvv^^v^^^^v^vv^v^v^^^vvvv^v^^^v^^^vv^^v^v^^^vv^v^^v^^^v^v^vvvv^vvvvv^v^vv^^^v^^v^^^^^v^v^^^^v^v^^v^^v^^...

output:

2213 5408180

result:

ok single line: '2213 5408180'

Test #34:

score: 0
Accepted
time: 164ms
memory: 395900kb

input:

5000
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^v^^^^^^^^v^^^^^^v^^^^^^^^^^^v^^^^^^^^^^^^^^^^^^^^^^^^^^v^^^^^^^^v^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^v^^v^^^^^^vv^^^^^^^v^^^^^^^^^v^^^^^v^v^^^^^^^^^^^^v^^^^^^^^^^^^v^^v^^^^^^v^^^^^^^^^^^^^^^v^^^v^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^v^^^^^^^v^^^^^^^^^^^^^^^v^^^^^^...

output:

4115 10169791

result:

ok single line: '4115 10169791'

Test #35:

score: 0
Accepted
time: 163ms
memory: 395208kb

input:

4995
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^v^^v^^^^^^^^v^^v^^^^^^^^^^^^^^^^^^^v^v^^^^^^^^^^v^^^^^^^^^v^^v^^v^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^v^v^^^^^v^^^^^^^^v^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^v^^^^^^^v^^^v^^^^^^^^^^^^v^^^^^v^^^^^^^^^^^^^^^^^^^v^^^^^^^^^^^^^^...

output:

4082 10186253

result:

ok single line: '4082 10186253'

Test #36:

score: 0
Accepted
time: 165ms
memory: 396376kb

input:

5000
^^^v^^^^v^v^^v^^^^vvv^^^vv^^v^^^^vv^^^^^^^^v^v^^^^^^v^^v^v^v^v^^vv^^v^^^^v^^^^^^^v^v^v^^^^^^^^v^v^^^^^^^v^^v^v^^^^v^^^^^v^^^^^^vvv^^v^vv^^vvv^v^vvv^^^vvv^^^v^^^^^vv^^^^^v^v^v^^^^^^v^v^^^vv^^^^^^^^vv^^vv^v^^v^^v^v^^^^^^^^^^^^v^^v^v^^v^^^^^^vvv^^^^^^^^^^vv^v^^vv^v^vv^^v^^v^^^^^^^v^^vv^v^^^^vv^^vv...

output:

2753 6808711

result:

ok single line: '2753 6808711'