結果
| 問題 | No.199 星を描こう |
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2015-04-29 00:50:41 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 2,000 ms |
| コード長 | 2,166 bytes |
| コンパイル時間 | 1,201 ms |
| コンパイル使用メモリ | 107,264 KB |
| 実行使用メモリ | 18,048 KB |
| 最終ジャッジ日時 | 2024-12-30 03:32:37 |
| 合計ジャッジ時間 | 3,240 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
class TEST{
static void Main(){
Sol mySol =new Sol();
mySol.Solve();
}
}
class Sol{
public void Solve(){
List<Pair> L=new List<Pair>();
for(int i=0;i<5;i++){
var d=ria();
L.Add(new Pair(d[0],d[1]));
}
Console.WriteLine((GrahamScan(L).Count==5)?"YES":"NO");
}
public Sol(){
}
public class Pair{
public int X;
public int Y;
public Pair(int x,int y){
X=x;Y=y;
}
public static Pair operator-(Pair p,Pair q){
return new Pair(p.X-q.X,p.Y-q.Y);
}
public static int det(Pair p,Pair q){
return (p.X*q.Y-p.Y*q.X);
}
}
public static List<Pair> GrahamScan(List<Pair> L_){
List<Pair> L=new List<Pair>(L_);
L.Sort((x,y)=>x.X.CompareTo(y.X)==0?x.Y.CompareTo(y.Y):x.X.CompareTo(y.X));
List<Pair> ret=new List<Pair>();
int k=0;
//右半分
for(int i=0;i<L.Count;i++){
//末尾削除はO(1)なのでどんどん使う。
k=ret.Count;
while(k>1 && det((ret[k-1].X-ret[k-2].X),(ret[k-1].Y-ret[k-2].Y),(L[i].X-ret[k-1].X),(L[i].Y-ret[k-1].Y))<=0){
ret.RemoveAt(k-1);
k=ret.Count;
}
ret.Add(L[i]);
}
//左半分
int t=ret.Count;
for(int i=L.Count-2;i>=0;i--){
//末尾削除はO(1)なのでどんどん使う。
k=ret.Count;
while(k>t && det((ret[k-1].X-ret[k-2].X),(ret[k-1].Y-ret[k-2].Y),(L[i].X-ret[k-1].X),(L[i].Y-ret[k-1].Y))<=0){
ret.RemoveAt(k-1);
k=ret.Count;
}
ret.Add(L[i]);
}
ret.RemoveAt(ret.Count-1);
return ret;
}
static int det(int a,int b,int c,int d){
return a*d-b*c;
}
static String rs(){return Console.ReadLine();}
static int ri(){return int.Parse(Console.ReadLine());}
static long rl(){return long.Parse(Console.ReadLine());}
static double rd(){return double.Parse(Console.ReadLine());}
static String[] rsa(){return Console.ReadLine().Split(' ');}
static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
kuuso1