結果
問題 | No.479 頂点は要らない |
ユーザー | 14番 |
提出日時 | 2017-01-28 11:23:26 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 275 ms / 1,500 ms |
コード長 | 3,046 bytes |
コンパイル時間 | 1,210 ms |
コンパイル使用メモリ | 109,184 KB |
実行使用メモリ | 57,132 KB |
最終ジャッジ日時 | 2024-06-06 07:37:02 |
合計ジャッジ時間 | 6,584 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 31 ms
19,584 KB |
testcase_01 | AC | 30 ms
19,456 KB |
testcase_02 | AC | 29 ms
19,456 KB |
testcase_03 | AC | 30 ms
19,584 KB |
testcase_04 | AC | 30 ms
19,456 KB |
testcase_05 | AC | 30 ms
19,584 KB |
testcase_06 | AC | 31 ms
19,328 KB |
testcase_07 | AC | 31 ms
19,584 KB |
testcase_08 | AC | 32 ms
19,584 KB |
testcase_09 | AC | 32 ms
19,584 KB |
testcase_10 | AC | 31 ms
19,456 KB |
testcase_11 | AC | 31 ms
19,328 KB |
testcase_12 | AC | 30 ms
19,328 KB |
testcase_13 | AC | 31 ms
19,456 KB |
testcase_14 | AC | 30 ms
19,584 KB |
testcase_15 | AC | 30 ms
19,584 KB |
testcase_16 | AC | 30 ms
19,456 KB |
testcase_17 | AC | 30 ms
19,712 KB |
testcase_18 | AC | 30 ms
19,456 KB |
testcase_19 | AC | 31 ms
19,968 KB |
testcase_20 | AC | 31 ms
20,072 KB |
testcase_21 | AC | 31 ms
19,840 KB |
testcase_22 | AC | 32 ms
20,096 KB |
testcase_23 | AC | 32 ms
19,712 KB |
testcase_24 | AC | 32 ms
20,352 KB |
testcase_25 | AC | 32 ms
19,840 KB |
testcase_26 | AC | 250 ms
54,008 KB |
testcase_27 | AC | 249 ms
54,536 KB |
testcase_28 | AC | 224 ms
57,132 KB |
testcase_29 | AC | 186 ms
42,112 KB |
testcase_30 | AC | 188 ms
41,984 KB |
testcase_31 | AC | 196 ms
41,856 KB |
testcase_32 | AC | 191 ms
41,984 KB |
testcase_33 | AC | 208 ms
42,940 KB |
testcase_34 | AC | 233 ms
44,560 KB |
testcase_35 | AC | 222 ms
42,112 KB |
testcase_36 | AC | 124 ms
30,976 KB |
testcase_37 | AC | 275 ms
45,364 KB |
testcase_38 | AC | 245 ms
40,832 KB |
testcase_39 | AC | 172 ms
39,936 KB |
testcase_40 | AC | 181 ms
43,004 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; using System.Collections.Generic; using System.Text.RegularExpressions; using System.Text; public class Program { public void Proc() { Reader.IsDebug = false; int[] inp = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray(); int pointCount = inp[0]; int roadCount = inp[1]; List<Point> pointList = new List<Point>(); for(int i=0; i<pointCount; i++) { pointList.Add(new Point(i)); } Dictionary<int, Dictionary<int, bool>> road = new Dictionary<int, Dictionary<int, bool>>(); for(int i=0; i<roadCount; i++) { inp = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray(); if(!road.ContainsKey(inp[0])) { road.Add(inp[0], new Dictionary<int, bool>()); } if(!road.ContainsKey(inp[1])) { road.Add(inp[1], new Dictionary<int, bool>()); } road[inp[0]].Add(inp[1], false); road[inp[1]].Add(inp[0], false); } StringBuilder ans = new StringBuilder(); for(int i=pointList.Count-1; i>=0; i--) { bool must = false; if(pointList[i].mustBuy != null) { if(pointList[i].mustBuy.Value) { must = true; } else { must = false; } } else { foreach(int key in road[i].Keys) { if(pointList[key].mustBuy != null && pointList[key].mustBuy.Value == false) { must = true; break; } } pointList[i].mustBuy = must; } if(must) { ans.Append(1); } else { ans.Append(0); } if(!pointList[i].mustBuy.Value) { foreach(int key in road[i].Keys) { if(pointList[key].mustBuy == null) { pointList[key].mustBuy = true; } } } } Console.WriteLine(ans.ToString().TrimStart(new char[]{'0'})); } private class Point { public int ID; public Nullable<Boolean> mustBuy = null; public Point(int id) { this.ID = id; } } public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" 4 5 0 1 0 2 0 3 1 2 2 3 "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }