結果

問題 No.2064 Smallest Sequence on Grid
ユーザー umezoumezo
提出日時 2022-09-03 19:41:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,050 bytes
コンパイル時間 2,303 ms
コンパイル使用メモリ 214,228 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-04-28 16:54:16
合計ジャッジ時間 20,199 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 RE -
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 3 ms
6,940 KB
testcase_17 AC 175 ms
12,928 KB
testcase_18 AC 173 ms
13,056 KB
testcase_19 AC 174 ms
13,056 KB
testcase_20 AC 1,734 ms
13,440 KB
testcase_21 AC 1,846 ms
13,440 KB
testcase_22 AC 1,422 ms
13,312 KB
testcase_23 AC 1,164 ms
13,312 KB
testcase_24 AC 1,166 ms
13,440 KB
testcase_25 AC 1,176 ms
13,568 KB
testcase_26 AC 2,112 ms
13,440 KB
testcase_27 AC 2,184 ms
13,440 KB
testcase_28 AC 174 ms
12,928 KB
testcase_29 AC 1,798 ms
11,904 KB
testcase_30 AC 259 ms
12,160 KB
権限があれば一括ダウンロードができます

ソースコード

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;

using pii=pair<int,int>;

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];
  set<pii> se;
  se.insert({0,0});
  for(int k=1;k<h+w;k++){
    char tmp='|';
    rep(i,h){
      int j=k-i;
      if(j<0 || j>=w) continue;
      bool b=false;
      if(i>0 && se.count({i-1,j})) b=true;
      if(j>0 && se.count({i,j-1})) b=true;
      if(b==false) continue;
      tmp=min(tmp,S[i][j]);
    }
    ans[k]=tmp;
    set<pii> se2;
    rep(i,h){
      int j=k-i;
      if(j<0 || j>=w) continue;
      if(S[i][j]!=tmp) continue;
      bool b=false;
      if(i>0 && se.count({i-1,j})) b=true;
      if(j>0 && se.count({i,j-1})) b=true;
      if(b==false) continue;
      se2.insert({i,j});
    }
    swap(se,se2);
  }
  rep(i,h+w-1) cout<<ans[i];
  cout<<endl;
  
  return 0;
}
0