結果

問題 No.2355 Unhappy Back Dance
ユーザー 👑 kakel-sankakel-san
提出日時 2023-08-09 09:01:11
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 2,750 ms / 6,000 ms
コード長 1,754 bytes
コンパイル時間 3,581 ms
コンパイル使用メモリ 112,808 KB
実行使用メモリ 52,848 KB
最終ジャッジ日時 2024-04-26 23:34:14
合計ジャッジ時間 39,640 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
25,200 KB
testcase_01 AC 32 ms
25,072 KB
testcase_02 AC 32 ms
23,348 KB
testcase_03 AC 32 ms
27,240 KB
testcase_04 AC 32 ms
27,116 KB
testcase_05 AC 30 ms
27,368 KB
testcase_06 AC 614 ms
52,780 KB
testcase_07 AC 604 ms
48,436 KB
testcase_08 AC 626 ms
50,724 KB
testcase_09 AC 633 ms
50,608 KB
testcase_10 AC 825 ms
52,848 KB
testcase_11 AC 795 ms
48,808 KB
testcase_12 AC 663 ms
50,868 KB
testcase_13 AC 653 ms
52,620 KB
testcase_14 AC 818 ms
48,808 KB
testcase_15 AC 32 ms
25,456 KB
testcase_16 AC 2,750 ms
48,584 KB
testcase_17 AC 2,702 ms
48,548 KB
testcase_18 AC 2,696 ms
48,904 KB
testcase_19 AC 2,714 ms
48,720 KB
testcase_20 AC 2,670 ms
50,768 KB
testcase_21 AC 1,133 ms
47,352 KB
testcase_22 AC 221 ms
31,752 KB
testcase_23 AC 236 ms
29,472 KB
testcase_24 AC 2,447 ms
48,348 KB
testcase_25 AC 1,330 ms
48,608 KB
testcase_26 AC 1,315 ms
48,604 KB
testcase_27 AC 1,118 ms
47,112 KB
testcase_28 AC 52 ms
25,072 KB
testcase_29 AC 86 ms
29,580 KB
testcase_30 AC 2,225 ms
47,856 KB
testcase_31 AC 1,622 ms
45,876 KB
testcase_32 AC 175 ms
29,588 KB
testcase_33 AC 906 ms
48,588 KB
testcase_34 AC 40 ms
25,456 KB
testcase_35 AC 56 ms
25,328 KB
testcase_36 AC 1,127 ms
47,240 KB
testcase_37 AC 614 ms
46,900 KB
testcase_38 AC 746 ms
48,580 KB
testcase_39 AC 595 ms
46,800 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 static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    static long[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var map = NArr(n);
        var ans = 0;
        for (var i = 0; i < n; ++i)
        {
            var list = new List<Rad>();
            for (var j = 0; j < n; ++j)
            {
                if (i == j) continue;
                list.Add(new Rad(map[j][0] - map[i][0], map[j][1] - map[i][1]));
            }
            list.Sort((l, r) =>
            {
                var d = l.Ch.CompareTo(r.Ch);
                if (d != 0) return d;
                return l.Pa.CompareTo(r.Pa);
            });
            for (var j = 0; j + 1 < list.Count; ++j)
            {
                if (list[j].Ch == list[j + 1].Ch && list[j].Pa == list[j + 1].Pa)
                {
                    ++ans;
                    break;
                }
            }
        }
        WriteLine(ans);
    }
    class Rad
    {
        public long Ch;
        public long Pa;
        public Rad(long x, long y)
        {
            var gcd = GCD(x, y);
            Ch = y / gcd;
            Pa = x / gcd;
        }
    }
    static long GCD(long a, long b)
    {
        if (a < 0) a = -a;
        if (b < 0) b = -b;
        if (a < b) return GCD(b, a);
        if (b == 0) return a;
        if (a % b == 0) return b;
        return GCD(b, a % b);
    }
}
0