結果

問題 No.2639 Longest Increasing Walk
ユーザー AerenAeren
提出日時 2024-02-19 21:34:55
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 1,017 bytes
コンパイル時間 3,487 ms
コンパイル使用メモリ 277,708 KB
実行使用メモリ 7,368 KB
最終ジャッジ日時 2024-02-19 21:35:01
合計ジャッジ時間 4,946 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 45 ms
7,368 KB
testcase_05 AC 46 ms
7,368 KB
testcase_06 AC 47 ms
7,224 KB
testcase_07 AC 65 ms
7,216 KB
testcase_08 AC 54 ms
7,232 KB
testcase_09 AC 64 ms
7,236 KB
testcase_10 AC 42 ms
6,676 KB
testcase_11 AC 38 ms
6,676 KB
testcase_12 AC 7 ms
6,676 KB
testcase_13 AC 45 ms
6,676 KB
testcase_14 AC 25 ms
6,676 KB
testcase_15 AC 1 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 21 ms
6,676 KB
testcase_18 AC 30 ms
6,676 KB
testcase_19 AC 9 ms
6,676 KB
testcase_20 AC 18 ms
6,676 KB
testcase_21 AC 38 ms
6,676 KB
testcase_22 AC 13 ms
6,676 KB
testcase_23 AC 1 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 1 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 #

// #pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
#if __cplusplus >= 202002L
using namespace numbers;
#endif



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	static const vector<pair<int, int>> dr4{{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
	int h, w;
	cin >> h >> w;
	vector<vector<int>> a(h, vector<int>(w));
	for(auto &x: a | ranges::views::join){
		cin >> x;
	}
	vector<array<int, 2>> order;
	for(auto i = 0; i < h; ++ i){
		for(auto j = 0; j < w; ++ j){
			order.push_back({i, j});
		}
	}
	ranges::sort(order, [&](auto x, auto y){ return a[x[0]][x[1]] < a[y[0]][y[1]]; });
	vector<vector<int>> dp(h, vector<int>(w, 1));
	for(auto [x, y]: order){
		for(auto [dx, dy]: dr4){
			int xn = x + dx, yn = y + dy;
			if(0 <= min(xn, yn) && xn < h && yn < w && a[x][y] < a[xn][yn]){
				dp[xn][yn] = max(dp[xn][yn], dp[x][y] + 1);
			}
		}
	}
	cout << ranges::max(dp | ranges::views::join) << "\n";
	return 0;
}

/*

*/
0