結果

問題 No.629 グラフの中に眠る門松列
ユーザー バカらっくバカらっく
提出日時 2018-01-05 22:35:29
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 81 ms / 4,000 ms
コード長 2,330 bytes
コンパイル時間 2,295 ms
コンパイル使用メモリ 108,444 KB
実行使用メモリ 26,168 KB
最終ジャッジ日時 2023-08-24 20:58:26
合計ジャッジ時間 6,805 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
21,928 KB
testcase_01 AC 66 ms
23,868 KB
testcase_02 AC 67 ms
23,848 KB
testcase_03 AC 66 ms
21,808 KB
testcase_04 AC 66 ms
21,760 KB
testcase_05 AC 65 ms
23,964 KB
testcase_06 AC 60 ms
21,932 KB
testcase_07 AC 65 ms
21,856 KB
testcase_08 AC 65 ms
23,940 KB
testcase_09 AC 66 ms
23,896 KB
testcase_10 AC 64 ms
21,852 KB
testcase_11 AC 64 ms
21,928 KB
testcase_12 AC 66 ms
23,872 KB
testcase_13 AC 65 ms
21,936 KB
testcase_14 AC 65 ms
21,824 KB
testcase_15 AC 65 ms
21,888 KB
testcase_16 AC 65 ms
21,912 KB
testcase_17 AC 65 ms
23,952 KB
testcase_18 AC 65 ms
21,908 KB
testcase_19 AC 66 ms
19,796 KB
testcase_20 AC 66 ms
21,904 KB
testcase_21 AC 76 ms
22,016 KB
testcase_22 AC 75 ms
22,044 KB
testcase_23 AC 75 ms
22,084 KB
testcase_24 AC 70 ms
22,028 KB
testcase_25 AC 72 ms
23,876 KB
testcase_26 AC 78 ms
22,024 KB
testcase_27 AC 79 ms
26,068 KB
testcase_28 AC 74 ms
24,068 KB
testcase_29 AC 77 ms
24,004 KB
testcase_30 AC 80 ms
22,060 KB
testcase_31 AC 81 ms
24,068 KB
testcase_32 AC 78 ms
22,012 KB
testcase_33 AC 80 ms
24,152 KB
testcase_34 AC 77 ms
22,136 KB
testcase_35 AC 77 ms
22,012 KB
testcase_36 AC 78 ms
24,036 KB
testcase_37 AC 79 ms
26,168 KB
testcase_38 AC 78 ms
22,132 KB
testcase_39 AC 77 ms
22,132 KB
testcase_40 AC 76 ms
21,940 KB
testcase_41 AC 75 ms
21,964 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int pointCount = inpt[0];
        int pathCount = inpt[1];

        int[] pointList = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        Dictionary<int, Dictionary<int, bool>> path = new Dictionary<int, Dictionary<int, bool>>();
        for (int i = 0; i < pathCount; i++) {
            inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a) - 1).ToArray();
            if(!path.ContainsKey(inpt[0])) {
                path.Add(inpt[0], new Dictionary<int, bool>());
            }
            path[inpt[0]].Add(inpt[1], true);
            if(!path.ContainsKey(inpt[1])) {
                path.Add(inpt[1], new Dictionary<int, bool>());
            }
            path[inpt[1]].Add(inpt[0], true);
        }
        bool hasKadomatu = false;
        for (int i = 0; i < pointCount; i++) {
            int num = pointList[i];
            if(!path.ContainsKey(i)) {
                continue;
            }
            if (path[i].Select(a => pointList[a.Key]).Distinct().Count(a => a < num) >= 2)
            {
                hasKadomatu = true;
                break;
            } else if (path[i].Select(a => pointList[a.Key]).Distinct().Count(a => a > num) >= 2)
                {
                hasKadomatu = true;
                break;
            }
        }
        Console.WriteLine(hasKadomatu?"YES":"NO");
    }



    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 = @"



3 2
1 3 2
1 2
2 3


";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}
0