結果

問題 No.2639 Longest Increasing Walk
ユーザー umezoumezo
提出日時 2024-02-20 04:44:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 2,978 ms
コンパイル使用メモリ 209,332 KB
実行使用メモリ 21,120 KB
最終ジャッジ日時 2024-02-20 04:44:16
合計ジャッジ時間 5,284 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 0 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 103 ms
21,120 KB
testcase_05 AC 80 ms
21,120 KB
testcase_06 AC 80 ms
20,864 KB
testcase_07 AC 92 ms
20,736 KB
testcase_08 AC 107 ms
20,992 KB
testcase_09 AC 109 ms
20,992 KB
testcase_10 AC 78 ms
13,952 KB
testcase_11 AC 73 ms
12,544 KB
testcase_12 AC 10 ms
6,676 KB
testcase_13 AC 86 ms
14,464 KB
testcase_14 AC 45 ms
10,496 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 36 ms
9,728 KB
testcase_18 AC 55 ms
11,520 KB
testcase_19 AC 14 ms
6,676 KB
testcase_20 AC 31 ms
8,576 KB
testcase_21 AC 69 ms
12,416 KB
testcase_22 AC 22 ms
7,424 KB
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 1 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 1 ms
6,676 KB
testcase_31 AC 1 ms
6,676 KB
testcase_32 AC 2 ms
6,676 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;

int A[510][510];
int dp[510][510];
int dh[]={1,0,-1,0};
int dw[]={0,1,0,-1};

int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int h,w;
  cin>>h>>w;
  set<pair<int,pair<int,int>>> s;
  rep(i,h) rep(j,w){
    cin>>A[i][j];
    s.insert({A[i][j],{i,j}});
  }
  for(auto x:s){
    int a=x.first;
    int i=x.second.first,j=x.second.second;
    bool b=false;
    rep(k,4){
      int ni=i+dh[k],nj=j+dw[k];
      if(ni<0 || nj<0 || ni>=h || nj>=w) continue;
      if(A[ni][nj]<a){
        dp[i][j]=max(dp[i][j],dp[ni][nj]+1);
        b=true;
      }
    }
    if(b==false) dp[i][j]=1;
  }
  int ans=0;
  rep(i,h) rep(j,w) ans=max(ans,dp[i][j]);
  cout<<ans<<endl;
  
  return 0;
}
0