結果

問題 No.2639 Longest Increasing Walk
ユーザー daiotadaiota
提出日時 2024-02-19 23:08:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 775 bytes
コンパイル時間 1,281 ms
コンパイル使用メモリ 167,592 KB
実行使用メモリ 13,480 KB
最終ジャッジ日時 2024-02-19 23:08:33
合計ジャッジ時間 5,305 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,480 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 38 ms
6,676 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define REP(i,n) for(int i=0;i<int(n);i++)

int a[510][510],v[510][510];
int mx=0;
int H,W;

bool inside(int i,int j){
	return (1<=i && i<=H && 1<=j && j<=W);
}


int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

void dfs(int x,int y,int d){
	v[x][y]=1;
	mx=max(mx,d);

    REP(k,4){
    int p=x+dx[k],q=y+dy[k];
	if(!inside(p,q)) continue;
	if(v[p][q]==1) continue;
	if(a[x][y]<a[p][q]) dfs(p,q,d+1);

	v[x][y]=0;


    }

}


int main(){
	cin.tie(nullptr);  ios_base::sync_with_stdio(false);
	int i,j;


	cin >> H >> W;

	for(i=1;i<=H;i++) for(j=1;j<=W;j++) cin >> a[i][j];

	for(i=1;i<=H;i++) for(j=1;j<=W;j++){
		if(v[i][j]==0) dfs(i,j,1);
	}

	cout << mx << endl;


    return 0;
}
0