結果
問題 |
No.2064 Smallest Sequence on Grid
|
ユーザー |
👑 |
提出日時 | 2022-09-02 21:48:31 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 854 bytes |
コンパイル時間 | 1,684 ms |
コンパイル使用メモリ | 194,044 KB |
最終ジャッジ日時 | 2025-02-07 01:04:58 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 WA * 18 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; #define CIN( LL , A ) LL A; cin >> A #define FOR( VAR , INITIAL , FINAL_PLUS_ONE ) for( int VAR = INITIAL ; VAR < FINAL_PLUS_ONE ; VAR ++ ) #define RETURN( ANSWER ) cout << ( ANSWER ) << "\n"; return 0 int main(){ constexpr const ll A = 3000; CIN( ll , H ); CIN( ll , W ); string S[A]; FOR( i , 0 , H ){ cin >> S[i]; } string s{}; ll i = 0; ll j = 0; ll H_m = H - 1; ll W_m = W - 1; ll N = H + W_m; FOR( n , 0 , N ){ cout << S[i].substr( j , 1 ); if( i == H_m ){ j++; } else if( j == W_m ){ i++; } else { auto ci = S[i+1].substr( j , 1 ).c_str()[0]; auto cj = S[i].substr( j+1 , 1 ).c_str()[0]; if( ci < cj ){ i++; } else { j++; } } } cout << S[i].substr( j , 1 ); RETURN( "" ); }