예제 #1
0
    static object Solve()
    {
        var(n, k) = Read2();
        var a = Array.ConvertAll(new bool[n], _ => Read());

        return(Last(0, a.Max(r => r.Max()), m =>
        {
            var raq = new StaticRAQ2(n, n);

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    raq.Add(i, j, i + k, j + k, a[i][j] >= m ? 1 : -1);
                }
            }

            var all = raq.GetAll0();

            for (int i = k - 1; i < n; i++)
            {
                for (int j = k - 1; j < n; j++)
                {
                    if (all[i, j] <= 0)
                    {
                        return false;
                    }
                }
            }
            return true;
        }));
    }
예제 #2
0
    static void Main()
    {
        var z = Read();
        int h = z[0], w = z[1], n = z[2], m = z[3];
        var abs = Array.ConvertAll(new bool[n], _ => Read().Select(v => v - 1).ToArray());
        var cds = Array.ConvertAll(new bool[m], _ => Read().Select(v => v - 1).ToArray());

        var a = new bool[h, w];

        foreach (var p in cds)
        {
            a[p[0], p[1]] = true;
        }

        var rh = Enumerable.Range(0, h).ToArray();
        var rw = Enumerable.Range(0, w).ToArray();

        var bRow = rh.Select(i => rw.Where(j => a[i, j]).ToArray()).ToArray();
        var bCol = rw.Select(j => rh.Where(i => a[i, j]).ToArray()).ToArray();

        var raq = new StaticRAQ2(h, w);

        foreach (var p in abs)
        {
            var r = bRow[p[0]];
            var c = bCol[p[1]];

            var j = First(0, r.Length, x => r[x] > p[1]);
            raq.Add(p[0], j == 0 ? 0 : r[j - 1] + 1, p[0] + 1, j == r.Length ? w : r[j], 1);

            var i = First(0, c.Length, x => c[x] > p[0]);
            raq.Add(i == 0 ? 0 : c[i - 1] + 1, p[1], i == c.Length ? h : c[i], p[1] + 1, 1);
        }

        var d   = raq.GetAll0();
        var sum = 0;

        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                if (d[i, j] > 0)
                {
                    sum++;
                }
            }
        }
        Console.WriteLine(sum);
    }
예제 #3
0
	static object Solve()
	{
		var n = int.Parse(Console.ReadLine());
		var ps = Array.ConvertAll(new bool[n], _ => Read4());

		var raq = new StaticRAQ2(h, w);
		foreach (var (lx, ly, rx, ry) in ps)
		{
			raq.Add(lx, ly, rx, ry, 1);
		}
		var all = raq.GetAll0();

		var r = new int[n];
		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				if (all[i, j] == 0) continue;
				r[all[i, j] - 1]++;
			}
		}
		return string.Join("\n", r);
	}
예제 #4
0
    static object Solve()
    {
        var(n, k) = Read2();
        var ps = Array.ConvertAll(new bool[n], _ => Read2());

        var raq = new StaticRAQ2(max + 1, max + 1);

        foreach (var(a, b) in ps)
        {
            raq.Add(a, b, a + k + 1, b + k + 1, 1);
        }
        var all = raq.GetAll0();

        var r = 0L;

        for (int i = 0; i <= max; i++)
        {
            for (int j = 0; j <= max; j++)
            {
                r = Math.Max(r, all[i, j]);
            }
        }
        return(r);
    }