結果

問題 No.2376 障害物競プロ
ユーザー umezoumezo
提出日時 2023-07-10 05:34:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 416 ms / 4,000 ms
コード長 1,126 bytes
コンパイル時間 2,890 ms
コンパイル使用メモリ 199,264 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2023-10-09 22:42:47
合計ジャッジ時間 53,820 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,356 KB
testcase_04 AC 215 ms
5,824 KB
testcase_05 AC 304 ms
6,736 KB
testcase_06 AC 132 ms
5,160 KB
testcase_07 AC 405 ms
7,344 KB
testcase_08 AC 409 ms
7,348 KB
testcase_09 AC 396 ms
7,332 KB
testcase_10 AC 399 ms
7,552 KB
testcase_11 AC 344 ms
7,488 KB
testcase_12 AC 332 ms
7,352 KB
testcase_13 AC 394 ms
7,416 KB
testcase_14 AC 391 ms
7,248 KB
testcase_15 AC 366 ms
7,392 KB
testcase_16 AC 379 ms
7,368 KB
testcase_17 AC 316 ms
7,524 KB
testcase_18 AC 317 ms
7,408 KB
testcase_19 AC 340 ms
7,396 KB
testcase_20 AC 368 ms
7,408 KB
testcase_21 AC 361 ms
7,520 KB
testcase_22 AC 318 ms
6,696 KB
testcase_23 AC 222 ms
5,736 KB
testcase_24 AC 209 ms
5,824 KB
testcase_25 AC 103 ms
4,684 KB
testcase_26 AC 243 ms
6,292 KB
testcase_27 AC 215 ms
5,968 KB
testcase_28 AC 132 ms
5,060 KB
testcase_29 AC 106 ms
4,828 KB
testcase_30 AC 141 ms
4,956 KB
testcase_31 AC 136 ms
5,192 KB
testcase_32 AC 19 ms
4,384 KB
testcase_33 AC 57 ms
4,440 KB
testcase_34 AC 70 ms
4,476 KB
testcase_35 AC 43 ms
4,380 KB
testcase_36 AC 245 ms
5,976 KB
testcase_37 AC 287 ms
6,684 KB
testcase_38 AC 101 ms
4,924 KB
testcase_39 AC 304 ms
6,596 KB
testcase_40 AC 108 ms
4,700 KB
testcase_41 AC 97 ms
4,732 KB
testcase_42 AC 416 ms
7,340 KB
testcase_43 AC 408 ms
7,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#include <bits/stdc++.h>
using namespace std;

double EPS=1e-9,dis[310][310],X[310],Y[310];
int n,m,A[200200][4],INF=1e9+7;

void floyd(){
  rep(k,2*n){
    rep(i,2*n){
      if(dis[i][k]>INF-EPS) continue;
      rep(j,2*n){
        if(dis[k][j]>INF-EPS) continue;
        dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
      }
    }
  }
}

int main(){
  cin>>n>>m;
  rep(i,2*n){
    rep(j,2*n) if(i!=j) dis[i][j]=INF;
    cin>>X[i]>>Y[i];
  }
  rep(i,m) rep(j,4) cin>>A[i][j];
  
  auto cr=[&](int a,int b,int c)->double{
    return (X[b]-X[a])*(Y[c]-Y[a])-(Y[b]-Y[a])*(X[c]-X[a]);
  };
  auto f=[&](int a,int b,int c,int d)->int{
    return (cr(a,b,c)*cr(a,b,d)<0 && cr(c,d,a)*cr(c,d,b)<0)?0:1;
  }; 
  
  rep(i,2*n){
    for(int j=i+1;j<2*n;j++){
      int e=1;
      rep(k,n){
        if(k==i/2 || k==j/2) continue;
        if(f(i,j,2*k,2*k+1)==0) e=0;
      }
      if(e){
        double p=X[i]-X[j],q=Y[i]-Y[j];
        dis[j][i]=dis[i][j]=sqrt(p*p+q*q);
      }
    }
  }
  floyd();
  rep(i,m) printf("%.10f\n",dis[2*A[i][0]+A[i][1]-3][2*A[i][2]+A[i][3]-3]);
  
  return 0;
}
0