結果

問題 No.1265 Balloon Survival
ユーザー azukunazukun
提出日時 2020-10-23 22:25:10
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 4,543 bytes
コンパイル時間 1,997 ms
コンパイル使用メモリ 70,628 KB
実行使用メモリ 41,348 KB
最終ジャッジ日時 2023-09-28 16:23:31
合計ジャッジ時間 8,191 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
23,792 KB
testcase_01 AC 68 ms
23,684 KB
testcase_02 AC 68 ms
23,848 KB
testcase_03 AC 69 ms
23,824 KB
testcase_04 AC 68 ms
21,800 KB
testcase_05 AC 68 ms
21,616 KB
testcase_06 AC 69 ms
21,892 KB
testcase_07 AC 69 ms
21,780 KB
testcase_08 AC 69 ms
21,840 KB
testcase_09 AC 68 ms
21,720 KB
testcase_10 AC 68 ms
23,868 KB
testcase_11 AC 68 ms
23,856 KB
testcase_12 AC 68 ms
21,712 KB
testcase_13 AC 69 ms
21,720 KB
testcase_14 AC 93 ms
25,192 KB
testcase_15 AC 86 ms
23,092 KB
testcase_16 AC 76 ms
24,196 KB
testcase_17 AC 178 ms
35,588 KB
testcase_18 AC 79 ms
22,252 KB
testcase_19 AC 76 ms
24,256 KB
testcase_20 AC 92 ms
25,168 KB
testcase_21 AC 120 ms
23,244 KB
testcase_22 AC 102 ms
26,472 KB
testcase_23 AC 103 ms
24,616 KB
testcase_24 AC 276 ms
37,224 KB
testcase_25 AC 281 ms
37,208 KB
testcase_26 AC 276 ms
39,248 KB
testcase_27 AC 277 ms
41,348 KB
testcase_28 AC 279 ms
37,208 KB
testcase_29 AC 277 ms
37,232 KB
testcase_30 AC 277 ms
39,300 KB
testcase_31 AC 281 ms
37,252 KB
testcase_32 AC 280 ms
37,144 KB
testcase_33 AC 276 ms
37,264 KB
testcase_34 AC 68 ms
21,828 KB
testcase_35 AC 68 ms
21,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;

// (づ°ω°)づミe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        int n = ReadInt();
        var a = ReadIntMatrix(n);

        var e = new List<(long, int, int)>();
        for (int i = 0; i < n; i++)
            for (int j = i + 1; j < n; j++)
               e.Add((1L * (a[j][0] - a[i][0]) * (a[j][0] - a[i][0]) + 1L * (a[i][1] - a[j][1]) * (a[i][1] - a[j][1]), i, j));

        e.Sort((e1, e2) => e1.Item1.CompareTo(e2.Item1));
        var f = new bool[n];
        int ans = 0;
        foreach (var t in e)
            if (!f[t.Item2] && !f[t.Item3])
            {
                if (t.Item2 == 0)
                {
                    ans++;
                    f[t.Item3] = true;
                }
                else
                {
                    f[t.Item2] = f[t.Item3] = true;
                }
            }

        Write(ans);
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUGLOCAL
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }
        return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array) writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }
    #endregion
}
0