結果

問題 No.2639 Longest Increasing Walk
ユーザー kenken714kenken714
提出日時 2024-02-19 21:31:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 1,125 bytes
コンパイル時間 1,984 ms
コンパイル使用メモリ 210,552 KB
実行使用メモリ 14,064 KB
最終ジャッジ日時 2024-02-19 21:31:26
合計ジャッジ時間 4,332 ms
ジャッジサーバーID
(参考情報)
judge11 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 129 ms
13,608 KB
testcase_05 AC 104 ms
13,608 KB
testcase_06 AC 109 ms
13,624 KB
testcase_07 AC 114 ms
13,628 KB
testcase_08 AC 109 ms
13,608 KB
testcase_09 AC 118 ms
13,608 KB
testcase_10 AC 75 ms
14,064 KB
testcase_11 AC 63 ms
9,556 KB
testcase_12 AC 12 ms
6,676 KB
testcase_13 AC 78 ms
13,844 KB
testcase_14 AC 46 ms
10,032 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 3 ms
6,676 KB
testcase_17 AC 45 ms
9,556 KB
testcase_18 AC 53 ms
9,880 KB
testcase_19 AC 15 ms
6,676 KB
testcase_20 AC 33 ms
8,144 KB
testcase_21 AC 63 ms
9,556 KB
testcase_22 AC 24 ms
7,608 KB
testcase_23 AC 2 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 2 ms
6,676 KB
testcase_31 AC 2 ms
6,676 KB
testcase_32 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1ll << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

#define PP pair<ll, P>
ll h, w, ans, s[510][510], dp[510][510];
ll vx[4] = {1, -1, 0, 0}, vy[4] = {0, 0, -1, 1};
vector<PP> v;
int main(){
    cin >> h >> w;
    REP(i, h){
        REP(j, w){
            cin >> s[i][j];
            v.push_back(PP(s[i][j], P(i, j)));
        }
    }
    sort(ALL(v));
    REP(i, v.size()){
        ll x = v[i].second.first, y = v[i].second.second;
        ans = max(ans, dp[x][y] + 1);
        REP(j, 4){
            ll nx = x + vx[j], ny = y + vy[j];
            if(0 > nx or nx >= h or 0 > ny or ny >= w)continue;
            if(s[nx][ny] > s[x][y]){
                dp[nx][ny] = max(dp[nx][ny], dp[x][y] + 1);
            }
        }
    }
    cout <<ans << endl;
}
0