Submission #871368

# Submission time Handle Problem Language Result Execution time Memory
871368 2023-11-10T16:32:16 Z honanhphong Quality Of Living (IOI10_quality) C++14
0 / 100
1 ms 4444 KB
#include <bits/stdc++.h>
using namespace std;
using lli = long long;
using ld = long double;
using pii = pair <int, int>;
const int maxn = 3e3 + 1000;
const int mod = 1e9 + 7;
int m, n, h, w, b[maxn][maxn], a[maxn][maxn], pre[maxn][maxn], q[3001][3001];

bool check(lli x)
{
    for (lli i = 1; i <= m; i ++)
    {
        for (lli j = 1; j <= n; j ++)
        {
            a[i][j] = 0;
        }
    }
    for (lli i = 1; i <= m; i ++)
    {
        for (lli j = 1; j <= n; j ++)
        {
            if (b[i][j] <= x)
            {
                a[i][j] = 1;
            }
        }
    }
    for (lli i = 1; i <= m; i ++)
    {
        for (lli j = 1; j <= n; j ++)
        {
            pre[i][j] = a[i][j] + pre[i][j - 1] + pre[i - 1][j] - pre[i - 1][j - 1];
        }
    }
    for (lli i = 1; i <= m - h + 1; i ++)
    {
        for (lli j = 1; j <= n - w + 1; j ++)
        {
            lli sum = pre[i + h - 1][j + w - 1] - pre[i + h - 1][j - 1] - pre[i - 1][j + w - 1] + pre[i - 1][j - 1];
            if (sum > (h * w - 1) / 2)
            {
                return true;
            }
        }
    }
    return false;
}

int rectangle(int m, int n, int h, int w, int q[3001][3001])
{
    n = n, m = m, h = h, w = w;
    for (lli i = 1; i <= m; i ++)
    {
        for (lli j = 1; j <= n; j ++)
        {
            b[i][j] = q[i - 1][j - 1];
        }
    }
    lli l = 0, r = m * n, res = 0;
    while (l <= r)
    {
        lli mid = (l + r) / 2;
        if (check(mid))
        {
            res = mid;
            r = mid - 1;
        } else l = mid + 1;
        //cout << mid << endl;
    }
    return res;
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -