結果

問題 No.408 五輪ピック
ユーザー 14番14番
提出日時 2016-09-01 20:02:26
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 4,045 bytes
コンパイル時間 864 ms
コンパイル使用メモリ 111,560 KB
実行使用メモリ 58,020 KB
最終ジャッジ日時 2024-04-27 14:26:55
合計ジャッジ時間 9,660 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
25,716 KB
testcase_01 AC 33 ms
25,516 KB
testcase_02 AC 34 ms
27,244 KB
testcase_03 AC 34 ms
25,464 KB
testcase_04 AC 33 ms
27,440 KB
testcase_05 AC 100 ms
37,216 KB
testcase_06 AC 72 ms
36,696 KB
testcase_07 AC 93 ms
39,000 KB
testcase_08 AC 80 ms
30,728 KB
testcase_09 AC 81 ms
33,536 KB
testcase_10 AC 73 ms
35,284 KB
testcase_11 AC 73 ms
32,972 KB
testcase_12 AC 109 ms
38,360 KB
testcase_13 AC 103 ms
33,952 KB
testcase_14 AC 46 ms
29,576 KB
testcase_15 AC 111 ms
38,780 KB
testcase_16 AC 100 ms
33,284 KB
testcase_17 AC 104 ms
39,148 KB
testcase_18 AC 105 ms
35,440 KB
testcase_19 AC 119 ms
38,492 KB
testcase_20 AC 55 ms
31,712 KB
testcase_21 AC 42 ms
27,544 KB
testcase_22 AC 67 ms
34,776 KB
testcase_23 AC 175 ms
52,180 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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)
                {
                    foreach (int pos3 in from1.Keys)
                    {
                        if (pos1 == pos3 || pos2 == pos3)
                        {
                            continue;
                        }
                        foreach (int pos4 in from1[pos3].Keys)
                        {
                            if (pos1 == pos4 || pos2 == pos4)
                            {
                                continue;
                            }
                            if (con.ContainsKey(pos2) && con[pos2].ContainsKey(pos4))
                            {
                                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();
    }
}
0