結果

問題 No.2639 Longest Increasing Walk
ユーザー inkyaman
提出日時 2024-03-24 10:32:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 1,249 bytes
コンパイル時間 1,004 ms
コンパイル使用メモリ 111,524 KB
最終ジャッジ日時 2025-02-20 13:34:30
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long;
int H, W;
int A[505][505], vis[505][505];
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
void dfs(int y, int x) {
int mx = 0;
for(int i = 0; i < 4; ++i) {
int nx = x+dx[i];
int ny = y+dy[i];
if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
if(A[y][x] >= A[ny][nx]) continue;
if(vis[ny][nx] == 0) dfs(ny, nx);
mx = max(mx, vis[ny][nx]);
}
vis[y][x] = mx+1;
}
int main() {
cin >> H >> W;
for(int i = 0; i < H; ++i) {
for(int j = 0; j < W; ++j) {
cin >> A[i][j];
}
}
int ans = 0;
for(int i = 0; i < H; ++i) {
for(int j = 0; j < W; ++j) {
if(vis[i][j] != 0) {
ans = max(ans, vis[i][j]);
continue;
}
dfs(i,j);
ans = max(ans,vis[i][j]);
}
}
cout << ans << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0