結果
| 問題 |
No.2639 Longest Increasing Walk
|
| コンテスト | |
| ユーザー |
yuyu_5510
|
| 提出日時 | 2024-02-19 23:03:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,282 bytes |
| コンパイル時間 | 1,844 ms |
| コンパイル使用メモリ | 181,044 KB |
| 実行使用メモリ | 27,940 KB |
| 最終ジャッジ日時 | 2024-09-29 02:46:51 |
| 合計ジャッジ時間 | 9,256 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 2 RE * 30 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:37:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
37 | auto [d, v] = que.top(); que.pop();
| ^
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
int h, w;
cin >> h >> w;
vector<vector<int>> a(h, vector<int>(w));
for(int i = 0;i < h;i++){
for(int j = 0;j < w;j++){
cin >> a[i][j];
}
}
vector<vector<int>> g(h*w);
vector<vector<int>> gr(h*w);
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
for(int i = 0;i < h;i++){
for(int j = 0;j < w;j++){
for(int k = 0;k < 4;k++){
int nx = i + dx[k], ny = j + dy[k];
if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
if(a[i][j] < a[nx][ny]){
g[i*w+j].push_back(nx*w+ny);
}
}
}
}
priority_queue<pair<int, int>, vector<pair<int, int>>> que;
vector<long long> dist(h*w, 1);
for(int i = 0;i < h*w;i++){
que.push(make_pair(1, a[i/w][i%w]));
}
while(!que.empty()){
auto [d, v] = que.top(); que.pop();
if(dist[v] > d) continue;
for(auto to: g[v]){
if(dist[to] < dist[v] + 1){
dist[to] = dist[v] + 1;
que.push(make_pair(dist[to], a[to/w][to%w]));
}
}
}
long long ans = 0;
for(int i = 0;i < h*w;i++){
ans = max(ans, dist[i]);
}
cout << ans << endl;
}
yuyu_5510