結果
問題 | No.2355 Unhappy Back Dance |
ユーザー |
|
提出日時 | 2023-08-09 09:01:11 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 2,745 ms / 6,000 ms |
コード長 | 1,754 bytes |
コンパイル時間 | 5,118 ms |
コンパイル使用メモリ | 112,300 KB |
実行使用メモリ | 51,328 KB |
最終ジャッジ日時 | 2024-11-14 15:39:20 |
合計ジャッジ時間 | 38,916 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 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);}}