結果
| 問題 |
No.2355 Unhappy Back Dance
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-09 08:53:35 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,758 bytes |
| コンパイル時間 | 2,966 ms |
| コンパイル使用メモリ | 113,904 KB |
| 実行使用メモリ | 52,912 KB |
| 最終ジャッジ日時 | 2024-11-14 15:32:02 |
| 合計ジャッジ時間 | 41,437 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 28 WA * 9 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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 + 1 < 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);
}
}