結果

問題 No.2639 Longest Increasing Walk
ユーザー Nzt3Nzt3
提出日時 2024-02-19 21:34:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 816 bytes
コンパイル時間 1,999 ms
コンパイル使用メモリ 213,928 KB
実行使用メモリ 8,396 KB
最終ジャッジ日時 2024-02-19 21:34:57
合計ジャッジ時間 3,804 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 1 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 52 ms
8,396 KB
testcase_05 AC 48 ms
8,396 KB
testcase_06 AC 49 ms
8,380 KB
testcase_07 AC 58 ms
8,372 KB
testcase_08 AC 50 ms
8,388 KB
testcase_09 AC 59 ms
8,392 KB
testcase_10 AC 39 ms
7,968 KB
testcase_11 AC 34 ms
6,548 KB
testcase_12 AC 7 ms
6,548 KB
testcase_13 AC 43 ms
8,008 KB
testcase_14 AC 25 ms
6,548 KB
testcase_15 AC 2 ms
6,548 KB
testcase_16 AC 2 ms
6,548 KB
testcase_17 AC 29 ms
6,548 KB
testcase_18 AC 28 ms
6,548 KB
testcase_19 AC 9 ms
6,548 KB
testcase_20 AC 17 ms
6,548 KB
testcase_21 AC 36 ms
6,548 KB
testcase_22 AC 14 ms
6,548 KB
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 2 ms
6,548 KB
testcase_25 AC 3 ms
6,548 KB
testcase_26 AC 1 ms
6,548 KB
testcase_27 AC 1 ms
6,548 KB
testcase_28 AC 1 ms
6,548 KB
testcase_29 AC 1 ms
6,548 KB
testcase_30 AC 2 ms
6,548 KB
testcase_31 AC 1 ms
6,548 KB
testcase_32 AC 1 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H,W;
  cin>>H>>W;
  vector A(H,vector(W,0));
  vector V(0,array<int,3>());
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>A[i][j];
      V.push_back({A[i][j],i,j});
    }
  }
  sort(V.begin(),V.end());
  vector dp(H,vector(W,1));
  int dx[]={0,1,0,-1};
  int dy[]={1,0,-1,0};
  auto bound_ok=[&](int x,int y){
    return x>=0&&x<H&&y>=0&&y<W;
  };
  for(int i=0;i<H*W;i++){
    auto [v,x,y]=V[i];
    for(int j=0;j<4;j++){
      int x2=x+dx[j],y2=y+dy[j];
      if(bound_ok(x2,y2)&&A[x2][y2]<v){
        dp[x][y]=max(dp[x][y],dp[x2][y2]+1);
      }
    }
  }
  int ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++)ans=max(ans,dp[i][j]);
  }
  cout<<ans<<'\n';
}
0