Submission #1170510

#TimeUsernameProblemLanguageResultExecution timeMemory
1170510ZeroCoolJump (BOI06_jump)C++20
70 / 100
2 ms580 KiB
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define ar array
#define ld long double
#define int long long
#define all(v) v.begin(), v.end()

const int N = 2e5 + 20;
const int K = 469;
const int LOG = 26;
const int INF = 1e12;	
int MOD = 998244353;

void mm(int &x){x = (x % MOD + MOD) % MOD;}

void orz(){
	int n;
	cin>>n;
	int A[n][n];
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++)cin>>A[i][j];
	}
	int dp[n][n];
	memset(dp, 0, sizeof dp);
	dp[0][0] = 1;
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			if(A[i][j] == 0)continue;
			
			if(i + A[i][j] < n)dp[i + A[i][j]][j] += dp[i][j];
			if(j + A[i][j] < n)dp[i][j + A[i][j]] += dp[i][j];
		}
	}
	cout<<dp[n - 1][n - 1];
}	
signed main(){ios_base::sync_with_stdio(false);cin.tie(0);
	int t;
	//cin>>t;
	t = 1;
	while(t--)orz();
}
	
#Verdict Execution timeMemoryGrader output
Fetching results...