結果

問題 No.199 星を描こう
ユーザー kou6839
提出日時 2015-04-30 22:36:43
言語 Java
(openjdk 23)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 1,877 bytes
コンパイル時間 2,504 ms
コンパイル使用メモリ 79,840 KB
実行使用メモリ 54,496 KB
最終ジャッジ日時 2024-12-30 03:35:44
合計ジャッジ時間 7,707 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Scanner;


public class Main {
	static boolean cul(int[] x,int []y, ArrayList<Integer> use,ArrayList<Integer> not){
		int one = (x[use.get(1)]-x[use.get(0)])*(y[not.get(0)]-y[use.get(0)])-(y[use.get(1)]-y[use.get(0)])*(x[not.get(0)]-x[use.get(0)]);
		int two = (x[use.get(2)]-x[use.get(1)])*(y[not.get(0)]-y[use.get(1)])-(y[use.get(2)]-y[use.get(1)])*(x[not.get(0)]-x[use.get(1)]);
		int three=(x[use.get(0)]-x[use.get(2)])*(y[not.get(0)]-y[use.get(2)])-(y[use.get(0)]-y[use.get(2)])*(x[not.get(0)]-x[use.get(2)]);
		if((one>0 && two >0 && three >0 )||(one<0 && two <0 && three <0) || one==0 || two ==0 || three==0){
			return false;
		}else{

		}
		one = (x[use.get(1)]-x[use.get(0)])*(y[not.get(1)]-y[use.get(0)])-(y[use.get(1)]-y[use.get(0)])*(x[not.get(1)]-x[use.get(0)]);
		two = (x[use.get(2)]-x[use.get(1)])*(y[not.get(1)]-y[use.get(1)])-(y[use.get(2)]-y[use.get(1)])*(x[not.get(1)]-x[use.get(1)]);
		three=(x[use.get(0)]-x[use.get(2)])*(y[not.get(1)]-y[use.get(2)])-(y[use.get(0)]-y[use.get(2)])*(x[not.get(1)]-x[use.get(2)]);
		if((one>0 && two >0 && three >0 )||(one<0 && two <0 && three <0) || one==0 || two ==0 || three==0){
			return false;
		}else{
		}
		return true;
	}
	public static void main(String[] args){
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int[] x = new int[5];
		int[] y = new int[5];
		for(int i=0;i<5;i++){
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();
		}
		for(int i=0; i< (1<<5);i++){
			if(Integer.bitCount(i)!=3) continue;
			ArrayList<Integer> use = new ArrayList<>();
			ArrayList<Integer> not = new ArrayList<>();
			for(int j=0;j<5;j++){
				 if((i >> j &1) >0){
					 use.add(j);
				 }else{
					 not.add(j);
				 }
			}
			if(!cul(x, y, use, not)){
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");

	}
}
0