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 pointList = new List(); for(int i=0; i> road = new Dictionary>(); for(int i=0; iint.Parse(a)).ToArray(); if(!road.ContainsKey(inp[0])) { road.Add(inp[0], new Dictionary()); } if(!road.ContainsKey(inp[1])) { road.Add(inp[1], new Dictionary()); } 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 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(); } }