예제 #1
0
    static void Main()
    {
        int n  = sc.Int;
        var sg = new Segtree <int>(n, -1, Math.Min, n);

        sg.update(0, 0);
        int xor = 0;

        for (int i = 0; i < n - 1; i++)
        {
            int c, a;
            sc.Multi(out c, out a);
            int ok = 0, ng = i + 2;
            while (ng - ok > 1)
            {
                int m = (ok + ng) / 2;
                if (sg.run(0, m) > i - c)
                {
                    ok = m;
                }
                else
                {
                    ng = m;
                }
            }
            sg.update(ok, i + 1);
            if (a % 2 == 1)
            {
                xor ^= ok;
            }
        }
        Prt(xor != 0 ? "First" : "Second");
        sw.Flush();
    }
예제 #2
0
파일: 2455671.cs 프로젝트: qifanyyy/CLCDSA
    static void Main()
    {
        int n, m;

        sc.Multi(out n, out m);
        var a   = new P[n];
        var b   = new P[m];
        var all = new List <int>();

        for (int i = 0; i < n; i++)
        {
            a[i] = sc.Pair <int, int>();
            all.Add(a[i].v1);
            all.Add(a[i].v2);
        }
        for (int i = 0; i < m; i++)
        {
            b[i] = sc.Pair <int, int>();
            all.Add(b[i].v1);
            all.Add(b[i].v2);
        }
        all = all.Distinct().ToList();
        all.Sort();
        var zip = all.Select((x, i) => new { x, i }).ToDictionary(x => x.x, x => x.i);

        a = a.Select(x => new P(zip[x.v1], zip[x.v2])).ToArray();
        b = b.Select(x => new P(zip[x.v1], zip[x.v2])).ToArray();
        Array.Sort(a, (x, y) => y.v2.CompareTo(x.v2));
        Array.Sort(b, (x, y) => y.v1.CompareTo(x.v1));
        var sg = new Segtree <P>(all.Count, (x, y) => x.v2 > y.v2 ? x.v1 > 0 ? x : y : y.v1 > 0 ? y : x, new P(0, -1));

        for (int i = 0; i < all.Count; i++)
        {
            sg.assign(i, new P(0, i));
        }

        sg.all_update();
        int bi = 0, ans = 0;

        for (int i = 0; i < n; i++)
        {
            while (bi < m && a[i].v2 <= b[bi].v1)
            {
                sg.update(b[bi].v2, new P(sg.look(b[bi].v2).v1 + 1, b[bi].v2));
                ++bi;
            }
            var p = sg.run(0, a[i].v1 + 1);
            if (p.v1 > 0)
            {
                ++ans;
                sg.update(p.v2, new P(p.v1 - 1, p.v2));
            }
        }
        Prt(ans);
        sw.Flush();
    }