結果

問題 No.629 グラフの中に眠る門松列
ユーザー mbanmban
提出日時 2018-01-09 19:31:28
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,444 bytes
コンパイル時間 2,166 ms
コンパイル使用メモリ 106,884 KB
実行使用メモリ 23,876 KB
最終ジャッジ日時 2023-08-25 02:24:21
合計ジャッジ時間 6,475 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
23,772 KB
testcase_01 WA -
testcase_02 AC 59 ms
23,636 KB
testcase_03 AC 60 ms
21,584 KB
testcase_04 AC 60 ms
21,572 KB
testcase_05 AC 60 ms
21,536 KB
testcase_06 AC 60 ms
21,764 KB
testcase_07 AC 60 ms
19,544 KB
testcase_08 AC 61 ms
23,680 KB
testcase_09 AC 60 ms
23,700 KB
testcase_10 AC 59 ms
21,616 KB
testcase_11 AC 60 ms
23,660 KB
testcase_12 AC 59 ms
21,592 KB
testcase_13 AC 59 ms
21,552 KB
testcase_14 WA -
testcase_15 AC 60 ms
21,656 KB
testcase_16 AC 60 ms
21,568 KB
testcase_17 AC 60 ms
21,592 KB
testcase_18 AC 60 ms
23,512 KB
testcase_19 AC 59 ms
21,584 KB
testcase_20 AC 60 ms
23,568 KB
testcase_21 WA -
testcase_22 AC 68 ms
21,776 KB
testcase_23 AC 69 ms
21,820 KB
testcase_24 AC 64 ms
23,564 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 71 ms
21,784 KB
testcase_28 WA -
testcase_29 AC 70 ms
21,708 KB
testcase_30 AC 72 ms
21,752 KB
testcase_31 AC 71 ms
19,584 KB
testcase_32 AC 70 ms
21,812 KB
testcase_33 WA -
testcase_34 AC 70 ms
21,652 KB
testcase_35 AC 69 ms
23,732 KB
testcase_36 AC 72 ms
23,704 KB
testcase_37 WA -
testcase_38 AC 72 ms
23,748 KB
testcase_39 AC 71 ms
21,760 KB
testcase_40 WA -
testcase_41 AC 70 ms
21,812 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++)
            {
                int less = 0;
                int great = 0;
                foreach (int j in R[i])
                {
                    if (A[j] < A[i])
                    {
                        less++;
                    }
                    if (A[j] > A[i])
                    {
                        great++;
                    }
                }
                if ((less >= 2) || (great >= 2))
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }

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