結果

問題 No.2639 Longest Increasing Walk
ユーザー cho435cho435
提出日時 2024-02-21 00:04:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 890 bytes
コンパイル時間 4,889 ms
コンパイル使用メモリ 269,672 KB
実行使用メモリ 7,472 KB
最終ジャッジ日時 2024-02-21 00:04:26
合計ジャッジ時間 7,720 ms
ジャッジサーバーID
(参考情報)
judge16 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 136 ms
7,472 KB
testcase_05 AC 135 ms
7,472 KB
testcase_06 AC 135 ms
7,328 KB
testcase_07 AC 151 ms
7,320 KB
testcase_08 AC 141 ms
7,336 KB
testcase_09 AC 153 ms
7,468 KB
testcase_10 AC 97 ms
6,676 KB
testcase_11 AC 84 ms
6,676 KB
testcase_12 AC 14 ms
6,676 KB
testcase_13 AC 102 ms
6,676 KB
testcase_14 AC 58 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 3 ms
6,676 KB
testcase_17 AC 49 ms
6,676 KB
testcase_18 AC 69 ms
6,676 KB
testcase_19 AC 19 ms
6,676 KB
testcase_20 AC 41 ms
6,676 KB
testcase_21 AC 83 ms
6,676 KB
testcase_22 AC 30 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 3 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 3 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 2 ms
6,676 KB
testcase_32 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using mint = atcoder::modint998244353;

int main(){
	int h,w;
	cin>>h>>w;
	vector<vector<int>> a(h,vector<int>(w));
	rep(i,h) rep(j,w) cin>>a.at(i).at(j);
	vector<pair<int,int>> p;
	rep(i,h) rep(j,w) p.push_back({i,j});
	sort(p.begin(),p.end(),[&](pair<int,int> x,pair<int,int> y){
		return a.at(x.first).at(x.second)<a.at(y.first).at(y.second);
	});
	vector<int> dd={0,1,0,-1,0};
	auto isok=[&](int x,int y){
		return 0<=x&&x<h&&0<=y&&y<w;
	};
	vector<vector<int>> dp(h,vector<int>(w,1));
	int ans=0;
	for(auto[x,y]:p){
		ans=max(ans,dp.at(x).at(y));
		rep(i,4){
			int nx=x+dd.at(i);
			int ny=y+dd.at(i+1);
			if(isok(nx,ny)&&a.at(x).at(y)<a.at(nx).at(ny)){
				dp.at(nx).at(ny)=max(dp.at(nx).at(ny),dp.at(x).at(y)+1);
			}
		}
	}
	cout<<ans<<endl;
}
0