結果

問題 No.1041 直線大学
ユーザー keymoonkeymoon
提出日時 2021-01-15 01:36:21
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 3,154 bytes
コンパイル時間 946 ms
コンパイル使用メモリ 110,592 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-11-16 08:10:38
合計ジャッジ時間 3,176 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
18,944 KB
testcase_01 AC 30 ms
18,944 KB
testcase_02 AC 29 ms
18,944 KB
testcase_03 AC 30 ms
18,816 KB
testcase_04 AC 30 ms
18,944 KB
testcase_05 AC 29 ms
18,816 KB
testcase_06 AC 30 ms
18,944 KB
testcase_07 AC 30 ms
18,944 KB
testcase_08 AC 30 ms
19,072 KB
testcase_09 AC 30 ms
18,944 KB
testcase_10 AC 34 ms
19,200 KB
testcase_11 AC 33 ms
18,944 KB
testcase_12 AC 34 ms
19,072 KB
testcase_13 AC 31 ms
18,944 KB
testcase_14 AC 33 ms
19,072 KB
testcase_15 AC 32 ms
19,072 KB
testcase_16 AC 32 ms
19,072 KB
testcase_17 AC 31 ms
19,072 KB
testcase_18 AC 32 ms
19,072 KB
testcase_19 AC 32 ms
19,072 KB
testcase_20 AC 31 ms
19,200 KB
testcase_21 AC 30 ms
19,072 KB
testcase_22 AC 29 ms
19,072 KB
testcase_23 AC 31 ms
18,816 KB
testcase_24 AC 30 ms
18,944 KB
testcase_25 AC 30 ms
19,072 KB
testcase_26 AC 33 ms
18,944 KB
testcase_27 AC 31 ms
18,944 KB
testcase_28 AC 31 ms
19,072 KB
testcase_29 AC 30 ms
19,072 KB
testcase_30 AC 29 ms
18,816 KB
testcase_31 AC 28 ms
19,072 KB
testcase_32 AC 29 ms
18,816 KB
testcase_33 AC 29 ms
18,944 KB
testcase_34 AC 28 ms
18,944 KB
testcase_35 AC 28 ms
19,200 KB
testcase_36 AC 28 ms
18,944 KB
testcase_37 AC 27 ms
18,944 KB
testcase_38 AC 32 ms
18,944 KB
testcase_39 AC 28 ms
19,072 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;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).Select(x => new Vector(x[0], x[1])).ToArray();
        int res = 0;
        for (int i = 0; i < n; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                int cnt = 0;
                var d1 = a[j] - a[i];
                for (int k = 0; k < n; k++)
                {
                    var d2 = a[k] - a[i];
                    if (Vector.CrossProduct(d1, d2) == 0) cnt++;
                }
                res = Max(res, cnt);
            }
        }
        Console.WriteLine(res);
    }
}


struct Vector
{
    public int x;
    public int y;
    public int this[int index]
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get { if (index == 0) return x; else return y; }
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        set { if (index == 0) x = value; else y = value; }
    }
    public int Length => x * x + y * y;
    public double SqrtLength => Math.Sqrt(Length);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public Vector(int x, int y) { this.x = x; this.y = y; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public Vector RotateVector(double radian) => new Vector((int)(x * Math.Cos(radian) - y * Math.Sin(radian)), (int)(x * Math.Sin(radian) + y * Math.Cos(radian)));
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static public int CrossProduct(Vector a, Vector b) => a.x * b.y - a.y * b.x;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static public int InnerProduct(Vector a, Vector b) => a.x * b.x + a.y * b.y;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static Vector operator +(Vector a, Vector b) => new Vector(a.x + b.x, a.y + b.y);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static Vector operator -(Vector a, Vector b) => new Vector(a.x - b.x, a.y - b.y);
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool operator ==(Vector a, Vector b) => a.x == b.x && a.y == b.y;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool operator !=(Vector a, Vector b) => a.x != b.x || a.y != b.y;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public override bool Equals(object obj) => this == (Vector)obj;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public override int GetHashCode() => x.GetHashCode() * 1000000007 + y.GetHashCode();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public override string ToString() => $"({x},{y})";
}
0