結果
問題 |
No.629 グラフの中に眠る門松列
|
ユーザー |
![]() |
提出日時 | 2018-01-05 22:32:42 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,236 bytes |
コンパイル時間 | 2,677 ms |
コンパイル使用メモリ | 109,184 KB |
実行使用メモリ | 21,376 KB |
最終ジャッジ日時 | 2024-12-23 06:51:20 |
合計ジャッジ時間 | 5,869 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 WA * 1 |
other | AC * 28 WA * 8 |
コンパイルメッセージ
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].Count(a=>pointList[a.Key]<num)>=2) { hasKadomatu = true; break; } else if(path[i].Count(a=>pointList[a.Key]>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(); } }