結果

問題 No.629 グラフの中に眠る門松列
ユーザー mbanmban
提出日時 2018-01-09 19:35:08
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 75 ms / 4,000 ms
コード長 2,506 bytes
コンパイル時間 2,321 ms
コンパイル使用メモリ 104,632 KB
実行使用メモリ 24,860 KB
最終ジャッジ日時 2023-08-25 02:24:28
合計ジャッジ時間 6,669 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
24,692 KB
testcase_01 AC 62 ms
22,684 KB
testcase_02 AC 62 ms
22,688 KB
testcase_03 AC 62 ms
24,580 KB
testcase_04 AC 63 ms
22,576 KB
testcase_05 AC 63 ms
24,688 KB
testcase_06 AC 61 ms
20,576 KB
testcase_07 AC 64 ms
22,564 KB
testcase_08 AC 62 ms
22,592 KB
testcase_09 AC 64 ms
24,700 KB
testcase_10 AC 63 ms
22,528 KB
testcase_11 AC 62 ms
22,684 KB
testcase_12 AC 62 ms
22,560 KB
testcase_13 AC 62 ms
24,572 KB
testcase_14 AC 62 ms
24,608 KB
testcase_15 AC 63 ms
22,544 KB
testcase_16 AC 62 ms
24,580 KB
testcase_17 AC 62 ms
24,720 KB
testcase_18 AC 64 ms
22,636 KB
testcase_19 AC 62 ms
24,600 KB
testcase_20 AC 63 ms
24,672 KB
testcase_21 AC 71 ms
22,768 KB
testcase_22 AC 71 ms
22,716 KB
testcase_23 AC 71 ms
24,784 KB
testcase_24 AC 66 ms
22,588 KB
testcase_25 AC 66 ms
24,592 KB
testcase_26 AC 70 ms
22,776 KB
testcase_27 AC 72 ms
22,772 KB
testcase_28 AC 71 ms
22,764 KB
testcase_29 AC 73 ms
24,860 KB
testcase_30 AC 73 ms
22,688 KB
testcase_31 AC 75 ms
22,808 KB
testcase_32 AC 74 ms
22,752 KB
testcase_33 AC 74 ms
24,816 KB
testcase_34 AC 73 ms
24,820 KB
testcase_35 AC 73 ms
22,756 KB
testcase_36 AC 75 ms
22,788 KB
testcase_37 AC 72 ms
22,728 KB
testcase_38 AC 72 ms
20,708 KB
testcase_39 AC 72 ms
22,692 KB
testcase_40 AC 71 ms
24,788 KB
testcase_41 AC 72 ms
20,668 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.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            return Array().Select(int.Parse).ToArray();
        }
        public long[] LongArray()
        {
            return Array().Select(long.Parse).ToArray();
        }
    }

    class Program
    {
        private int N, M;
        private int[] A;
        private List<int>[] R;
        public void Solve()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            M = sc.NextInt();
            A = sc.IntArray();
            R = new List<int>[N];
            for (int i = 0; i < N; i++)
            {
                R[i] = new List<int>();
            }
            for (int i = 0; i < M; i++)
            {
                var u = sc.NextInt() - 1;
                var v = sc.NextInt() - 1;
                R[u].Add(v);
                R[v].Add(u);
            }

            for (int i = 0; i < N; i++)
            {
                var less = new HashSet<int>();
                var great = new HashSet<int>();
                foreach (int j in R[i])
                {
                    if (A[j] < A[i])
                    {
                        less.Add(A[j]);
                    }
                    if (A[j] > A[i])
                    {
                        great.Add(A[j]);
                    }
                }
                if ((less.Count >= 2) || (great.Count >= 2))
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }

        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}
0