結果

問題 No.2064 Smallest Sequence on Grid
ユーザー umezoumezo
提出日時 2022-09-03 19:27:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 678 bytes
コンパイル時間 2,244 ms
コンパイル使用メモリ 203,760 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2024-04-28 16:43:37
合計ジャッジ時間 6,403 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 107 ms
13,056 KB
testcase_21 AC 108 ms
12,928 KB
testcase_22 AC 100 ms
13,056 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 97 ms
13,056 KB
testcase_27 WA -
testcase_28 AC 97 ms
13,184 KB
testcase_29 AC 71 ms
11,520 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

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;

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];
  
  vector<char> ans(h+w-1,'|');
  ans[0]=S[0][0];
  for(int k=1;k<h+w;k++){
    rep(i,h){
      int j=k-i;
      if(j<0 || j>=w) continue;
      bool b=false;
      if(i>0 && S[i-1][j]==ans[k-1]) b=true;
      if(j>0 && S[i][j-1]==ans[k-1]) b=true;
      if(b==false) continue;
      if(S[i][j]<ans[k]) ans[k]=S[i][j];
    }
  }
  rep(i,h+w-1) cout<<ans[i];
  cout<<endl;
  
  return 0;
}
0