32832023-02-23 22:19:50zsomborSivatagcpp17Wrong answer 36/40120ms8532 KiB
#include <iostream>
#include <vector>
using namespace std;

int n, m, k, e, x1, y1, x2, y2, cur, ans = 0;
vector <vector <int>> fen(501, vector<int>(501, 0));
vector <vector <int>> pre(501, vector<int>(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;
}
SubtaskSumTestVerdictTimeMemory
base36/40
1Accepted0/04ms5860 KiB
2Wrong answer0/0119ms6072 KiB
3Accepted2/24ms6280 KiB
4Accepted2/26ms6436 KiB
5Accepted2/210ms6668 KiB
6Accepted2/210ms6804 KiB
7Accepted2/210ms6756 KiB
8Accepted2/210ms7052 KiB
9Accepted2/24ms7228 KiB
10Accepted2/24ms7660 KiB
11Accepted2/210ms7664 KiB
12Accepted2/210ms8020 KiB
13Accepted2/210ms7964 KiB
14Accepted2/29ms7900 KiB
15Accepted1/1112ms8188 KiB
16Accepted1/1115ms8108 KiB
17Accepted1/154ms8152 KiB
18Accepted1/197ms8116 KiB
19Accepted2/2119ms8112 KiB
20Wrong answer0/2119ms8108 KiB
21Accepted2/2119ms8112 KiB
22Wrong answer0/2120ms8112 KiB
23Accepted2/2119ms8272 KiB
24Accepted2/2119ms8532 KiB