結果

問題 No.635 自然門松列
ユーザー furafura
提出日時 2020-10-19 03:31:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 650 ms
コード長 777 bytes
コンパイル時間 2,136 ms
コンパイル使用メモリ 204,888 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-28 12:37:54
合計ジャッジ時間 3,447 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const double EPS=1e-8;

void solve(){
	int x[3],v[3];
	rep(i,3) scanf("%d",&x[i]);
	rep(i,3) scanf("%d",&v[i]);

	vector<double> T={0,1e9};
	rep(i,3) rep(j,3) if(i!=j) {
		if(x[i]<x[j] && v[i]>v[j]){
			// x_i+v_i*t = x_j+v_j*t <=> t = (x_j-x_i)/(v_i-v_j)
			T.emplace_back(double(x[j]-x[i])/(v[i]-v[j]));
		}
	}

	sort(T.begin(),T.end());

	rep(i,T.size()-1){
		double t=(T[i]+T[i+1])/2;
		double a[3];
		rep(j,3) a[j]=x[j]+v[j]*t;
		if(abs(a[0]-a[1])>EPS && abs(a[1]-a[2])>EPS && abs(a[0]-a[2])>EPS){
			if((a[0]>a[1] && a[1]<a[2]) || (a[0]<a[1] && a[1]>a[2])){
				puts("YES");
				return;
			}
		}
	}
	puts("NO");
}

int main(){
	int q; scanf("%d",&q); rep(_,q) solve();
	return 0;
}
0