結果
問題 | No.2639 Longest Increasing Walk |
ユーザー |
|
提出日時 | 2024-02-20 07:36:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 726 bytes |
コンパイル時間 | 1,690 ms |
コンパイル使用メモリ | 176,100 KB |
実行使用メモリ | 13,836 KB |
最終ジャッジ日時 | 2024-09-29 03:23:49 |
合計ジャッジ時間 | 5,553 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 TLE * 1 -- * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; typedef pair<int,P> Q; #define REP(i,n) for(int i=0;i<int(n);i++) int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int i,j; int H,W; cin >> H >> W; vector<Q> v; for(i=1;i<=H;i++) for(j=1;j<=W;j++){ int a; cin >> a; v.push_back(Q(a,P(i,j))); } sort(v.begin(),v.end()); vector<int> dp(H*W,1); REP(i,H*W){ for(j=i+1;j<H*W;j++){ if(v[i].first==v[j].first) continue; int d=abs(v[i].second.first-v[j].second.first)+abs(v[i].second.second-v[j].second.second); if(d==1) dp[j]=max(dp[j],dp[i]+1); } } int ans=1; REP(i,H*W) ans=max(ans,dp[i]); cout << ans << endl; return 0; }