Example #1
0
        static void GraphDec()
        {
            var graph = new Graph <int>();

            string[] s = Console.In.ReadToEnd().Split(new char[] { ' ', '\n', '\r', '\t' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < s.Length; i += 2)
            {
                var first  = Int32.Parse(s[i]);
                var second = Int32.Parse(s[i + 1]);
                graph.AddVertex(first);
                graph.AddVertex(second);
                graph.AddEdge(first, second, 1);
            }

            var c = graph.CountComponents();

            if (c % 2 == 0)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(1);
            }
        }