結果
問題 | No.55 正方形を描くだけの簡単なお仕事です。 |
ユーザー |
![]() |
提出日時 | 2020-09-12 10:10:56 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 36 ms / 5,000 ms |
コード長 | 2,043 bytes |
コンパイル時間 | 1,359 ms |
コンパイル使用メモリ | 119,732 KB |
実行使用メモリ | 27,496 KB |
最終ジャッジ日時 | 2024-12-31 08:00:59 |
合計ジャッジ時間 | 3,335 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Linq;using System.Collections.Generic;using System;public static class Permi{public static IEnumerable<IEnumerable<T>> Perm<T>(this IEnumerable<T> items, int? k = null){if (k == null) k = items.Count();if (k == 0) yield return Enumerable.Empty<T>();else{var i = 0;foreach (var x in items){var xs = items.Where((_, index) => i != index);foreach (var c in Perm(xs, k - 1))yield return c.Before(x);i++;}}}public static IEnumerable<T> Before<T>(this IEnumerable<T> items, T first){yield return first;foreach (var i in items) yield return i;}}public class P{public int x { get; set; }public int y { get; set; }}public class Hello{public static P[] ps;static void Main(){string[] line = Console.ReadLine().Trim().Split(' ');ps = new P[3];for (int i = 0; i < 3; i++)ps[i] = new P { x = int.Parse(line[i * 2]), y = int.Parse(line[i * 2 + 1]) };getAns();}static void getAns(){var a = new int[] { 0, 1, 2 }.Perm();foreach (var x in a){var b = x.ToArray();var res = check(b);if (res.x != 999) { Console.WriteLine("{0} {1}", res.x, res.y); return; }}Console.WriteLine(-1);}static P check(int[] a){var res = new P();var p21x = ps[a[1]].x - ps[a[2]].x;var p21y = ps[a[1]].y - ps[a[2]].y;var p10x = ps[a[0]].x - ps[a[1]].x;var p10y = ps[a[0]].y - ps[a[1]].y;if (p21x * p10x + p21y * p10y != 0) { res.x = 999; return res; }if (p21x * p21x + p21y * p21y != p10x * p10x + p10y * p10y){ res.x = 999; return res; }var p3x = p10x + ps[a[2]].x;var p3y = p10y + ps[a[2]].y;res.x = p3x;res.y = p3y;return res;}}