結果
| 問題 |
No.1041 直線大学
|
| コンテスト | |
| ユーザー |
keymoon
|
| 提出日時 | 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 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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})";
}
keymoon