Submission #1317699

#TimeUsernameProblemLanguageResultExecution timeMemory
1317699eyadoozJump (BOI06_jump)C++20
100 / 100
5 ms1032 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define pb push_back #define all(x) (x).begin(), (x).end() #define sz(x) (int) (x).size() #define endl '\n' #define int long long string add(string a, string b) { if(sz(a)<sz(b)) swap(a,b); // cout << "here: " << a << " " << b << endl << flush; if(b.empty()) return a; int rem=0; string ans=""; int j=sz(a)-1; for(int i = sz(b)-1;i >= 0;i--) { int x=b[i]-'0'+a[j]-'0'+rem; if(x>=10) rem=(x-(x%10))/10; else rem=0; ans+=(x%10)+'0'; j--; } while(j>=0) { int x=a[j]-'0'+rem; if(x>=10) rem=(x-(x%10))/10; else rem=0; ans+=(x%10)+'0'; j--; } while(rem>=10) { ans+=(rem%10)+'0'; rem/=10; } // cout << rem << endl << flush; if(rem>0) ans+=(rem+'0'); reverse(all(ans)); return ans; } main() { cin.tie(0) -> sync_with_stdio(0); // string a, b; // cin >> a >> b; // cout << add(a, b) << endl << flush; // cout << (stol(add(a, b))==(stol(a)+stol(b))); // return 0; int n; cin >> n; string dp[n][n]={}; for(int i = 0;i < n;i++) { for(int j = 0;j < n;j++) { dp[i][j]='0'; } } dp[0][0]="1"; for(int i = 0;i < n;i++) { for(int j = 0;j < n;j++) { int x; cin >> x; if(i==n-1&&j==n-1) break; // cout << i << " " << j << endl << flush; if(i+x<n) dp[i+x][j]=add(dp[i+x][j], dp[i][j]); if(j+x<n) dp[i][j+x]=add(dp[i][j+x], dp[i][j]); } } // // cout << "here: " << endl << flush; cout << dp[n-1][n-1]; // // cout << add("00001","12412"); }

Compilation message (stderr)

jump.cpp:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...