結果

問題 No.199 星を描こう
ユーザー kuuso1kuuso1
提出日時 2015-04-29 00:50:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 2,166 bytes
コンパイル時間 2,286 ms
コンパイル使用メモリ 105,576 KB
実行使用メモリ 22,896 KB
最終ジャッジ日時 2023-08-28 18:38:05
合計ジャッジ時間 5,026 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
20,812 KB
testcase_01 AC 57 ms
20,596 KB
testcase_02 AC 59 ms
22,896 KB
testcase_03 AC 59 ms
20,768 KB
testcase_04 AC 58 ms
20,732 KB
testcase_05 AC 58 ms
20,676 KB
testcase_06 AC 58 ms
22,636 KB
testcase_07 AC 57 ms
20,752 KB
testcase_08 AC 57 ms
22,772 KB
testcase_09 AC 58 ms
22,716 KB
testcase_10 AC 58 ms
22,788 KB
testcase_11 AC 57 ms
20,700 KB
testcase_12 AC 56 ms
20,732 KB
testcase_13 AC 57 ms
20,696 KB
testcase_14 AC 57 ms
20,736 KB
testcase_15 AC 59 ms
20,828 KB
testcase_16 AC 59 ms
20,780 KB
testcase_17 AC 60 ms
22,768 KB
testcase_18 AC 58 ms
20,800 KB
testcase_19 AC 56 ms
18,680 KB
testcase_20 AC 57 ms
22,776 KB
testcase_21 AC 57 ms
22,768 KB
testcase_22 AC 57 ms
20,812 KB
testcase_23 AC 59 ms
20,816 KB
testcase_24 AC 58 ms
20,824 KB
testcase_25 AC 58 ms
22,776 KB
testcase_26 AC 59 ms
22,760 KB
testcase_27 AC 59 ms
20,660 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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));}
}
0