示例#1
0
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        map = new int[n].Select(_ => Read().Skip(1).ToArray()).ToArray();
        var q  = int.Parse(Console.ReadLine());
        var qs = new int[q].Select(_ => Read()).ToArray();

        tour     = new List <int>();
        order    = Array.ConvertAll(new int[n], _ => new List <int>());
        minDepth = new ST_Min(2 * n);
        minDepth.InitAllLevels(1 << 30);
        EulerTourDfs(0, 0);

        Console.WriteLine(string.Join("\n", qs.Select(x => Lca(x[0], x[1]))));
    }
示例#2
0
    static void Main()
    {
        var r = new List <long>();
        var h = Read();
        var n = h[0];

        var st = new ST_Min(n);

        st.InitAllLevels(int.MaxValue);

        for (int i = 0; i < h[1]; i++)
        {
            var q = Read();
            if (q[0] == 0)
            {
                st.Set(q[1], q[2]);
            }
            else
            {
                r.Add(st.Submin(q[1], q[2] + 1));
            }
        }
        Console.WriteLine(string.Join("\n", r));
    }