結果
| 問題 | No.199 星を描こう |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-06-06 22:48:13 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 159 ms / 2,000 ms |
| コード長 | 2,060 bytes |
| コンパイル時間 | 4,779 ms |
| コンパイル使用メモリ | 83,588 KB |
| 実行使用メモリ | 41,212 KB |
| 最終ジャッジ日時 | 2024-12-30 03:50:17 |
| 合計ジャッジ時間 | 10,513 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
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;
}
}
}