結果

問題 No.635 自然門松列
ユーザー 👑 kmjpkmjp
提出日時 2018-01-19 22:08:41
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,692 bytes
コンパイル時間 1,211 ms
コンパイル使用メモリ 145,984 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-05 13:08:11
合計ジャッジ時間 2,287 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
long double X[3],Y[3];

int hoge(long double t) {
	double a=X[0]+t*Y[0];
	double b=X[1]+t*Y[1];
	double c=X[2]+t*Y[2];
	if(t<0) return 0;
	
	if(abs(a-b)<1e-12) return 0;
	if(abs(a-c)<1e-12) return 0;
	if(abs(b-c)<1e-12) return 0;
	if(a>b && c>b) return 1;
	if(a<b && c<b) return 1;
	return 0;
}

int ok() {
	
	if(X[0]==X[1] && Y[0]==Y[1]) return 0;
	if(X[0]==X[2] && Y[0]==Y[2]) return 0;
	if(X[1]==X[2] && Y[1]==Y[2]) return 0;
	if(hoge(0)) return 1;
	if(hoge(1<<30)) return 1;
	
	int C[2]={};
	double T=0;
	if(X[0]==X[1] && hoge(1e-5)) return 1;
	if(Y[0]!=Y[1]) {
		T=1.0*(X[1]-X[0])/(Y[0]-Y[1]);
		if(hoge(T+(1e-5))) return 1;
		if(hoge(T-(1e-5))) return 1;
	}
	if(X[2]==X[1] && hoge(1e-4)) return 1;
	if(Y[2]!=Y[1]) {
		T=1.0*(X[1]-X[2])/(Y[2]-Y[1]);
		if(hoge(T+(1e-5))) return 1;
		if(hoge(T-(1e-5))) return 1;
	}
	return 0;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	while(N--) {
		cin>>X[0]>>X[1]>>X[2]>>Y[0]>>Y[1]>>Y[2];
		
		if(ok()) _P("YES\n");
		else _P("NO\n");
		
		
		
		
		
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0