Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Graph
- {
- private class Node
- {
- List<List<int>> array = new List<List<int>>();
- public Node(List<List<int>> tmp)
- {
- array = tmp;
- }
- public int CountEvenVertex()
- {
- int count = 0;
- foreach (var item in array)
- if (item.Count % 2 == 0)
- count++;
- return count;
- }
- }
- private Node graph;
- public Graph(string nameOfFile)
- {
- StreamReader fin = new StreamReader(nameOfFile);
- int n = int.Parse(fin.ReadLine());
- List<List<int>> tmp = new List<List<int>>();
- for (int i = 0; i < n; i++)
- {
- List<int> tmp2 = new List<int>();
- string[] arr = fin.ReadLine().Split(' ');
- for (int j = 1; j < arr.Length; j++)
- tmp2.Add(int.Parse(arr[j]) - 1);
- tmp.Add(tmp2);
- }
- fin.Close();
- graph = new Node(tmp);
- }
- public int CountEvenVertex()
- {
- return graph.CountEvenVertex();
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Graph graph1 = new Graph("input.txt");
- StreamWriter fout = new StreamWriter("output.txt");
- fout.WriteLine("{0}", graph1.CountEvenVertex());
- fout.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement