結果
| 問題 |
No.2639 Longest Increasing Walk
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-19 21:51:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,280 bytes |
| コンパイル時間 | 3,775 ms |
| コンパイル使用メモリ | 235,404 KB |
| 実行使用メモリ | 13,648 KB |
| 最終ジャッジ日時 | 2024-09-29 01:50:30 |
| 合計ジャッジ時間 | 7,594 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 TLE * 1 -- * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
#include <atcoder/all>
using namespace atcoder;
// using mint = modint998244353;
// using mint = modint1000000007;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define reps(i, l, r) for(ll i = l; i < r; i++)
// 左上右下の順番
vector<int> dx = {0,-1,0,1};
vector<int> dy = {-1,0,1,0};
inline bool outField(int x,int y,int h,int w){
if(0 <= x && x < h && 0 <= y && y < w)return false;
return true;
}
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
ll h, w; cin >> h >> w;
vector<vector<ll>> a(h,vector<ll>(w)), walk(h,vector<ll>(w,0));
rep(i,h) rep(j,w) cin >> a[i][j];
auto dfs = [&](auto self, ll x, ll y) -> void {
ll res = 0;
rep(d,4) {
ll nx = x + dx[d], ny = y + dy[d];
if(outField(nx,ny,h,w)) continue;
if(a[x][y] < a[nx][ny]) {
self(self, nx, ny);
res = max(res, walk[nx][ny]);
}
}
walk[x][y] = res + 1;
return;
};
ll ans = 0;
rep(i,h) rep(j,w) {
dfs(dfs, i, j);
ans = max(ans, walk[i][j]);
}
cout << ans << '\n';
return 0;
}