結果
問題 | No.199 星を描こう |
ユーザー | eitaho |
提出日時 | 2015-06-11 13:56:01 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 3,890 bytes |
コンパイル時間 | 1,325 ms |
コンパイル使用メモリ | 117,324 KB |
実行使用メモリ | 27,684 KB |
最終ジャッジ日時 | 2024-06-09 13:51:26 |
合計ジャッジ時間 | 2,789 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
25,648 KB |
testcase_01 | AC | 31 ms
27,476 KB |
testcase_02 | AC | 30 ms
25,556 KB |
testcase_03 | AC | 29 ms
25,636 KB |
testcase_04 | AC | 29 ms
27,420 KB |
testcase_05 | AC | 29 ms
25,432 KB |
testcase_06 | AC | 29 ms
23,220 KB |
testcase_07 | AC | 29 ms
25,520 KB |
testcase_08 | AC | 28 ms
25,436 KB |
testcase_09 | AC | 28 ms
25,564 KB |
testcase_10 | AC | 28 ms
25,264 KB |
testcase_11 | AC | 33 ms
25,768 KB |
testcase_12 | AC | 27 ms
25,520 KB |
testcase_13 | AC | 28 ms
25,564 KB |
testcase_14 | AC | 28 ms
25,432 KB |
testcase_15 | AC | 28 ms
27,564 KB |
testcase_16 | AC | 28 ms
25,392 KB |
testcase_17 | AC | 28 ms
27,552 KB |
testcase_18 | AC | 29 ms
25,520 KB |
testcase_19 | AC | 30 ms
27,560 KB |
testcase_20 | AC | 32 ms
25,508 KB |
testcase_21 | AC | 28 ms
25,308 KB |
testcase_22 | AC | 28 ms
25,560 KB |
testcase_23 | AC | 28 ms
27,684 KB |
testcase_24 | AC | 28 ms
23,472 KB |
testcase_25 | AC | 28 ms
25,892 KB |
testcase_26 | AC | 28 ms
23,480 KB |
testcase_27 | AC | 30 ms
25,688 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.IO; using System.Linq; using System.Text; using System.Collections.Generic; using System.Diagnostics; using System.Numerics; using Enu = System.Linq.Enumerable; class Program { public void Solve() { var vec = Enu.Range(0, 5).Select(i => new Vector2D(Reader.Int(), Reader.Int())).ToList(); if (ConvexHull(vec).Count == 5) Console.WriteLine("YES"); else Console.WriteLine("NO"); } List<Vector2D> ConvexHull(List<Vector2D> Ps) { Ps.Sort(); var res = new List<Vector2D>(); for (int i = 0; i < Ps.Count; i++) { while (res.Count > 1 && (res[res.Count - 1] - res[res.Count - 2]).Det(Ps[i] - res[res.Count - 1]) <= 0) res.RemoveAt(res.Count - 1); res.Add(Ps[i]); } for (int i = Ps.Count - 2, t = res.Count; i >= 0; i--) { while (res.Count > t && (res[res.Count - 1] - res[res.Count - 2]).Det(Ps[i] - res[res.Count - 1]) <= 0) res.RemoveAt(res.Count - 1); res.Add(Ps[i]); } res.RemoveAt(res.Count - 1); return res; } struct Vector2D : IEquatable<Vector2D>, IComparable<Vector2D> { public long X, Y; public Vector2D(long x, long y) { X = x; Y = y; } public static Vector2D operator +(Vector2D a, Vector2D b) { return new Vector2D(a.X + b.X, a.Y + b.Y); } public static Vector2D operator -(Vector2D a, Vector2D b) { return new Vector2D(a.X - b.X, a.Y - b.Y); } public long DistSquare(Vector2D b) { return (X - b.X) * (X - b.X) + (Y - b.Y) * (Y - b.Y); } public double Dist(Vector2D b) { return Math.Sqrt(DistSquare(b)); } public long InnerProduct(Vector2D b) { return X * b.X + Y * b.Y; } public long Det(Vector2D b) { return X * b.Y - Y * b.X; } public override int GetHashCode() { return (int)(X * 10007 + Y); } public bool Equals(Vector2D b) { return X == b.X && Y == b.Y; } public int CompareTo(Vector2D b) { return X != b.X ? Math.Sign(X - b.X) : Math.Sign(Y - b.Y); } } } class Entry { static void Main() { new Program().Solve(); } } class Reader { private static TextReader reader = Console.In; private static readonly char[] separator = { ' ' }; private static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries; private static string[] A = new string[0]; private static int i; private static void Init() { A = new string[0]; } public static void Set(TextReader r) { reader = r; Init(); } public static void Set(string file) { reader = new StreamReader(file); Init(); } public static bool HasNext() { return CheckNext(); } public static string String() { return Next(); } public static int Int() { return int.Parse(Next()); } public static long Long() { return long.Parse(Next()); } public static double Double() { return double.Parse(Next()); } public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); } public static int[] IntArray(int N) { return Enu.Range(0, N).Select(i => Int()).ToArray(); } public static int[][] IntTable(int H) { return Enu.Range(0, H).Select(i => IntLine()).ToArray(); } public static string[] StringArray(int N) { return Enu.Range(0, N).Select(i => Line()).ToArray(); } public static string Line() { return reader.ReadLine().Trim(); } private static string[] Split(string s) { return s.Split(separator, op); } private static string Next() { CheckNext(); return A[i++]; } private static bool CheckNext() { if (i < A.Length) return true; string line = reader.ReadLine(); if (line == null) return false; if (line == "") return CheckNext(); A = Split(line); i = 0; return true; } }