結果
| 問題 | No.629 グラフの中に眠る門松列 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-01-05 21:33:54 | 
| 言語 | D (dmd 2.109.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 7 ms / 4,000 ms | 
| コード長 | 933 bytes | 
| コンパイル時間 | 1,217 ms | 
| コンパイル使用メモリ | 137,288 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-12 23:19:47 | 
| 合計ジャッジ時間 | 2,652 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 36 | 
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.datetime;
void main() {
    auto s = readln.split.map!(to!int).array;
    auto N = s[0];
    auto M = s[1];
    auto A = readln.split.map!(to!int).array;
    auto G = new int[][](N);
    foreach (_; 0..M) {
        s = readln.split.map!(to!int).array;
        G[s[0]-1] ~= s[1]-1;
        G[s[1]-1] ~= s[0]-1;
    }
    foreach (i; 0..N) {
        bool[int] hoge;
        foreach (j; G[i]) hoge[A[j]] = true;
        auto fuga = hoge.keys.array;
        fuga.sort();
        if (fuga.length >= 2 && fuga[0] < A[i] && fuga[1] < A[i]) {
            "YES".writeln;
            return;
        }
        if (fuga.length >= 2 && fuga[$-1] > A[i] && fuga[$-2] > A[i]) {
            "YES".writeln;
            return;
        }
    }
    "NO".writeln;
}
            
            
            
        