結果

問題 No.635 自然門松列
ユーザー kotatsugame
提出日時 2020-03-07 05:52:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 650 ms
コード長 690 bytes
コンパイル時間 670 ms
コンパイル使用メモリ 74,176 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-14 11:14:01
合計ジャッジ時間 1,675 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N;
int X[3],Y[3];
main()
{
	cin>>N;
	for(;N--;)
	{
		for(int i=0;i<3;i++)cin>>X[i];
		for(int i=0;i<3;i++)cin>>Y[i];
		vector<int>id={0,1,2};
		bool flag=false;
		do{
			if(id[1]==1)continue;
			double L=0,R=1e15;
			for(int i=0;i<2;i++)
			{
				long ax=X[id[i]],ay=Y[id[i]],bx=X[id[i+1]],by=Y[id[i+1]];
				if(ay==by)
				{
					if(bx-ax<0);
					else R=-1;
				}
				else if(ay>by)
				{
					L=max(L,(bx-ax)/(double)(ay-by));
				}
				else
				{
					R=min(R,(bx-ax)/(double)(ay-by));
				}
			}
			if(L<R)flag=true;
		}while(next_permutation(id.begin(),id.end()));
		cout<<(flag?"YES":"NO")<<endl;
	}
}
0