예제 #1
0
            public void Solve()
            {
                int N     = NextInt();
                var Alist = new List <ti3>();
                var Blist = new List <ti3>();

                var s = 0;
                var t = 2 * N + 1;

                var mf = new MaxFlow(t + 1);

                N.REP(i =>
                {
                    var ai = NextInt();
                    var bi = NextInt();

                    Alist.Add(new ti3(ai, bi, i + 1));
                    mf.Add(s, i + 1, 1);
                });

                N.REP(i =>
                {
                    var ai = NextInt();
                    var bi = NextInt();

                    Alist.Add(new ti3(ai, bi, i + N + 1));
                    mf.Add(i + N + 1, t, 1);
                });

                var list = Alist.Concat(Blist).OrderBy(x => x.Item1).Select(item => new ti2(item.Item2, item.Item3)).ToList();

                for (int i = 0; i < list.Count; i++)
                {
                    var a = list[i].Item2;
                    if (a > N)
                    {
                        continue;
                    }
                    var ay = list[i].Item1;
                    for (int j = i + 1; j < list.Count; j++)
                    {
                        var b = list[j].Item2;
                        if (b < N + 1)
                        {
                            continue;
                        }
                        var by = list[j].Item1;
                        if (by < ay)
                        {
                            continue;
                        }

                        mf.Add(a, b, 1);
                    }
                }

                mf.Run(s, t).WL();

                return;
            }
예제 #2
0
파일: 2254885.cs 프로젝트: qifanyyy/CLCDSA
            public void Solve()
            {
                int N  = NextInt();
                var s  = 0;
                var t  = 2 * N + 1;
                var mf = new MaxFlow(t + 1);

                var A = new List <ti2>();
                var B = new List <ti2>();

                N.REP(i => {
                    A.Add(NextInt(), NextInt());
                    mf.Add(s, i + 1, 1);
                });
                N.REP(i => {
                    B.Add(NextInt(), NextInt());
                    mf.Add(i + N + 1, t, 1);
                });

                for (int i = 0; i < N; i++)
                {
                    var ax = A[i].Item1;
                    var ay = A[i].Item2;

                    for (int j = 0; j < N; j++)
                    {
                        var bx = B[j].Item1;
                        var by = B[j].Item2;

                        if (ax < bx && ay < by)
                        {
                            mf.Add(i + 1, j + N + 1, 1);
                        }
                    }
                }

                mf.Run(s, t).WL();

                return;
            }