QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#286509 | #7963. 多折较差验证 | ucup-team022 | AC ✓ | 470ms | 322476kb | C++17 | 1.5kb | 2023-12-17 23:01:26 | 2023-12-17 23:01:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=5005;
char s[N];
int n;
bool vis[N][N];
vector<int>L[N],R[N];
int f[N][N];
long long g[N][N];
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>n>>(s+1);
for(int i=1;i<=n;++i)vis[i][i]=1,L[i].emplace_back(i),R[i].emplace_back(i);
for(int i=n;i;--i)
for(int j=i+2;j<=n;j+=2){
vis[i][j]=vis[i+1][j-1]&&(s[i]!=s[j]);
if(vis[i][j]){
L[i].emplace_back(j);
R[j].emplace_back(i);
}
}
memset(f,0x3f,sizeof f);
memset(g,0x3f,sizeof g);
for(int i=1;i<=n;++i){
f[i][i]=1,g[i][i]=0;
f[i+1][i]=0,g[i+1][i]=0;
}
f[1][0]=g[1][0]=0;
for(int i=n;i;--i)
for(int j=i+1;j<=n;j+=1){
for(int k:L[i]){
if(k>j)break;
int m=(i+k)/2;
if(f[i][j]>f[m+1][j]+1)
f[i][j]=f[m+1][j]+1,g[i][j]=g[m+1][j]+j-m-m+i;
else if(f[i][j]==f[m+1][j]+1)
g[i][j]=min(g[i][j],g[m+1][j]+(j-m-m+i));
}
for(int k:R[j]){
if(k<i)break;
int m=(k+j)/2;
if(f[i][j]>f[i][m-1]+1)
f[i][j]=f[i][m-1]+1,g[i][j]=g[i][m-1]-(j-m-m+i);
else if(f[i][j]==f[i][m-1]+1)
g[i][j]=min(g[i][j],g[i][m-1]-(j-m-m+i));
}
}
cout<<f[1][n]<<" "<<g[1][n]<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 71ms
memory: 321956kb
input:
5000 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^...
output:
5000 12497500
result:
ok single line: '5000 12497500'
Test #2:
score: 0
Accepted
time: 149ms
memory: 322028kb
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: 130ms
memory: 322084kb
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: 136ms
memory: 321888kb
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: 93ms
memory: 321996kb
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: 91ms
memory: 322028kb
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: 167ms
memory: 322112kb
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: 168ms
memory: 322028kb
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: 169ms
memory: 322016kb
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: 322204kb
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: 431ms
memory: 322460kb
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: 79ms
memory: 321984kb
input:
5000 vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv...
output:
5000 12497500
result:
ok single line: '5000 12497500'
Test #13:
score: 0
Accepted
time: 451ms
memory: 322436kb
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: 289ms
memory: 319000kb
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: 291ms
memory: 319464kb
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: 319ms
memory: 322116kb
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: 390ms
memory: 322440kb
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: 367ms
memory: 322288kb
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: 279ms
memory: 322304kb
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: 336ms
memory: 322096kb
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: 351ms
memory: 322212kb
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: 428ms
memory: 322476kb
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: 159ms
memory: 322128kb
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: 459ms
memory: 322296kb
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: 442ms
memory: 322336kb
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: 443ms
memory: 322376kb
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: 441ms
memory: 322292kb
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: 470ms
memory: 322248kb
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: 428ms
memory: 322276kb
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: 458ms
memory: 322392kb
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: 166ms
memory: 321996kb
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: 322052kb
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: 163ms
memory: 321944kb
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: 96ms
memory: 322108kb
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: 94ms
memory: 322180kb
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: 149ms
memory: 322012kb
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'