結果
| 問題 | No.629 グラフの中に眠る門松列 | 
| コンテスト | |
| ユーザー |  バカらっく | 
| 提出日時 | 2018-01-05 22:35:29 | 
| 言語 | C#(csc) (csc 3.9.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 51 ms / 4,000 ms | 
| コード長 | 2,330 bytes | 
| コンパイル時間 | 1,329 ms | 
| コンパイル使用メモリ | 109,696 KB | 
| 実行使用メモリ | 22,400 KB | 
| 最終ジャッジ日時 | 2024-12-23 06:51:33 | 
| 合計ジャッジ時間 | 4,038 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 36 | 
コンパイルメッセージ
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;
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();
    }
}
            
            
            
        