結果

問題 No.2695 Warp Zone
ユーザー shkiiii_shkiiii_
提出日時 2024-03-22 22:53:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 2,231 bytes
コンパイル時間 2,347 ms
コンパイル使用メモリ 190,952 KB
実行使用メモリ 67,968 KB
最終ジャッジ日時 2024-03-22 22:53:20
合計ジャッジ時間 3,963 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 74 ms
67,968 KB
testcase_04 AC 77 ms
66,688 KB
testcase_05 AC 73 ms
66,688 KB
testcase_06 AC 77 ms
67,584 KB
testcase_07 AC 75 ms
67,968 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 30 ms
28,032 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 11 ms
11,136 KB
testcase_12 AC 40 ms
38,144 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 50 ms
47,744 KB
testcase_15 AC 27 ms
25,344 KB
testcase_16 AC 10 ms
9,984 KB
testcase_17 AC 16 ms
16,256 KB
testcase_18 AC 62 ms
57,984 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 56 ms
51,840 KB
testcase_21 AC 50 ms
46,848 KB
testcase_22 AC 21 ms
19,456 KB
testcase_23 AC 41 ms
38,016 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:59:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   59 |     auto [od,ov] = que.top();que.pop();
      |          ^

ソースコード

diff #

#include<bits/stdc++.h>
// #include<atcoder/all>
// #include<boost/multiprecision/cpp_int.hpp>

using namespace std;
// using namespace atcoder;
// using bint = boost::multiprecision::cpp_int;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll,ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define sz(c) ((ll)(c).size())
#define LB(A,x) (int)(lower_bound(A.begin(),A.end(),x)-A.begin())
// #define MOD 1000000007
#define MOD 998244353
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<typename T>ostream&operator<<(ostream&os,vector<T>&v){for(int i = 0;i < v.size();i++)os<<v[i]<<(i+1!=v.size()?" ":"");return os;}
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<typename T1,typename T2>ostream&operator<<(ostream&os,pair<T1,T2>&p){os<<p.first<<" "<<p.second;return os;}
template<typename T1,typename T2>istream&operator>>(istream&is,pair<T1,T2>&p){is>>p.first>>p.second;return is;}


int main(){
  
  ios_base::sync_with_stdio(0), cin.tie(0);
  ll h,w,n;
  cin >> h >> w >> n;
  vvi g(n,vi(4));
  vector<P> p(2*n);
  rep(i,n){
    rep(j,4)cin >> g[i][j];
    p[i] = {g[i][0],g[i][1]};
    p[i+n] = {g[i][2],g[i][3]};
  }
  p.emplace_back(1,1);
  p.emplace_back(h,w);
  sort(ALL(p));
  p.erase(unique(ALL(p)),p.end());
  vector<vector<P>> v(sz(p));
  rep(i,n){
    int k = LB(p,make_pair(g[i][0],g[i][1]));
    int l = LB(p,make_pair(g[i][2],g[i][3]));
    v[k].emplace_back(l,1);
    // v[l].emplace_back(k,1);
  }
  rep(i,sz(p))rep(j,sz(p)){
    v[i].emplace_back((int)j,abs(p[i].first-p[j].first)+abs(p[i].second-p[j].second));
  }
  min_priority_queue<pair<ll,int>> que;
  que.push(make_pair(0,LB(p,(P{1,1}))));
  // /*
  vi d(sz(p),1ll << 50);
  d[LB(p,(P{1,1}))] = 0;
  while(!que.empty()){
    auto [od,ov] = que.top();que.pop();
  if(od > d[ov])continue;
    for(auto nv : v[ov]){
      if(d[nv.first] <= d[ov] + nv.second)continue;
      d[nv.first] = d[ov] + nv.second;
      que.push(make_pair(d[nv.first],nv.first));
    }
  }
  cout << d[LB(p,(P{h,w}))] << "\n";
  // */

  return 0;
}
0