답안 #720323

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
720323 2023-04-08T03:18:17 Z Yell0 Jump (BOI06_jump) C++17
100 / 100
8 ms 1132 KB
#include <bits/stdc++.h>

using namespace std;
int N,gr[102][102];
string dp[102][102];

inline string add(string x,string y) {
  if(x=="0") return y;
  if(y=="0") return x;
  string ret="";
  reverse(x.begin(),x.end());
  reverse(y.begin(),y.end());
  if(x.size()<y.size()) swap(x,y);
  int c=0,d;
  for(int i=0;i<(int)x.size();++i) {
    if(i>=(int)y.size()) d=x[i]-'0'+c;
    else d=x[i]-'0'+y[i]-'0'+c;
    c=d/10;
    ret.push_back(d%10+'0');
  }
  if(c) ret.push_back(c+'0');
  reverse(ret.begin(),ret.end());
  return ret;
}
inline bool chk(int r,int c) {return r>0&&c>0&&r<=N&&c<=N;}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  cin>>N;
  dp[1][1]="1";
  for(int i=1;i<=N;++i) for(int j=1;j<=N;++j) {
    cin>>gr[i][j];
    if(!gr[i][j]) continue;
    if(chk(i+gr[i][j],j)) dp[i+gr[i][j]][j]=add(dp[i+gr[i][j]][j],dp[i][j]);
    if(chk(i,j+gr[i][j])) dp[i][j+gr[i][j]]=add(dp[i][j+gr[i][j]],dp[i][j]);
  }
  cout<<(dp[N][N].size()?dp[N][N]:"0")<<'\n';
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 652 KB Output is correct
5 Correct 0 ms 596 KB Output is correct
6 Correct 1 ms 656 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 596 KB Output is correct
10 Correct 1 ms 656 KB Output is correct
11 Correct 1 ms 656 KB Output is correct
12 Correct 1 ms 596 KB Output is correct
13 Correct 1 ms 596 KB Output is correct
14 Correct 1 ms 596 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 4 ms 924 KB Output is correct
17 Correct 4 ms 724 KB Output is correct
18 Correct 6 ms 924 KB Output is correct
19 Correct 6 ms 792 KB Output is correct
20 Correct 8 ms 1132 KB Output is correct