結果

問題 No.2064 Smallest Sequence on Grid
ユーザー umezo
提出日時 2022-09-02 22:24:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 597 bytes
コンパイル時間 1,759 ms
コンパイル使用メモリ 198,308 KB
最終ジャッジ日時 2025-02-07 01:30:31
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 MLE * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

string dp[3030][3030];
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int h,w;
  cin>>h>>w;
  vector<string> S(h);
  rep(i,h) cin>>S[i];
  
  dp[0][0]=S[0][0];
  rep(i,h) rep(j,w){
    if(i==0 && j==0) continue;
    else if(i==0) dp[i][j]=dp[i][j-1]+S[i][j];
    else if(j==0) dp[i][j]=dp[i-1][j]+S[i][j];
    else if(i>0 && j>0) dp[i][j]=min(dp[i-1][j],dp[i][j-1])+S[i][j];
  }
  cout<<dp[h-1][w-1]<<endl;

  return 0;
}
0