結果
問題 |
No.2064 Smallest Sequence on Grid
|
ユーザー |
![]() |
提出日時 | 2022-09-03 19:27:22 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 678 bytes |
コンパイル時間 | 1,766 ms |
コンパイル使用メモリ | 196,980 KB |
最終ジャッジ日時 | 2025-02-07 02:28:04 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 WA * 17 |
ソースコード
#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; }