結果

問題 No.2376 障害物競プロ
ユーザー asaringoasaringo
提出日時 2023-07-07 23:17:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,826 bytes
コンパイル時間 3,075 ms
コンパイル使用メモリ 205,452 KB
実行使用メモリ 5,700 KB
最終ジャッジ日時 2023-09-29 01:02:05
合計ジャッジ時間 30,602 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define fast_io ios::sync_with_stdio(false); cin.tie(nullptr);
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
typedef long long ll;
typedef long double ld;
#define chmin(a,b) a = min(a,b);
#define chmax(a,b) a = max(a,b);
#define bit_count(x) __builtin_popcountll(x)
#define leading_zero_count(x) __builtin_clz(x)
#define trailing_zero_count(x) __builtin_ctz(x)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / gcd(a,b) * b
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define rrep(i,a,b) for(int i = a ; i < b ; i++)
#define repi(it,S) for(auto it = S.begin() ; it != S.end() ; it++)
#define pt(a) cout << a << endl;
#define debug(a) cout << #a << " " << a << endl;
#define all(a) a.begin(), a.end()
#define endl "\n";
#define v1(n,a) vector<ll>(n,a)
#define v2(n,m,a) vector<vector<ll>>(n,v1(m,a))
#define v3(n,m,k,a) vector<vector<vector<ll>>>(n,v2(m,k,a))
#define v4(n,m,k,l,a) vector<vector<vector<vector<ll>>>>(n,v3(m,k,l,a))
template<typename T,typename U>istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<typename T,typename U>ostream &operator<<(ostream&os,const pair<T,U>&p){os<<p.first<<" "<<p.second;return os;}
template<typename T>istream &operator>>(istream&is,vector<T>&v){for(T &in:v){is>>in;}return is;}
template<typename T>ostream &operator<<(ostream&os,const vector<T>&v){for(auto it=v.begin();it!=v.end();){os<<*it<<((++it)!=v.end()?" ":"");}return os;}
template<typename T>istream &operator>>(istream&is,vector<vector<T>>&v){for(T &in:v){is>>in;}return is;}
template<typename T>ostream &operator<<(ostream&os,const vector<vector<T>>&v){for(auto it=v.begin();it!=v.end();){os<<*it<<((++it)!=v.end()?"\n":"");}return os;}
template<typename T>ostream &operator<<(ostream&os,const set<T>&v){for(auto it=v.begin();it!=v.end();){os<<*it<<((++it)!=v.end()?" ":"");}return os;}
template<typename T>ostream &operator<<(ostream&os,const multiset<T>&v){for(auto it=v.begin();it!=v.end();){os<<*it<<((++it)!=v.end()?" ":"");}return os;}

int n, m;
tuple<ld,ld> X[303];

ld dist(int i, int j){
    if((i - j) % n == 0) return 1e16;
    auto[x,y] = X[i];
    auto[a,b] = X[j];
    ld v = abs(x - a) * abs(x - a) + abs(y - b) * abs(y - b);
    v = sqrt(v);
    return v;
}

ld d[404][404];

void fff(){
    rep(i,2*n) rep(j,2*n) rep(k,2*n) chmin(d[i][j], d[i][k] + d[k][j]);
}

void solve(){
    cin >> n >> m;
    rep(i,n){
        ld a, b, c, d;
        cin >> a >> b >> c >> d;
        X[i] = {a,b};
        X[i+n] = {c,d};
    }
    rep(i,2*n) rep(j,2*n) {
        if((i - j) % n == 0){
            d[i][j] = 1e16;
            continue;
        }
        auto[a,b] = X[i];
        auto[c,e] = X[j];
        ld dx = c - a;
        ld dy = e - b;
        bool ok = true;
        rep(k,n){
            if(k == i % n || k == j % n) continue;
            auto[x,y] = X[k];
            auto[s,t] = X[k+n];
            ld ddx1 = x - c;
            ld ddy1 = y - e;
            ld ddx2 = s - c;
            ld ddy2 = t - e;
            ld crs1 = ddx1 * dy - ddy1 * dx;
            ld crs2 = ddx2 * dy - ddy2 * dx;
            if(abs(ddx1 * dx + ddy1 * dy) <= 1e-5) continue;
            if(abs(ddx2 * dx + ddy2 * dy) <= 1e-5) continue;
            bool f = (crs1 < 0) ^ (crs2 < 0);
            // cout << i << " " << j << " " << k << " " << f << endl;
            if(f) ok = false;
        }
        if(ok) d[i][j] = dist(i,j);
        else d[i][j] = 1e16;
        // cout << i << " " << j << " " << d[i][j] << endl;
    }
    fff();
    rep(i,m){
        int a, b, c, e;
        cin >> a >> b >> c >> e;
        a--;
        b--;
        c--;
        e--;
        cout << fixed << setprecision(25) << d[a+b*n][c+e*n] << endl;
    }
}

int main(){
    fast_io
    int t = 1;
    // cin >> t;
    rep(i,t) solve();
}
0