結果
問題 | No.629 グラフの中に眠る門松列 |
ユーザー |
|
提出日時 | 2018-01-09 11:56:23 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 7 ms / 4,000 ms |
コード長 | 567 bytes |
コンパイル時間 | 885 ms |
コンパイル使用メモリ | 104,076 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-12 23:23:19 |
合計ジャッジ時間 | 1,973 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 36 |
ソースコード
import std.algorithm, std.conv, std.range, std.stdio, std.string; void main() { auto rd = readln.split.to!(int[]), n = rd[0], m = rd[1]; auto a = readln.split.to!(int[]); auto g = new int[][](n); foreach (_; 0..m) { auto rd2 = readln.split.to!(int[]), u = rd2[0]-1, v = rd2[1]-1; g[u] ~= v; g[v] ~= u; } foreach (i; 0..n) { auto b = a[i]; auto c = a.indexed(g[i]); if (c.filter!(ci => ci < b).uniq.walkLength > 1 || c.filter!(ci => ci > b).uniq.walkLength > 1) { writeln("YES"); return; } } writeln("NO"); }