QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623781#7057. Digital Pathbright_ml#AC ✓182ms106236kbC++201.9kb2024-10-09 13:59:192024-10-09 13:59:20

Judging History

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

  • [2024-10-09 13:59:20]
  • 评测
  • 测评结果:AC
  • 用时:182ms
  • 内存:106236kb
  • [2024-10-09 13:59:19]
  • 提交

answer

//
// Created by 35395 on 2024/10/9.
//
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1010;
int dp[N][N][5];

int a[N][N];
const int mod=1e9+7;
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>a[i][j];
        }
    }
    memset(dp,-1,sizeof dp);
    int dir[4][2]={0,1,1,0,-1,0,0,-1};
    auto dfs=[&](auto &&self,int x,int y,int z){
        if(dp[x][y][z]!=-1)return dp[x][y][z];
        if(z==0)return dp[x][y][z]=0;
        int res=0;
        dp[x][y][z]=0;
        for(int i=0;i<4;i++){
            int xx=x+dir[i][1];
            int yy=y+dir[i][0];
            if(xx<1||xx>n||yy<1||yy>m)continue;
            if(a[xx][yy]!=a[x][y]+1)continue;
            res++;
            if(z!=1)dp[x][y][z]=(self(self,xx,yy,z-1)+dp[x][y][z])%mod;
            if(z==4)dp[x][y][z]=(self(self,xx,yy,z)+dp[x][y][z])%mod;
        }
        if(res==0&&z==1)return dp[x][y][z]=1;
        return dp[x][y][z];
    };
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            for(int k=1;k<=4;k++){
                dfs(dfs,i,j,k);
            }
        }
    }
//    for(int i=1;i<=n;i++){
//        for(int j=1;j<=m;j++){
//            cout<<dp[i][j][4]<<' ';
//        }
//        cout<<endl;
//    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            int flag=0;
            for(int c=0; c < 4; c++){
                int xx=i+dir[c][1];
                int yy=j+dir[c][0];
                if(xx<1||xx>n||yy<1||yy>m)continue;
                if(a[xx][yy]!=a[i][j]-1)continue;
                flag=1;
            }
            if(flag==0){
//                cout<<i<<' '<<j<<endl;
                ans+=dp[i][j][4];
            }
            ans%=mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 5
1 2 3 8 7
-1 -1 4 5 6
1 2 3 8 7

output:

4

result:

ok single line: '4'

Test #2:

score: 0
Accepted
time: 8ms
memory: 45008kb

input:

4 4
1 2 3 4
2 3 4 3
3 4 3 2
4 3 2 1

output:

16

result:

ok single line: '16'

Test #3:

score: 0
Accepted
time: 146ms
memory: 106236kb

input:

1000 1000
1000000 99999 99998 99997 99996 99995 99994 99993 99992 99991 99990 99989 99988 99987 99986 99985 99984 99983 99982 99981 99980 99979 99978 99977 99976 99975 99974 99973 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99954 99953 ...

output:

990039586

result:

ok single line: '990039586'

Test #4:

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

input:

146 237
1 1 1 1 1 1 2 3 4 5 1 1 4 1 1 2 3 1 1 1 2 1 1 1 4 1 1 2 3 4 5 6 7 1 1 1 1 2 3 1 2 3 1 2 3 6 7 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 2 3 1 2 3 1 1 2 1 1 1 2 1 2 3 4 1 1 1 2 1 2 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 2 3 4 5 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 2 1 1 1 1 2 3 1 1 1 1 ...

output:

152287

result:

ok single line: '152287'

Test #5:

score: 0
Accepted
time: 17ms
memory: 45308kb

input:

211 597
1 1 2 1 2 3 4 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 2 1 2 3 1 1 1 1 1 2 3 4 1 4 5 6 1 2 1 2 1 1 1 1 2 3 6 1 1 2 1 2 1 1 1 1 1 1 2 1 2 1 1 2 1 2 1 1 1 2 3 4 1 1 2 1 1 2 1 1 1 1 1 1 2 1 4 5 1 2 3 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 3 4 1 1 1 2 3 1 2 1 2 3 1 1 1 1 1 ...

output:

399561

result:

ok single line: '399561'

Test #6:

score: 0
Accepted
time: 23ms
memory: 47368kb

input:

231 551
1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 2 3 1 1 1 1 2 1 1 9 8 1 2 1 1 1 1 1 1 2 3 1 1 2 1 1 1 1 2 1 1 1 2 3 1 1 1 2 1 1 1 1 1 2 1 1 2 1 2 1 1 1 1 1 1 1 1 1 6 1 2 3 4 1 1 2 1 1 2 1 1 1 1 2 3 1 1 2 1 6 1 2 5 6 1 1 2 3 1 2 3 4 1 1 2 1 1 1 2 1 1 2 1 2 1 2 3 1 1 2 1 6 7 1 2 1 1 2 1 1 1 1 2 1 1 2 1 ...

output:

1188595

result:

ok single line: '1188595'

Test #7:

score: 0
Accepted
time: 28ms
memory: 47372kb

input:

342 549
1 1 1 1 1 1 1 1 1 2 3 1 1 2 1 1 1 1 1 2 5 1 1 2 3 4 1 2 1 1 2 1 1 1 2 1 1 2 1 1 2 3 1 2 3 1 2 3 1 1 1 1 1 2 3 6 1 1 1 1 4 1 4 5 6 7 8 1 1 2 3 1 1 1 2 3 4 5 6 7 1 1 1 1 1 1 1 2 3 1 1 1 1 1 1 1 2 3 4 1 1 1 2 3 4 5 6 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 2 1 1 1 2 3 4 1 1 1 1 1 1 1 1 5 6 1 1 1 1 1 1 1 ...

output:

628608

result:

ok single line: '628608'

Test #8:

score: 0
Accepted
time: 11ms
memory: 46880kb

input:

352 26
1 2 3 1 1 2 3 1 1 2 1 1 1 1 1 1 2 3 1 4 1 1 1 1 1 1
1 1 4 5 1 1 4 1 1 3 4 5 6 3 2 4 3 1 2 3 4 1 1 1 1 2
1 1 1 6 2 6 5 1 13 1 9 8 7 4 3 1 1 1 2 6 5 1 2 1 1 3
2 1 1 2 3 7 6 1 12 11 10 1 1 5 6 2 1 1 1 7 1 1 3 1 2 4
1 1 1 1 4 8 1 2 13 1 11 1 9 8 7 1 1 12 11 8 1 2 4 5 1 2
3 2 3 4 1 1 1 1 1 2 3 11 ...

output:

10827

result:

ok single line: '10827'

Test #9:

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

input:

365 252
1 1 1 1 1 1 1 2 1 1 2 1 2 1 1 1 1 1 1 2 3 6 1 1 4 5 1 2 3 1 1 1 1 1 2 1 2 1 1 1 1 2 3 1 1 1 1 1 1 1 1 1 2 3 1 2 3 4 5 1 1 1 2 1 1 1 1 1 1 2 3 1 2 1 1 1 1 1 1 2 1 1 1 2 3 1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 2 1 2 3 4 5 6 1 2 3 1 1 1 1 1 1 2 3 4 5 1 1 1 2 1 1 1 2 1 2 3 4 5 ...

output:

166369

result:

ok single line: '166369'

Test #10:

score: 0
Accepted
time: 24ms
memory: 46860kb

input:

185 914
1 1 1 1 1 1 1 1 1 2 3 4 1 1 9 1 1 1 1 1 1 1 2 1 1 2 3 4 5 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 3 1 1 2 1 2 1 1 1 1 2 1 2 3 1 1 1 1 2 3 4 1 1 1 2 3 4 1 2 1 1 2 1 2 3 4 1 2 1 2 3 1 1 1 1 2 1 1 1 1 2 1 2 1 1 2 3 4 1 2 1 1 1 1 1 1 2 1 1 1 2 1 2 7 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 2 3 1 1 1 2 1 1 ...

output:

486846

result:

ok single line: '486846'

Test #11:

score: 0
Accepted
time: 28ms
memory: 47260kb

input:

381 458
1 1 2 3 1 1 2 3 4 5 1 2 3 4 5 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 2 1 2 1 2 3 4 1 1 1 1 2 3 1 2 1 1 2 3 4 1 2 3 4 1 2 1 1 2 1 1 1 2 3 4 1 2 1 1 1 1 1 1 2 3 4 7 1 1 1 4 5 1 1 1 1 1 2 3 4 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 1 1 2 5 6 7 1 2 1 1 1 2 3 1 2 1 1 1 1 1 1 2 1 1 2 3 1 2 3 4 1 1 1 1 1 ...

output:

877099

result:

ok single line: '877099'

Test #12:

score: 0
Accepted
time: 20ms
memory: 49340kb

input:

401 412
1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 1 2 1 2 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 2 3 1 1 1 2 1 2 1 1 1 1 1 5 6 1 1 1 1 2 1 1 2 5 6 7 8 1 1 1 1 1 2 3 1 1 2 3 1 1 1 1 2 1 1 1 1 4 5 1 1 1 2 3 4 1 2 1 1 2 1 2 1 2 1 1 1 1 1 1 1 1 1 1 2 3 4 1 ...

output:

710978

result:

ok single line: '710978'

Test #13:

score: 0
Accepted
time: 38ms
memory: 47428kb

input:

414 638
1 1 1 1 1 2 3 4 1 1 1 1 2 3 4 5 8 9 1 1 1 1 1 1 2 3 4 5 1 1 1 1 2 5 1 1 1 1 2 3 4 5 6 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 2 1 1 1 1 2 3 1 1 1 2 3 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 4 1 1 1 2 3 1 1 2 1 1 1 1 1 2 3 1 1 1 1 2 3 1 2 1 1 1 1 4 5 6 1 1 1 4 1 2 1 1 1 1 1 1 1 1 1 1 1 ...

output:

3603480

result:

ok single line: '3603480'

Test #14:

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

input:

424 115
1 1 1 1 1 2 1 1 2 3 1 1 1 2 3 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 8 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 2 3 1 1 1 1 2 3 4 1 1 1 1 1 2 1 2 1 1 1 1 2 3 6 1 1 1 1 1 1 9 1 2 3 4 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 2 3 4 5 1 1 1 2
1 2 3 1 2 3 2 3 1 2 3 2 1 1 4 5 2 2 2 1 2 3 4 5 2 2 1 1 1 1 1 ...

output:

229311

result:

ok single line: '229311'

Test #15:

score: 0
Accepted
time: 40ms
memory: 49424kb

input:

437 573
1 1 2 1 1 2 3 1 1 2 3 4 1 1 7 8 9 1 1 1 1 2 1 1 1 2 1 1 2 3 1 1 1 1 1 1 1 1 2 1 1 1 1 2 3 4 1 1 1 4 1 2 3 4 1 2 3 1 1 2 1 2 5 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 2 3 1 2 1 1 1 1 1 1 1 2 3 4 5 6 13 12 1 1 1 1 1 1 2 3 4 1 2 1 2 1 2 1 2 1 4 1 2 1 2 3 4 1 1 1 2 1 1 2 1 1 1 1 2 1 1 1 2 5 1 ...

output:

1124492

result:

ok single line: '1124492'

Test #16:

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

input:

446 50
1 2 3 4 1 1 2 1 6 7 8 1 1 1 2 1 1 2 1 2 1 4 1 1 1 1 1 1 1 2 1 2 5 1 1 2 3 4 1 1 2 1 1 2 1 1 1 1 1 1
1 2 3 3 2 7 3 4 5 1 1 1 1 1 2 1 1 3 4 3 2 3 4 2 3 2 2 2 1 2 1 3 4 1 2 3 4 5 6 1 1 2 3 1 2 2 1 2 2 5
1 1 1 4 5 6 4 5 6 7 2 2 3 1 3 2 2 4 5 1 1 1 5 6 7 8 11 12 13 3 4 5 1 2 3 4 9 10 11 2 1 3 4 5 ...

output:

31752

result:

ok single line: '31752'

Test #17:

score: 0
Accepted
time: 31ms
memory: 49428kb

input:

456 527
1 1 1 2 1 2 3 1 2 1 2 1 1 1 2 5 6 7 1 1 1 4 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 4 13 1 2 3 4 7 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 3 1 1 1 1 1 2 3 1 1 1 1 1 1 1 2 1 1 1 2 3 1 2 3 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 2 1 2 3 1 2 1 2 1 2 1 2 1 1 1 2 3 4 1 6 1 1 1 1 1 1 1 1 1 2 3 4 1 1 1 1 1 1...

output:

743785

result:

ok single line: '743785'

Test #18:

score: 0
Accepted
time: 5ms
memory: 49312kb

input:

466 4
1 2 3 4
1 1 1 5
2 1 1 6
1 1 1 1
2 3 1 1
1 4 1 2
1 2 1 1
4 3 1 2
5 4 1 1
1 5 2 1
1 2 3 1
1 1 4 5
2 1 2 1
1 4 3 2
10 5 6 3
9 8 7 8
1 1 1 9
1 2 11 10
1 3 4 5
2 1 1 2
3 2 1 3
1 2 2 1
1 1 3 1
1 2 4 5
2 10 7 6
1 9 8 1
2 1 1 2
3 4 1 1
4 5 6 1
9 8 7 8
10 1 8 9
11 2 1 10
1 2 1 1
1 3 1 1
1 4 2 1
1 5 6 1...

output:

719

result:

ok single line: '719'

Test #19:

score: 0
Accepted
time: 80ms
memory: 49356kb

input:

482 978
1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 2 1 4 5 1 2 3 1 1 1 1 1 1 1 1 1 1 4 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 2 3 4 5 1 1 1 1 2 3 6 7 1 1 1 1 1 1 1 1 2 3 4 5 1 1 1 1 1 2 3 6 7 8 1 1 1 1 1 1 1 2 3 1 1 1 1 2 3 1 1 2 3 1 1 2 1 1 1 1 1 2 3 1 1 4 5 1 2 1 1 1 2 3 4 1 2 3 1 1 1 1 1 1 1 2 1 1 2 1 1 2 1 2 1 1 ...

output:

1819069

result:

ok single line: '1819069'

Test #20:

score: 0
Accepted
time: 15ms
memory: 48856kb

input:

499 185
1 1 1 1 1 2 3 4 5 8 1 1 1 2 1 2 1 2 3 4 5 6 1 1 1 1 2 3 4 1 1 1 1 1 1 1 1 2 3 1 1 2 1 1 2 3 1 1 2 3 1 1 1 1 1 1 1 1 4 1 2 3 1 1 2 3 4 5 6 7 1 1 1 1 1 1 1 2 1 1 2 1 2 1 1 1 1 1 1 2 1 1 2 3 1 1 2 1 1 1 1 2 6 7 10 11 12 13 14 15 1 1 1 1 1 1 1 2 3 4 5 6 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 2 1 1 2 3 ...

output:

521236

result:

ok single line: '521236'

Test #21:

score: 0
Accepted
time: 11ms
memory: 49208kb

input:

518 139
1 1 1 1 1 1 1 1 1 1 2 3 4 1 1 1 1 1 1 1 1 2 3 4 1 1 1 1 4 1 4 5 1 1 2 1 1 1 1 2 1 1 1 2 1 1 2 5 1 2 1 1 2 1 2 3 1 1 1 1 2 1 1 2 1 1 2 3 1 1 1 4 5 6 1 2 3 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 3 7 1 1 1 1 1 1 1 1 1 1 2 3 4 1 1 9 1 1 1 1 1 1 1 2 1 1 2 3 4 5 1 1 1
1 1 1 1 2 1 1 ...

output:

252133

result:

ok single line: '252133'

Test #22:

score: 0
Accepted
time: 59ms
memory: 49488kb

input:

541 842
1 2 1 2 1 4 1 1 1 2 3 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 1 1 2 3 1 2 3 1 1 1 2 3 1 1 2 1 2 5 6 7 10 11 12 13 1 1 1 1 2 1 2 3 6 1 2 3 1 2 1 2 1 1 2 1 1 2 1 1 1 2 1 2 1 1 1 1 2 1 2 1 1 1 1 2 3 4 1 1 2 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 1 1 1 1 1 2 1 1 1 1 2 1 2 3 1 1 1 2 1 1 2 3 1 1 ...

output:

16501983

result:

ok single line: '16501983'

Test #23:

score: 0
Accepted
time: 36ms
memory: 51512kb

input:

587 479
1 1 1 1 1 1 2 3 4 1 2 3 1 2 1 2 3 4 1 1 6 1 1 1 1 2 1 1 1 2 5 1 1 2 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 2 3 4 5 6 1 2 1 2 1 1 1 1 1 1 1 4 5 1 1 1 1 1 2 3 1 2 1 1 1 1 1 1 2 1 1 2 3 4 5 6 1 1 2 5 6 7 1 1 1 2 3 4 5 6 7 1 1 2 3 1 2 3 1 1 1 1 1 2 1 1 1 2 1 1 2 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1 4 ...

output:

1050750

result:

ok single line: '1050750'

Test #24:

score: 0
Accepted
time: 44ms
memory: 49364kb

input:

606 434
1 1 1 2 3 1 1 1 1 2 1 1 1 2 1 1 2 1 1 1 1 1 2 1 1 1 1 2 3 4 1 1 1 1 1 1 1 1 2 1 1 2 1 1 2 3 4 5 6 1 1 1 1 1 2 3 4 5 6 1 1 1 1 1 1 1 2 1 1 2 1 1 2 3 1 1 2 3 1 1 4 1 2 1 1 1 1 1 1 2 1 1 1 2 3 4 1 1 2 3 1 1 1 1 2 1 1 2 1 1 1 1 2 1 2 3 1 2 3 4 5 6 1 1 1 2 1 1 1 1 2 3 1 1 1 2 3 4 1 1 1 1 1 1 1 1 ...

output:

2497507

result:

ok single line: '2497507'

Test #25:

score: 0
Accepted
time: 57ms
memory: 49416kb

input:

619 660
1 1 1 1 2 1 1 1 2 3 6 7 1 2 3 4 1 2 1 2 1 1 1 1 1 1 2 3 4 1 4 5 1 1 1 1 2 1 1 1 2 1 2 3 1 2 3 1 4 1 1 2 1 2 1 1 1 8 9 1 2 1 2 3 4 1 2 1 1 1 1 2 1 1 1 2 3 1 1 2 1 2 3 1 1 2 3 1 2 1 1 2 3 4 1 1 2 3 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 5 1 2 1 1 1 1 1 2 1 1 1 2 3 1 1 2 1 1 1 2 1 2 3 4 5 1 1 1 1 2 1 ...

output:

2575280

result:

ok single line: '2575280'

Test #26:

score: 0
Accepted
time: 29ms
memory: 51412kb

input:

662 317
1 1 1 1 2 3 4 5 1 4 5 1 1 1 1 1 2 3 1 1 1 1 1 2 3 4 5 6 7 1 1 1 1 1 2 3 4 1 1 2 1 1 1 1 2 1 1 2 1 1 1 2 3 4 5 1 1 2 3 1 1 1 1 1 1 2 3 1 1 2 1 1 1 1 1 2 1 1 2 3 1 1 2 1 1 1 1 2 1 1 1 2 1 1 1 1 5 1 2 1 1 1 1 1 2 3 4 1 1 1 1 2 3 4 5 8 9 1 1 1 1 1 1 2 3 4 5 1 1 1 1 2 5 1 1 1 1 2 3 4 5 6 1 2 1 1 ...

output:

1208698

result:

ok single line: '1208698'

Test #27:

score: 0
Accepted
time: 69ms
memory: 51400kb

input:

675 774
1 2 3 4 1 1 2 1 1 1 1 2 3 4 1 1 1 2 1 1 2 3 4 5 1 2 1 2 1 1 1 1 1 1 5 6 7 8 9 10 1 2 3 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 2 3 4 5 6 1 1 1 2 3 1 1 2 1 1 2 1 2 1 1 1 1 1 1 1 1 1 2 3 4 1 1 1 4 5 1 1 2 1 1 1 1 2 3 4 1 1 2 1 1 2 1 1 7 8 1 2 3 4 1 2 3 1 2 3 4 5 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 1...

output:

5057023

result:

ok single line: '5057023'

Test #28:

score: 0
Accepted
time: 95ms
memory: 51400kb

input:

688 1000
1 1 1 2 1 2 3 4 5 1 1 1 1 1 1 1 2 1 2 1 2 3 1 1 2 1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 2 3 1 1 2 3 1 2 1 1 1 4 5 6 7 1 1 1 1 2 5 6 7 1 2 3 4 5 1 1 2 1 2 1 1 2 3 1 1 2 1 1 2 3 4 1 1 1 1 2 3 1 1 4 5 6 7 8 9 10 1 2 1 1 1 1 1 1 1 2 3 4 5 1 1 1 2 3 4 5 1 1 2 5 1 1 1 1 2 1 1 1 1 1 2 ...

output:

2728795

result:

ok single line: '2728795'

Test #29:

score: 0
Accepted
time: 95ms
memory: 51460kb

input:

708 955
1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 2 1 1 2 3 4 5 1 1 1 2 1 2 1 1 1 2 1 1 4 5 6 7 8 1 1 1 1 1 2 7 6 1 1 1 1 1 2 1 1 2 3 1 2 1 2 5 6 1 2 1 1 1 2 1 1 1 2 3 1 2 1 1 1 2 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 2 1 1 1 2 3 1 2 1 1 1 1 1 4 1 1 1 1 1 1 2 3 1 1 2 3 4 5 1 1 1 2 3 6 1 2 3 ...

output:

5201757

result:

ok single line: '5201757'

Test #30:

score: 0
Accepted
time: 17ms
memory: 50900kb

input:

724 161
1 1 1 2 3 4 5 6 9 10 1 1 1 1 1 2 3 4 1 2 1 2 1 2 3 1 1 1 1 1 1 1 2 3 1 2 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 2 3 6 7 8 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 3 4 1 1 1 2 3 8 7 8 9 10 11 12 1 1 1 2 3 4 1 1 1 2 1 1 2 1 1 1 1 1 2 1 1 1 2 1 1 2 5 1 1 2 3 4 1 1 2 3 1 1 1 1 2 3 1 2 1 1 1 1 1 1 1 1 ...

output:

656364

result:

ok single line: '656364'

Test #31:

score: 0
Accepted
time: 39ms
memory: 51220kb

input:

737 386
1 1 2 3 1 1 1 1 1 2 1 2 1 1 1 2 3 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 2 5 6 1 1 1 2 3 4 1 1 1 1 2 1 1 1 1 2 1 1 2 1 2 1 2 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 2 3 6 1 1 2 3 1 1 1 1 1 1 2 1 1 1 2 1 2 3 4 5 1 1 1 1 2 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 3 1 2 3 1 1 2 1 1 1 ...

output:

809816

result:

ok single line: '809816'

Test #32:

score: 0
Accepted
time: 63ms
memory: 51472kb

input:

753 592
1 1 4 1 1 1 1 1 1 1 1 1 1 4 5 6 1 2 1 1 1 1 1 1 1 2 1 1 1 2 3 4 1 2 3 4 5 1 1 2 3 1 2 3 4 5 6 7 14 13 1 2 3 4 5 8 9 10 1 1 2 3 8 1 1 1 1 2 3 1 1 1 4 1 1 1 2 3 1 1 2 1 1 1 1 1 2 1 1 1 2 1 2 1 1 1 2 3 4 5 1 1 1 1 1 4 1 1 1 1 2 3 4 1 2 1 2 3 1 1 1 1 1 1 1 2 3 1 1 2 1 1 1 1 2 1 2 1 1 1 1 1 2 1 1...

output:

3580375

result:

ok single line: '3580375'

Test #33:

score: 0
Accepted
time: 182ms
memory: 51628kb

input:

1000 1000
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

482801872

result:

ok single line: '482801872'

Test #34:

score: 0
Accepted
time: 130ms
memory: 51564kb

input:

1000 1000
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

194088777

result:

ok single line: '194088777'