Submission #923600

#TimeUsernameProblemLanguageResultExecution timeMemory
923600parlimoosJump (BOI06_jump)C++17
95 / 100
19 ms1372 KiB
//Be Name KHODA #pragma GCC optimize("Ofast") #include<bits/stdc++.h> #include<array> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define pp pop_back #define lb lower_bound #define ub upper_bound #define cl clear #define bg begin #define arr(x) array<unsigned long long , x> #define endl '\n' const unsigned long long INF = (1ll * 1e11); int n; int mat[100][100]; arr(10) dp[100][100]; arr(10) zr = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0}; arr(10) Sum(arr(10) &a , arr(10) &b){ arr(10) res = zr; for(int i = 0 ; i < 10 ; i++) res[i] = a[i] + b[i]; for(int i = 0 ; i < 9 ; i++){ unsigned long long d = res[i] % INF; res[i + 1] += (res[i] / INF); res[i] = d; } return res; } void f(int i , int j){ if(dp[i][j] != zr) return; if(mat[i][j] == 0) return; if(i + mat[i][j] >= n and j + mat[i][j] >= n) return; if(i + mat[i][j] >= n) f(i , j + mat[i][j]) , dp[i][j] = dp[i][j + mat[i][j]]; else if(j + mat[i][j] >= n) f(i + mat[i][j] , j) , dp[i][j] = dp[i + mat[i][j]][j]; else{ f(i + mat[i][j] , j) , f(i , j + mat[i][j]); dp[i][j] = Sum(dp[i + mat[i][j]][j] , dp[i][j + mat[i][j]]); } } int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 0 ; i < n ; i++){ for(int j = 0 ; j < n ; j++){ cin >> mat[i][j]; } } fill(&dp[0][0] , &dp[99][100] , zr); dp[n - 1][n - 1] = {1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0}; f(0 , 0); int inx = 9; while(inx >= 0 and dp[0][0][inx] == 0) inx--; for(int i = max(0 , inx) ; i >= 0 ; i--) cout << dp[0][0][i]; }
#Verdict Execution timeMemoryGrader output
Fetching results...