結果
| 問題 |
No.2855 Move on Grid
|
| コンテスト | |
| ユーザー |
mitani
|
| 提出日時 | 2024-08-25 14:38:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,494 bytes |
| コンパイル時間 | 3,895 ms |
| コンパイル使用メモリ | 238,264 KB |
| 実行使用メモリ | 411,292 KB |
| 最終ジャッジ日時 | 2024-08-25 14:38:37 |
| 合計ジャッジ時間 | 12,983 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | TLE * 1 -- * 39 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:54:30: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
54 | auto [c,p]=pq.top();pq.pop();
| ^
main.cpp:55:30: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
55 | auto [x,y]=p;
| ^
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#include <atcoder/all>
using namespace atcoder;
//using mint=static_modint<998244353>;
using mint=static_modint<1000000007>;
////using mint=modint;
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
int inf=2147483647;
ll INF=9223372036854775807;
const ld PI=acos(-1);
void yn(bool f){
if(f)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return;
}
ll n,m;
bool in(int x,int y){
if(x<0||n<=x)return false;
if(y<0||m<=y)return false;
return true;
}
vector<int> dx={1,-1,0,0};
vector<int> dy={0,0,1,-1};
int main(){
ll k;cin>>n>>m>>k;
vector<vector<ll>> a(n,vector<ll>(m));
rep(i,n)rep(j,m)cin>>a[i][j];
ll lb=1,ub=1000000000+1;
priority_queue<pair<int,P>,vector<pair<int,P>>,greater<pair<int,P>>> pq;
while(lb+1<ub){
ll md=(lb+ub)/2;
vector<vector<int>> cos(n,vector<int>(m,-1));
//cout<<1<<endl;
if(a[0][0]<md)pq.push({1,{0,0}});
else pq.push({0,{0,0}});
while(!pq.empty()){
auto [c,p]=pq.top();pq.pop();
auto [x,y]=p;
rep(i,4){
int nx=x+dx[i];
int ny=y+dy[i];
//cout<<nx<<" "<<ny<<endl;
if(!in(nx,ny))continue;
if(cos[nx][ny]!=-1)continue;
if(a[nx][ny]<md)pq.push({c+1,{nx,ny}});
else pq.push({c,{nx,ny}});
}
cos[x][y]=c;
}
if(cos[n-1][m-1]<=k)lb=md;
else ub=md;
}
cout<<lb<<endl;
}
mitani