32842023-02-23 22:24:01zsomborSivatagcpp17Elfogadva 40/40126ms10224 KiB
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

int n, m, k, e, x1, y1, x2, y2;
ll cur, ans = 0;
vector <vector <int>> fen(501, vector<int>(501, 0));
vector <vector <ll>> pre(501, vector<ll>(501, 0));

void pref_update(int x, int y, int val) {
    for (int i = x; i >= 0; i = (i & (i + 1)) - 1) {
        for (int j = y; j >= 0; j = (j & (j + 1)) - 1) {
            fen[i][j] += val;
        }
    }
}

void update() {
    cin >> x1 >> y1 >> x2 >> y2;
    x1--; y1--;
    pref_update(x1, y1, 1);
    pref_update(x2, y2, 1);
    pref_update(x1, y2, -1);
    pref_update(x2, y1, -1);
}

int query(int x, int y) {
    int ret = 0;
    for (int i = x; i <= n; i = (i | (i + 1))) {
        for (int j = y; j <= m; j = (j | (j + 1))) {
            ret += fen[i][j];
        }
    }
    return ret;
}

int main()
{
    cin >> n >> m >> k >> e;
    for (int i = 0; i < e; i++) update();
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            pre[i][j] = query(i, j) + pre[i - 1][j] + pre[i][j - 1] - pre[i - 1][j - 1];
            if (i < k || j < k) continue;
            cur = pre[i][j] - pre[i - k][j] - pre[i][j - k] + pre[i - k][j - k];
            if (cur > ans) { ans = cur; x1 = i - k + 1; y1 = j - k + 1; }
        }
    }
    cout << ans << endl << x1 << " " << y1;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base40/40
1Elfogadva0/04ms7608 KiB
2Elfogadva0/0126ms7900 KiB
3Elfogadva2/24ms8116 KiB
4Elfogadva2/26ms8068 KiB
5Elfogadva2/210ms8344 KiB
6Elfogadva2/210ms8668 KiB
7Elfogadva2/210ms8620 KiB
8Elfogadva2/210ms8956 KiB
9Elfogadva2/24ms8916 KiB
10Elfogadva2/26ms8908 KiB
11Elfogadva2/210ms8964 KiB
12Elfogadva2/210ms9028 KiB
13Elfogadva2/210ms9164 KiB
14Elfogadva2/210ms9504 KiB
15Elfogadva1/1115ms9840 KiB
16Elfogadva1/1119ms9668 KiB
17Elfogadva1/156ms9552 KiB
18Elfogadva1/1101ms9800 KiB
19Elfogadva2/2125ms10136 KiB
20Elfogadva2/2123ms10092 KiB
21Elfogadva2/2123ms10224 KiB
22Elfogadva2/2123ms10188 KiB
23Elfogadva2/2123ms10180 KiB
24Elfogadva2/2123ms10184 KiB