結果
| 問題 |
No.408 五輪ピック
|
| コンテスト | |
| ユーザー |
14番
|
| 提出日時 | 2016-09-01 20:10:14 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 2,844 ms / 5,000 ms |
| コード長 | 4,026 bytes |
| コンパイル時間 | 1,105 ms |
| コンパイル使用メモリ | 109,184 KB |
| 実行使用メモリ | 43,980 KB |
| 最終ジャッジ日時 | 2024-11-15 17:02:05 |
| 合計ジャッジ時間 | 10,437 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 32 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
class Program
{
public void Proc()
{
Reader.IsDebug = false;
int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
int pointCount = inpt[0];
int connectCount = inpt[1];
for (int i = 0; i < connectCount; i++)
{
inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
if (!con.ContainsKey(inpt[0]))
{
con.Add(inpt[0], new Dictionary<int, bool>());
}
con[inpt[0]][inpt[1]] = true;
if (!con.ContainsKey(inpt[1]))
{
con.Add(inpt[1], new Dictionary<int, bool>());
}
con[inpt[1]][inpt[0]] = true;
}
Dictionary<int, Dictionary<int, bool>> from1 = new Dictionary<int,Dictionary<int,bool>>();
Dictionary<int, Dictionary<int, bool>> to1 = new Dictionary<int,Dictionary<int,bool>>();
bool ans = false;
if (con.ContainsKey(1))
{
foreach (int pos1 in con[1].Keys)
{
if (con.ContainsKey(pos1))
{
foreach (int pos2 in con[pos1].Keys)
{
if (pos2 == 1)
{
continue;
}
if (!from1.ContainsKey(pos1))
{
from1.Add(pos1, new Dictionary<int, bool>());
}
from1[pos1][pos2] = true;
if (!to1.ContainsKey(pos2))
{
to1.Add(pos2, new Dictionary<int, bool>());
}
to1[pos2][pos1] = true;
}
}
}
foreach (int pos1 in from1.Keys)
{
foreach (int pos2 in from1[pos1].Keys)
{
if (!con.ContainsKey(pos2))
{
break;
}
foreach (int pos3 in con[pos2].Keys)
{
if (pos3 == pos1 || !to1.ContainsKey(pos3))
{
continue;
}
foreach (int pos4 in to1[pos3].Keys)
{
if (pos4 == pos2 || pos4 == pos1)
{
continue;
}
ans = true;
break;
}
if (ans)
{
break;
}
}
if (ans)
{
break;
}
}
if (ans)
{
break;
}
}
}
Console.WriteLine(ans ? "YES" : "NO");
}
private Dictionary<int, Dictionary<int, bool>> con = new Dictionary<int, Dictionary<int, bool>>();
public class Reader
{
public static bool IsDebug = true;
private static String PlainInput = @"
7 10
1 2
1 3
1 4
1 5
2 3
2 4
2 6
3 4
3 7
4 5
";
private static System.IO.StringReader Sr = null;
public static string ReadLine()
{
if (IsDebug)
{
if (Sr == null)
{
Sr = new System.IO.StringReader(PlainInput.Trim());
}
return Sr.ReadLine();
}
else
{
return Console.ReadLine();
}
}
}
static void Main()
{
Program prg = new Program();
prg.Proc();
}
}
14番