結果
問題 | No.2639 Longest Increasing Walk |
ユーザー |
|
提出日時 | 2024-02-19 21:34:55 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 61 ms / 2,000 ms |
コード長 | 1,017 bytes |
コンパイル時間 | 3,127 ms |
コンパイル使用メモリ | 277,984 KB |
実行使用メモリ | 7,244 KB |
最終ジャッジ日時 | 2024-09-29 01:30:38 |
合計ジャッジ時間 | 4,865 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
// #pragma GCC optimize("O3,unroll-loops")#include <bits/stdc++.h>// #include <x86intrin.h>using namespace std;#if __cplusplus >= 202002Lusing namespace numbers;#endifint 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;}/**/