結果
| 問題 |
No.2855 Move on Grid
|
| コンテスト | |
| ユーザー |
mitani
|
| 提出日時 | 2024-08-25 14:42:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 641 ms / 3,000 ms |
| コード長 | 1,524 bytes |
| コンパイル時間 | 4,447 ms |
| コンパイル使用メモリ | 239,148 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-08-25 14:42:48 |
| 合計ジャッジ時間 | 22,591 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 40 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:60:30: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
60 | auto [c,p]=pq.top();pq.pop();
| ^
main.cpp:61:30: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
61 | 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));
if(a[0][0]<md){
pq.push({1,{0,0}});
cos[0][0]=1;
}
else{
pq.push({0,{0,0}});
cos[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;
int nc=c;
if(a[nx][ny]<md)nc++;
cos[nx][ny]=nc;
pq.push({nc,{nx,ny}});
}
}
if(cos[n-1][m-1]<=k)lb=md;
else ub=md;
}
cout<<lb<<endl;
}
mitani