結果

問題 No.2354 Poor Sight in Winter
ユーザー Jeroen Op de BeekJeroen Op de Beek
提出日時 2023-06-16 21:52:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 2,181 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 203,560 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 19:25:55
合計ジャッジ時間 3,720 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 29 ms
4,380 KB
testcase_12 AC 29 ms
4,380 KB
testcase_13 AC 31 ms
4,380 KB
testcase_14 AC 31 ms
4,380 KB
testcase_15 AC 30 ms
4,384 KB
testcase_16 AC 30 ms
4,380 KB
testcase_17 AC 31 ms
4,380 KB
testcase_18 AC 11 ms
4,384 KB
testcase_19 AC 20 ms
4,380 KB
testcase_20 AC 13 ms
4,384 KB
testcase_21 AC 2 ms
4,384 KB
testcase_22 AC 7 ms
4,380 KB
testcase_23 AC 8 ms
4,380 KB
testcase_24 AC 18 ms
4,384 KB
testcase_25 AC 6 ms
4,380 KB
testcase_26 AC 4 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int mxN = 1e5+1, oo = 1e9;
typedef complex<int> pt;
#define X real()
#define Y imag()
#define x real()
#define y imag()
auto cross(pt u, pt v) {return (ll)u.X*v.Y-(ll)u.Y*v.X;}
auto sgn(ll a) {return a==0?0:(a>0?1:-1);}
auto ccw(pt p1, pt p2, pt p3) {auto u = p2-p1, v = p3-p2;return cross(u,v);}
auto in(pt p1, pt p2) {return (ll)p1.X*p2.X+(ll)p1.Y*p2.Y;}
auto norm(pt p) {return (ll)p.X*p.X+(ll)p.Y*p.Y;}
bool comp(const pt& a, const pt& b) { return a.X<b.X or (a.X==b.X and a.Y < b.Y);}
void read(pt& p) {
    int a,b; cin >> a >> b;
    p = {a,b};
}
#define rep(i,a,b) for(int i=a;i<b;++i)
typedef pt P;
int manh(pt p) {
    return abs(p.X)+abs(p.Y);
}
int main() {
    int n,k; cin >> n >> k;
    vector<pt> pts(n+2);
    for(auto& i : pts) {
        read(i);
    }
    n+=2;

    int lo = 1,hi = 1e6;
    while(lo<hi) {
        auto mid = (lo+hi)/2;
            vector<bool> vis(n);
    vi d(n,oo);
    d[0]=0;
        while(true) {
            int best=-1;
            for(int i=0;i<n;++i) if(!vis[i]) {
                if(best==-1 or d[i]<d[best]) {
                    best=i;
                }
            }
            if(best==-1) break;
            int at = best;
            vis[at]=1;
            for(int to=0;to<n;++to) if(!vis[to]) {
                auto di = manh(pts[at]-pts[to]);
                di = (di-1)/mid;
                d[to]=min(d[to],d[at]+di);
                
            }
        }
        if(d[1]<=k) {
            hi = mid;
        } else lo = mid+1;

    }
    cout << lo << '\n';
    
}
0