結果

問題 No.199 星を描こう
ユーザー kuuso1kuuso1
提出日時 2015-04-29 00:50:41
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 2,166 bytes
コンパイル時間 1,080 ms
コンパイル使用メモリ 116,512 KB
実行使用メモリ 26,336 KB
最終ジャッジ日時 2024-06-09 13:49:37
合計ジャッジ時間 2,310 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
24,040 KB
testcase_01 AC 23 ms
24,164 KB
testcase_02 AC 22 ms
24,044 KB
testcase_03 AC 23 ms
24,240 KB
testcase_04 AC 22 ms
24,424 KB
testcase_05 AC 24 ms
24,364 KB
testcase_06 AC 23 ms
26,296 KB
testcase_07 AC 24 ms
24,172 KB
testcase_08 AC 23 ms
24,036 KB
testcase_09 AC 24 ms
21,940 KB
testcase_10 AC 24 ms
22,068 KB
testcase_11 AC 23 ms
24,136 KB
testcase_12 AC 24 ms
24,236 KB
testcase_13 AC 24 ms
24,244 KB
testcase_14 AC 24 ms
26,176 KB
testcase_15 AC 23 ms
24,172 KB
testcase_16 AC 24 ms
24,132 KB
testcase_17 AC 22 ms
24,036 KB
testcase_18 AC 24 ms
26,040 KB
testcase_19 AC 25 ms
26,044 KB
testcase_20 AC 23 ms
24,164 KB
testcase_21 AC 23 ms
23,988 KB
testcase_22 AC 24 ms
23,912 KB
testcase_23 AC 23 ms
24,124 KB
testcase_24 AC 24 ms
24,296 KB
testcase_25 AC 24 ms
26,336 KB
testcase_26 AC 24 ms
23,988 KB
testcase_27 AC 21 ms
22,200 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