結果

問題 No.199 星を描こう
ユーザー GrenacheGrenache
提出日時 2016-06-06 22:48:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 2,060 bytes
コンパイル時間 3,804 ms
コンパイル使用メモリ 77,420 KB
実行使用メモリ 58,052 KB
最終ジャッジ日時 2023-08-28 18:46:38
合計ジャッジ時間 7,961 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
56,300 KB
testcase_01 AC 118 ms
58,052 KB
testcase_02 AC 118 ms
55,984 KB
testcase_03 AC 118 ms
55,708 KB
testcase_04 AC 118 ms
56,528 KB
testcase_05 AC 117 ms
56,088 KB
testcase_06 AC 117 ms
55,976 KB
testcase_07 AC 118 ms
55,988 KB
testcase_08 AC 117 ms
55,968 KB
testcase_09 AC 119 ms
56,288 KB
testcase_10 AC 117 ms
55,752 KB
testcase_11 AC 119 ms
56,160 KB
testcase_12 AC 117 ms
55,740 KB
testcase_13 AC 117 ms
56,112 KB
testcase_14 AC 118 ms
55,864 KB
testcase_15 AC 118 ms
55,980 KB
testcase_16 AC 119 ms
55,456 KB
testcase_17 AC 118 ms
55,976 KB
testcase_18 AC 123 ms
55,484 KB
testcase_19 AC 121 ms
55,476 KB
testcase_20 AC 120 ms
55,980 KB
testcase_21 AC 118 ms
55,684 KB
testcase_22 AC 117 ms
56,096 KB
testcase_23 AC 118 ms
55,936 KB
testcase_24 AC 118 ms
55,492 KB
testcase_25 AC 117 ms
55,812 KB
testcase_26 AC 118 ms
55,844 KB
testcase_27 AC 117 ms
56,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;


public class Main_yukicoder199 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        List<Pair> xy = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
        	xy.add(new Pair(sc.nextInt(), sc.nextInt()));
        }
        Collections.sort(xy);

        List<Pair> ch = new ArrayList<>();

        for (int i = 0; i < xy.size(); i++) {
        	while (ch.size() > 1
        			&& (Geom.cross(ch.get(ch.size() - 1).a - ch.get(ch.size() - 2).a, ch.get(ch.size() - 1).b - ch.get(ch.size() - 2).b, xy.get(i).a - ch.get(ch.size() - 1).a, xy.get(i).b - ch.get(ch.size() - 1).b)) <= 0) {
        		ch.remove(ch.size() - 1);
        	}
        	ch.add(xy.get(i));
        }
        int t = ch.size();
        for (int i = xy.size() - 1; i >= 0; i--) {
        	while (ch.size() > t
        			&& (Geom.cross(ch.get(ch.size() - 1).a - ch.get(ch.size() - 2).a, ch.get(ch.size() - 1).b - ch.get(ch.size() - 2).b, xy.get(i).a - ch.get(ch.size() - 1).a, xy.get(i).b - ch.get(ch.size() - 1).b)) <= 0) {
        		ch.remove(ch.size() - 1);
        	}
        	ch.add(xy.get(i));
        }

        if (ch.size() == 6) {
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }

        sc.close();
    }

    private static class Pair implements Comparable<Pair> {
    	int a;
    	int b;

    	Pair(int a, int b) {
    		this.a = a;
    		this.b = b;
    	}

		@Override
		public int compareTo(Pair o) {
			if (this.a == o.a) {
				return Integer.compare(this.b, o.b);
			}

			return Integer.compare(this.a, o.a);
		}

		@Override
		public String toString() {
			return "[" + Integer.toString(a) + " " + Integer.toString(b) + "]";
		}
    }

	@SuppressWarnings("unused")
	private static class Geom {
		static int dot(int xa, int ya, int xb, int yb) {
			return xa * xb + ya * yb;
		}

		static int cross(int xa, int ya, int xb, int yb) {
			return xa * yb - xb * ya;
		}

		static int sumofsquare(int xa, int ya) {
			return xa * xa + ya * ya;
		}

	}
}
0