結果

問題 No.635 自然門松列
ユーザー furafura
提出日時 2020-10-19 03:27:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 671 bytes
コンパイル時間 2,345 ms
コンパイル使用メモリ 203,304 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-28 12:32:42
合計ジャッジ時間 3,766 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 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 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

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

using namespace std;

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};
	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((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