結果
問題 | No.408 五輪ピック |
ユーザー | 14番 |
提出日時 | 2016-09-01 20:10:14 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 2,844 ms / 5,000 ms |
コード長 | 4,026 bytes |
コンパイル時間 | 1,105 ms |
コンパイル使用メモリ | 109,184 KB |
実行使用メモリ | 43,980 KB |
最終ジャッジ日時 | 2024-11-15 17:02:05 |
合計ジャッジ時間 | 10,437 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
19,328 KB |
testcase_01 | AC | 31 ms
19,328 KB |
testcase_02 | AC | 32 ms
19,200 KB |
testcase_03 | AC | 35 ms
19,328 KB |
testcase_04 | AC | 34 ms
19,072 KB |
testcase_05 | AC | 101 ms
28,800 KB |
testcase_06 | AC | 74 ms
28,416 KB |
testcase_07 | AC | 93 ms
28,672 KB |
testcase_08 | AC | 83 ms
26,624 KB |
testcase_09 | AC | 85 ms
27,392 KB |
testcase_10 | AC | 73 ms
27,136 KB |
testcase_11 | AC | 71 ms
27,008 KB |
testcase_12 | AC | 104 ms
30,336 KB |
testcase_13 | AC | 97 ms
27,520 KB |
testcase_14 | AC | 45 ms
22,880 KB |
testcase_15 | AC | 110 ms
30,592 KB |
testcase_16 | AC | 104 ms
29,184 KB |
testcase_17 | AC | 107 ms
28,928 KB |
testcase_18 | AC | 109 ms
29,440 KB |
testcase_19 | AC | 116 ms
30,336 KB |
testcase_20 | AC | 57 ms
25,728 KB |
testcase_21 | AC | 45 ms
22,336 KB |
testcase_22 | AC | 73 ms
28,416 KB |
testcase_23 | AC | 186 ms
43,980 KB |
testcase_24 | AC | 140 ms
42,624 KB |
testcase_25 | AC | 107 ms
29,952 KB |
testcase_26 | AC | 121 ms
33,024 KB |
testcase_27 | AC | 460 ms
30,336 KB |
testcase_28 | AC | 2,844 ms
29,952 KB |
testcase_29 | AC | 2,591 ms
29,696 KB |
testcase_30 | AC | 32 ms
19,328 KB |
testcase_31 | AC | 31 ms
19,328 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.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray(); int pointCount = inpt[0]; int connectCount = inpt[1]; for (int i = 0; i < connectCount; i++) { inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray(); if (!con.ContainsKey(inpt[0])) { con.Add(inpt[0], new Dictionary<int, bool>()); } con[inpt[0]][inpt[1]] = true; if (!con.ContainsKey(inpt[1])) { con.Add(inpt[1], new Dictionary<int, bool>()); } con[inpt[1]][inpt[0]] = true; } Dictionary<int, Dictionary<int, bool>> from1 = new Dictionary<int,Dictionary<int,bool>>(); Dictionary<int, Dictionary<int, bool>> to1 = new Dictionary<int,Dictionary<int,bool>>(); bool ans = false; if (con.ContainsKey(1)) { foreach (int pos1 in con[1].Keys) { if (con.ContainsKey(pos1)) { foreach (int pos2 in con[pos1].Keys) { if (pos2 == 1) { continue; } if (!from1.ContainsKey(pos1)) { from1.Add(pos1, new Dictionary<int, bool>()); } from1[pos1][pos2] = true; if (!to1.ContainsKey(pos2)) { to1.Add(pos2, new Dictionary<int, bool>()); } to1[pos2][pos1] = true; } } } foreach (int pos1 in from1.Keys) { foreach (int pos2 in from1[pos1].Keys) { if (!con.ContainsKey(pos2)) { break; } foreach (int pos3 in con[pos2].Keys) { if (pos3 == pos1 || !to1.ContainsKey(pos3)) { continue; } foreach (int pos4 in to1[pos3].Keys) { if (pos4 == pos2 || pos4 == pos1) { continue; } ans = true; break; } if (ans) { break; } } if (ans) { break; } } if (ans) { break; } } } Console.WriteLine(ans ? "YES" : "NO"); } private Dictionary<int, Dictionary<int, bool>> con = new Dictionary<int, Dictionary<int, bool>>(); public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 7 10 1 2 1 3 1 4 1 5 2 3 2 4 2 6 3 4 3 7 4 5 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }