Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace mainSolution
- {
- class Input
- {
- private static IEnumerator<string> getin()
- {
- while (true)
- foreach (string s in Console.ReadLine().Split().Where(x => x.Length > 0))
- yield return s;
- }
- private IEnumerator<string> inp = getin();
- public string GetString() { inp.MoveNext(); return inp.Current; }
- public int GetInt() { return int.Parse(GetString()); }
- public long GetLong() { return long.Parse(GetString()); }
- public double GetDouble() { return double.Parse(GetString()); }
- }
- class Tree
- {
- public List<List<int>> g = new List<List<int>>();
- private List<int> parent = new List<int> ();
- private List<bool> used = new List<bool> ();
- private int size = 0;
- bool isChanged = false;
- public Tree() { }
- public Tree(int size)
- {
- setSize(size);
- Initialize();
- isChanged = true;
- }
- private void changeTree(int size)
- {
- g.RemoveRange(size, this.size - size);
- parent.RemoveRange(size, this.size - size);
- used.RemoveRange(size, this.size - size);
- }
- public void setSize(int size)
- {
- //this.size = size;
- if (this.size > size)
- {
- changeTree(size);
- }
- this.size = size;
- isChanged = true;
- }
- private void Initialize()
- {
- for (int i = 0; i < size; i++)
- {
- g.Add(new List<int>());
- parent.Add(new int());
- used.Add(new bool());
- }
- }
- }
- static class Program
- {
- static void Main(string[] args)
- {
- Tree tree = new Tree();
- tree.setSize(10);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement