結果

問題 No.2064 Smallest Sequence on Grid
ユーザー 👑 p-adicp-adic
提出日時 2022-09-02 21:48:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 854 bytes
コンパイル時間 1,761 ms
コンパイル使用メモリ 203,112 KB
実行使用メモリ 14,976 KB
最終ジャッジ日時 2024-04-27 21:17:11
合計ジャッジ時間 5,840 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 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,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 1 ms
6,944 KB
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 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 158 ms
14,848 KB
testcase_27 WA -
testcase_28 AC 158 ms
14,848 KB
testcase_29 AC 134 ms
14,848 KB
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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( "" );
}
0