結果

問題 No.202 1円玉投げ
ユーザー nuwasoginuwasogi
提出日時 2015-11-08 16:17:29
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 2,010 ms / 5,000 ms
コード長 2,595 bytes
コンパイル時間 3,928 ms
コンパイル使用メモリ 107,400 KB
実行使用メモリ 234,352 KB
最終ジャッジ日時 2023-09-07 22:51:10
合計ジャッジ時間 76,916 ms
ジャッジサーバーID
(参考情報)
judge5 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,833 ms
232,304 KB
testcase_01 AC 2,007 ms
232,232 KB
testcase_02 AC 1,546 ms
232,304 KB
testcase_03 AC 1,546 ms
232,268 KB
testcase_04 AC 1,535 ms
234,248 KB
testcase_05 AC 1,579 ms
232,356 KB
testcase_06 AC 1,939 ms
232,140 KB
testcase_07 AC 1,986 ms
234,352 KB
testcase_08 AC 2,000 ms
230,256 KB
testcase_09 AC 1,790 ms
232,296 KB
testcase_10 AC 1,651 ms
232,224 KB
testcase_11 AC 1,744 ms
234,256 KB
testcase_12 AC 1,768 ms
234,280 KB
testcase_13 AC 1,681 ms
232,208 KB
testcase_14 AC 1,618 ms
232,232 KB
testcase_15 AC 1,786 ms
232,568 KB
testcase_16 AC 1,791 ms
232,560 KB
testcase_17 AC 1,777 ms
232,284 KB
testcase_18 AC 1,756 ms
232,160 KB
testcase_19 AC 1,750 ms
232,156 KB
testcase_20 AC 1,900 ms
232,224 KB
testcase_21 AC 1,776 ms
230,492 KB
testcase_22 AC 1,557 ms
230,244 KB
testcase_23 AC 1,550 ms
230,180 KB
testcase_24 AC 1,548 ms
232,208 KB
testcase_25 AC 1,533 ms
230,600 KB
testcase_26 AC 1,556 ms
228,276 KB
testcase_27 AC 1,533 ms
234,228 KB
testcase_28 AC 1,536 ms
230,160 KB
testcase_29 AC 1,545 ms
232,184 KB
testcase_30 AC 1,564 ms
228,128 KB
testcase_31 AC 1,554 ms
230,260 KB
testcase_32 AC 1,544 ms
234,216 KB
testcase_33 AC 1,541 ms
232,196 KB
testcase_34 AC 1,545 ms
230,444 KB
testcase_35 AC 1,767 ms
230,188 KB
testcase_36 AC 1,839 ms
232,532 KB
testcase_37 AC 2,010 ms
232,228 KB
testcase_38 AC 1,877 ms
232,200 KB
testcase_39 AC 1,529 ms
232,252 KB
testcase_40 AC 1,546 ms
232,180 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.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);
        }
    }
}
0