結果
問題 |
No.202 1円玉投げ
|
ユーザー |
![]() |
提出日時 | 2015-11-08 16:17:29 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 2,091 ms / 5,000 ms |
コード長 | 2,595 bytes |
コンパイル時間 | 3,554 ms |
コンパイル使用メモリ | 117,388 KB |
実行使用メモリ | 239,812 KB |
最終ジャッジ日時 | 2025-02-07 08:48:27 |
合計ジャッジ時間 | 79,556 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
コンパイルメッセージ
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.Generic; namespace Ichiendama { class Ichiendama { public static int Radius = 10; private int _x; private int _y; public int X { get { return _x; } } public int Y { get { return _y; } } public Ichiendama(int x, int y) { _x = x; _y = y; } // 2乗距離を返す public static double Distance2(Ichiendama a, Ichiendama b) { return (Math.Pow(a.X - b.X, 2.0) + Math.Pow(a.Y - b.Y, 2.0)); } // 重なっていればtrueを返す public static bool CheckOverlap(Ichiendama a, Ichiendama b) { if (Ichiendama.Distance2(a, b) < Math.Pow(Ichiendama.Radius * 2, 2.0)) { return true; } else { return false; } } } class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int M = 2001; int ans = 0; List<Ichiendama>[,] Valids = new List<Ichiendama>[M, M]; for (int i = 0; i < M; i++) { for (int j = 0; j < M; j++) { Valids[i, j] = new List<Ichiendama>(); } } char[] delimiter = { ' ' }; for (int i = 0; i < N; i++) { string[] s = Console.ReadLine().Split(delimiter); int[] xy = { int.Parse(s[0]), int.Parse(s[1]) }; Ichiendama newcoin = new Ichiendama(xy[0], xy[1]); bool isOverlap = false; int nx = xy[0]/10; int ny = xy[1]/10; for (int dx = Math.Max(nx - 2, 0); dx <= Math.Min(nx + 2, M-1); dx++) { for (int dy = Math.Max(ny - 2, 0); dy <= Math.Min(ny + 2, M-1); dy++) { foreach (Ichiendama v in Valids[dx, dy]) { if (Ichiendama.CheckOverlap(v, newcoin)) { isOverlap = true; break; } } } } if (isOverlap == false) { Valids[nx, ny].Add(newcoin); ans++; } } Console.WriteLine(ans); } } }