結果

問題 No.2376 障害物競プロ
ユーザー 沙耶花沙耶花
提出日時 2023-07-10 19:11:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 683 ms / 4,000 ms
コード長 1,442 bytes
コンパイル時間 6,053 ms
コンパイル使用メモリ 261,660 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-10-10 01:16:49
合計ジャッジ時間 67,525 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 402 ms
4,348 KB
testcase_05 AC 554 ms
4,360 KB
testcase_06 AC 224 ms
4,356 KB
testcase_07 AC 631 ms
4,396 KB
testcase_08 AC 638 ms
4,380 KB
testcase_09 AC 587 ms
4,368 KB
testcase_10 AC 592 ms
4,380 KB
testcase_11 AC 564 ms
4,376 KB
testcase_12 AC 541 ms
4,464 KB
testcase_13 AC 620 ms
4,360 KB
testcase_14 AC 599 ms
4,440 KB
testcase_15 AC 563 ms
4,428 KB
testcase_16 AC 593 ms
4,508 KB
testcase_17 AC 548 ms
4,380 KB
testcase_18 AC 516 ms
4,384 KB
testcase_19 AC 644 ms
4,392 KB
testcase_20 AC 646 ms
4,384 KB
testcase_21 AC 657 ms
4,384 KB
testcase_22 AC 508 ms
4,384 KB
testcase_23 AC 312 ms
4,380 KB
testcase_24 AC 413 ms
4,384 KB
testcase_25 AC 195 ms
4,380 KB
testcase_26 AC 457 ms
4,388 KB
testcase_27 AC 403 ms
4,384 KB
testcase_28 AC 208 ms
4,384 KB
testcase_29 AC 189 ms
4,384 KB
testcase_30 AC 142 ms
4,380 KB
testcase_31 AC 215 ms
4,384 KB
testcase_32 AC 27 ms
4,380 KB
testcase_33 AC 70 ms
4,380 KB
testcase_34 AC 106 ms
4,384 KB
testcase_35 AC 77 ms
4,380 KB
testcase_36 AC 321 ms
4,384 KB
testcase_37 AC 491 ms
4,384 KB
testcase_38 AC 185 ms
4,384 KB
testcase_39 AC 440 ms
4,388 KB
testcase_40 AC 85 ms
4,384 KB
testcase_41 AC 189 ms
4,384 KB
testcase_42 AC 683 ms
4,380 KB
testcase_43 AC 655 ms
4,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001


int main(){
	
	int n,m;
	cin>>n>>m;
	
	vector<long long> x(n*2),y(n*2);//,z(n),w(n);
	rep(i,n*2){
		cin>>x[i]>>y[i];
	}
	vector d(n*2,vector<double>(n*2,1e18));
	rep(i,n*2){
		rep(j,n*2){
			if(i==j)d[i][j] = 0.0;
			bool f = false;
			if(i%2==0 && i+1==j)f = true;
			else{
				f = true;
				
				rep(k,n){
					if(k==i/2 || k==j/2)continue;
					long long t = 1;
					long long dx0 = x[j]-x[i],dy0 = y[j]-y[i];
					long long dx1 = x[k*2]-x[j], dy1 = y[k*2]-y[j];
					t *= dx0*dy1 - dx1*dy0;
					dx1 = x[k*2+1]-x[j], dy1 = y[k*2+1]-y[j];
					t *= dx0*dy1 - dx1*dy0;
					if(t<0){
						dx0 = x[k*2]-x[k*2+1],dy0 = y[k*2]-y[k*2+1];
						dx1 = x[k*2+1]-x[i], dy1 = y[k*2+1]-y[i];
						t = 1;
						t *= dx0*dy1 - dx1*dy0;
						dx1 = x[k*2+1]-x[j], dy1 = y[k*2+1]-y[j];
						t *= dx0*dy1 - dx1*dy0;
						if(t<0){
							f = false;
							break;
						}
					}
				}
				if(f){
					d[i][j] = hypot(x[j]-x[i],y[j]-y[i]);
				}
			}
		}
	}
	
	rep(i,n*2){
		rep(j,n*2){
			rep(k,n*2){
				d[j][k] = min(d[j][k],d[j][i] + d[i][k]);
			}
		}
	}
	
	rep(_,m){
		int a,b,c,D;
		cin>>a>>b>>c>>D;
		a--,b--,c--,D--;
		cout<<fixed<<setprecision(10)<<d[a*2 + b][c*2 + D]<<endl;
	}
	
	return 0;
}
0