結果
問題 | No.2639 Longest Increasing Walk |
ユーザー |
![]() |
提出日時 | 2024-02-19 21:24:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 67 ms / 2,000 ms |
コード長 | 1,235 bytes |
コンパイル時間 | 2,228 ms |
コンパイル使用メモリ | 207,136 KB |
最終ジャッジ日時 | 2025-02-19 16:34:02 |
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define all(x) (x).begin(),(x).end() #define fi first #define se second #define mp make_pair #define si(x) int(x.size()) const int mod=998244353,MAX=505,INF=1<<30; vector<int> dh={0,1,0,-1},dw={1,0,-1,0}; int dp[MAX][MAX]; int main(){ std::ifstream in("text.txt"); std::cin.rdbuf(in.rdbuf()); cin.tie(0); ios::sync_with_stdio(false); int H,W;cin>>H>>W; vector<vector<int>> A(H,vector<int>(W)); vector<array<int,3>> S; for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ cin>>A[i][j]; S.push_back({A[i][j],i,j}); } } sort(all(S)); for(auto [x,i,j]:S){ for(int k=0;k<4;k++){ int toh=i+dh[k],tow=j+dw[k]; if(toh<0||toh>=H||tow<0||tow>=W) continue; if(A[toh][tow]<x) chmax(dp[i][j],dp[toh][tow]); } dp[i][j]++; } int ans=0; for(int i=0;i<H;i++) for(int j=0;j<W;j++) chmax(ans,dp[i][j]); cout<<ans<<endl; }