結果

問題 No.1041 直線大学
ユーザー keymoonkeymoon
提出日時 2021-01-15 01:36:21
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 3,154 bytes
コンパイル時間 6,797 ms
コンパイル使用メモリ 105,512 KB
実行使用メモリ 23,824 KB
最終ジャッジ日時 2023-08-16 09:46:41
合計ジャッジ時間 10,843 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
23,784 KB
testcase_01 AC 64 ms
21,804 KB
testcase_02 AC 64 ms
21,732 KB
testcase_03 AC 62 ms
21,664 KB
testcase_04 AC 65 ms
21,648 KB
testcase_05 AC 65 ms
21,736 KB
testcase_06 AC 65 ms
21,656 KB
testcase_07 AC 65 ms
23,764 KB
testcase_08 AC 65 ms
21,744 KB
testcase_09 AC 65 ms
21,740 KB
testcase_10 AC 69 ms
21,632 KB
testcase_11 AC 70 ms
23,660 KB
testcase_12 AC 70 ms
23,792 KB
testcase_13 AC 65 ms
21,744 KB
testcase_14 AC 66 ms
19,668 KB
testcase_15 AC 65 ms
21,764 KB
testcase_16 AC 66 ms
21,780 KB
testcase_17 AC 65 ms
21,716 KB
testcase_18 AC 65 ms
23,776 KB
testcase_19 AC 68 ms
23,780 KB
testcase_20 AC 64 ms
21,728 KB
testcase_21 AC 65 ms
19,632 KB
testcase_22 AC 65 ms
21,780 KB
testcase_23 AC 68 ms
21,660 KB
testcase_24 AC 67 ms
21,740 KB
testcase_25 AC 64 ms
21,748 KB
testcase_26 AC 64 ms
21,720 KB
testcase_27 AC 64 ms
23,772 KB
testcase_28 AC 63 ms
21,720 KB
testcase_29 AC 66 ms
23,780 KB
testcase_30 AC 65 ms
21,764 KB
testcase_31 AC 64 ms
21,600 KB
testcase_32 AC 64 ms
21,736 KB
testcase_33 AC 64 ms
23,696 KB
testcase_34 AC 65 ms
23,824 KB
testcase_35 AC 64 ms
19,696 KB
testcase_36 AC 65 ms
21,864 KB
testcase_37 AC 65 ms
23,700 KB
testcase_38 AC 69 ms
21,648 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