QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#692139#7057. Digital PathkonghaojieAC ✓117ms62324kbC++171.6kb2024-10-31 13:53:552024-10-31 13:53:57

Judging History

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

  • [2024-10-31 13:53:57]
  • 评测
  • 测评结果:AC
  • 用时:117ms
  • 内存:62324kb
  • [2024-10-31 13:53:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
int go[4][2]={{0,1},{1,0},{-1,0},{0,-1}};
const int MOD=1e9+7;
const int N=1005;
int dp[5][N][N];
int n,m;
struct node{
	int x,y;
};
bool in(int x,int y){
	if(x>=0&&x<n&&y>=0&&y<m) return true;
	return false;
}
void solve(){
	cin>>n>>m;
	int a[n][m],c[n][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			for(int k=0;k<5;k++) dp[k][i][j]=0;
			cin>>a[i][j];
			c[i][j]=0;
		}
	}
	queue<node>q;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			for(int k=0;k<4;k++){
				int x=i+go[k][0],y=j+go[k][1];
				if(!in(x,y)) continue;
				if(a[x][y]==a[i][j]-1) c[i][j]++;
			}
			if(c[i][j]==0){
				node tmp;
				tmp.x=i,tmp.y=j;
				dp[1][i][j]=1;
				q.push(tmp);
			} 
		}
	}
	while(!q.empty()){
		node tmp=q.front();
		q.pop();
		int x=tmp.x,y=tmp.y;
		for(int i=0;i<4;i++){
			int x1=x+go[i][0],y1=y+go[i][1];
			if(!in(x1,y1)||a[x1][y1]!=a[x][y]+1) continue;
			c[x1][y1]--;
			for(int j=1;j<=4;j++){
				dp[j][x1][y1]=(dp[j][x1][y1]+dp[j-1][x][y])%MOD;
			}
			dp[4][x1][y1]=(dp[4][x1][y1]+dp[4][x][y])%MOD;
			if(c[x1][y1]==0){
				node tmp;
				tmp.x=x1,tmp.y=y1;
				q.push(tmp);
			}
		}
	}
	int ans=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			bool ok=true;
			for(int k=0;k<4;k++){
				int x=i+go[k][0],y=j+go[k][1];
				if(!in(x,y)) continue;
				if(a[x][y]==a[i][j]+1) ok=false;
			}
			if(ok) ans=(ans+dp[4][i][j])%MOD;
		}
	}
	cout<<ans<<endl;
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int t=1;
//	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 11756kb

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: 0ms
memory: 11756kb

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: 117ms
memory: 58888kb

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: 3ms
memory: 17412kb

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: 12ms
memory: 22352kb

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: 11ms
memory: 24604kb

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: 16ms
memory: 31660kb

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: 0ms
memory: 24812kb

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: 7ms
memory: 26464kb

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: 17ms
memory: 23608kb

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: 22ms
memory: 33484kb

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: 7ms
memory: 33600kb

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: 29ms
memory: 32664kb

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: 7ms
memory: 30192kb

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: 23ms
memory: 33544kb

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: 7ms
memory: 29096kb

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: 15ms
memory: 35568kb

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: 0ms
memory: 30440kb

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: 54ms
memory: 41312kb

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: 11ms
memory: 35032kb

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: 3ms
memory: 32504kb

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: 42ms
memory: 41824kb

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: 21ms
memory: 42020kb

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: 25ms
memory: 39864kb

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: 45ms
memory: 43244kb

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: 23ms
memory: 39516kb

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: 54ms
memory: 47736kb

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: 81ms
memory: 52712kb

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: 76ms
memory: 54632kb

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: 7ms
memory: 44868kb

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: 25ms
memory: 47508kb

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: 39ms
memory: 51916kb

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: 104ms
memory: 58616kb

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: 96ms
memory: 62324kb

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'