結果
問題 | No.479 頂点は要らない |
ユーザー | 14番 |
提出日時 | 2017-01-28 11:23:26 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 239 ms / 1,500 ms |
コード長 | 3,046 bytes |
コンパイル時間 | 2,720 ms |
コンパイル使用メモリ | 107,260 KB |
実行使用メモリ | 60,308 KB |
最終ジャッジ日時 | 2023-08-25 13:01:54 |
合計ジャッジ時間 | 8,939 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 56 ms
21,920 KB |
testcase_01 | AC | 58 ms
21,864 KB |
testcase_02 | AC | 58 ms
21,968 KB |
testcase_03 | AC | 57 ms
21,840 KB |
testcase_04 | AC | 58 ms
19,808 KB |
testcase_05 | AC | 57 ms
23,896 KB |
testcase_06 | AC | 55 ms
19,916 KB |
testcase_07 | AC | 57 ms
23,936 KB |
testcase_08 | AC | 56 ms
21,868 KB |
testcase_09 | AC | 56 ms
21,864 KB |
testcase_10 | AC | 57 ms
21,852 KB |
testcase_11 | AC | 55 ms
19,916 KB |
testcase_12 | AC | 57 ms
21,956 KB |
testcase_13 | AC | 58 ms
21,940 KB |
testcase_14 | AC | 57 ms
21,916 KB |
testcase_15 | AC | 58 ms
21,940 KB |
testcase_16 | AC | 57 ms
19,956 KB |
testcase_17 | AC | 58 ms
21,984 KB |
testcase_18 | AC | 58 ms
23,860 KB |
testcase_19 | AC | 57 ms
21,836 KB |
testcase_20 | AC | 59 ms
21,904 KB |
testcase_21 | AC | 59 ms
23,952 KB |
testcase_22 | AC | 59 ms
23,908 KB |
testcase_23 | AC | 58 ms
21,968 KB |
testcase_24 | AC | 60 ms
21,860 KB |
testcase_25 | AC | 59 ms
21,936 KB |
testcase_26 | AC | 239 ms
57,524 KB |
testcase_27 | AC | 238 ms
58,964 KB |
testcase_28 | AC | 224 ms
60,308 KB |
testcase_29 | AC | 190 ms
44,468 KB |
testcase_30 | AC | 190 ms
46,576 KB |
testcase_31 | AC | 189 ms
46,576 KB |
testcase_32 | AC | 186 ms
44,568 KB |
testcase_33 | AC | 209 ms
49,536 KB |
testcase_34 | AC | 222 ms
46,988 KB |
testcase_35 | AC | 199 ms
44,700 KB |
testcase_36 | AC | 136 ms
35,688 KB |
testcase_37 | AC | 224 ms
47,732 KB |
testcase_38 | AC | 192 ms
47,160 KB |
testcase_39 | AC | 158 ms
44,608 KB |
testcase_40 | AC | 176 ms
48,160 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(); } }