結果
問題 | No.488 四角関係 |
ユーザー | 14番 |
提出日時 | 2017-05-31 08:04:50 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 110 ms / 5,000 ms |
コード長 | 3,649 bytes |
コンパイル時間 | 1,353 ms |
コンパイル使用メモリ | 110,464 KB |
実行使用メモリ | 24,064 KB |
最終ジャッジ日時 | 2024-09-21 20:16:50 |
合計ジャッジ時間 | 3,443 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 49 ms
20,096 KB |
testcase_01 | AC | 68 ms
23,904 KB |
testcase_02 | AC | 57 ms
22,912 KB |
testcase_03 | AC | 54 ms
22,144 KB |
testcase_04 | AC | 61 ms
23,680 KB |
testcase_05 | AC | 74 ms
24,048 KB |
testcase_06 | AC | 51 ms
20,480 KB |
testcase_07 | AC | 110 ms
24,064 KB |
testcase_08 | AC | 39 ms
20,224 KB |
testcase_09 | AC | 32 ms
19,328 KB |
testcase_10 | AC | 50 ms
20,608 KB |
testcase_11 | AC | 47 ms
19,712 KB |
testcase_12 | AC | 57 ms
21,760 KB |
testcase_13 | AC | 54 ms
21,120 KB |
testcase_14 | AC | 50 ms
20,096 KB |
testcase_15 | AC | 36 ms
19,328 KB |
testcase_16 | AC | 47 ms
19,584 KB |
testcase_17 | AC | 34 ms
19,328 KB |
testcase_18 | AC | 48 ms
19,840 KB |
testcase_19 | AC | 47 ms
19,584 KB |
testcase_20 | AC | 48 ms
19,584 KB |
testcase_21 | AC | 35 ms
19,328 KB |
testcase_22 | AC | 38 ms
19,584 KB |
testcase_23 | AC | 35 ms
19,456 KB |
testcase_24 | AC | 47 ms
19,584 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.IO; using System.Linq; using System.Collections.Generic; public class Program { public void Proc() { int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray(); int nodeCount = inpt[0]; int pathCount = inpt[1]; for (int i = 0; i < pathCount; i++) { inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray(); int[][] tmp = new int[][] { inpt, inpt.Reverse().ToArray() }; foreach(int[] lst in tmp) { if(!Path.ContainsKey(lst[0])) { Path.Add(lst[0],new Dictionary<int, bool>()); } Path[lst[0]].Add(lst[1], true); } } Dictionary<int, Dictionary<int, Dictionary<int, Dictionary<int, bool>>>> dic = new Dictionary<int, Dictionary<int, Dictionary<int, Dictionary<int, bool>>>>(); foreach(int key1 in Path.Keys) { if(Path[key1].Count < 2) { continue; } int[] key1ToList = Path[key1].Keys.ToArray(); for (int i = 0; i < key1ToList.Length - 1;i++) { for (int j = i + 1; j < key1ToList.Length;j++) { if(Path[key1ToList[i]].ContainsKey(key1ToList[j])) { continue; } if(!Path.Any(a=>a.Key != key1 && a.Value.ContainsKey(key1ToList[i]) && a.Value.ContainsKey(key1ToList[j]))) { continue; } int[] key2List = Path.Where(a => a.Key != key1 && a.Value.ContainsKey(key1ToList[i]) && a.Value.ContainsKey(key1ToList[j])).Select(a => a.Key).ToArray(); foreach(int key2 in key2List) { if(Path[key2].ContainsKey(key1)) { continue; } int[] tmp = new int[]{key1, key2, key1ToList[i], key1ToList[j]}.OrderBy(a=>a).ToArray(); if(!dic.ContainsKey(tmp[0])) { dic.Add(tmp[0], new Dictionary<int, Dictionary<int, Dictionary<int, bool>>>()); } if(!dic[tmp[0]].ContainsKey(tmp[1])) { dic[tmp[0]].Add(tmp[1], new Dictionary<int, Dictionary<int, bool>>()); } if(!dic[tmp[0]][tmp[1]].ContainsKey(tmp[2])) { dic[tmp[0]][tmp[1]].Add(tmp[2], new Dictionary<int, bool>()); } dic[tmp[0]][tmp[1]][tmp[2]][tmp[3]] = true; } } } } int ans = dic.Select(a => a.Value.Select(b => b.Value.Select(c => c.Value.Count()).Sum()).Sum()).Sum(); Console.WriteLine(ans); } private Dictionary<int, Dictionary<int, bool>> Path = new Dictionary<int, Dictionary<int, bool>>(); public class Reader { private static StringReader sr; public static bool IsDebug = false; public static string ReadLine() { if(IsDebug) { if(sr == null) { sr = new StringReader(InputText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } private static string InputText = @" 8 17 0 3 0 4 0 6 1 2 1 6 2 4 2 5 2 7 3 4 3 5 3 6 4 5 4 6 4 7 5 6 5 7 6 7 "; } public static void Main(string[] args) { #if DEBUG Reader.IsDebug = true; #endif Program prg = new Program(); prg.Proc(); } }