Submission #69444208


Source Code Expand

// To scale the heights, one must embrace the fall.
#include <bits/stdc++.h>
#define fi first
#define se second
#define int long long
#define pb emplace_back
#define F(i, a, b) for (int i = (a); i <= (b); ++i)
#define dF(i, a, b) for (int i = (a); i >= (b); --i)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int N = 505, M = (N << 1), inf = 1e16, mod = 1e9 + 7;
int n, m, a[N][N], s[N][N];
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n >> m;
    F(i, 1, n) {
        F(j, 1, n) {
            char c;
            cin >> c;
            a[i][j] = c == '.';
        }
    }
    F(i, 1, n - 1) F(j, 1, n - 1) {
        if (a[i][j] && a[i + 1][j] && a[i][j + 1] && a[i + 1][j + 1])
            s[i][j] = 1;
        s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
    }

    while (m--) {
        int u, d, l, r;
        cin >> u >> d >> l >> r;
        int sum = s[d - 1][r - 1] - s[u - 1][r - 1] - s[d - 1][l - 1] + s[u - 1][l - 1];
        cout << sum << '\n';
    }
    return 0;
}

Submission Info

Submission Time
Task A - 2x2 Erasing
User zhutianrui
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1105 Byte
Status AC
Exec Time 46 ms
Memory 7572 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 28
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3512 KiB
00_sample_01.txt AC 1 ms 3548 KiB
01_handmade_00.txt AC 27 ms 3428 KiB
01_handmade_01.txt AC 35 ms 7360 KiB
01_handmade_02.txt AC 1 ms 3508 KiB
01_handmade_03.txt AC 44 ms 7372 KiB
01_handmade_04.txt AC 37 ms 7496 KiB
02_random_00.txt AC 41 ms 6452 KiB
02_random_01.txt AC 36 ms 4528 KiB
02_random_02.txt AC 43 ms 7224 KiB
02_random_03.txt AC 33 ms 4332 KiB
02_random_04.txt AC 33 ms 3652 KiB
02_random_05.txt AC 46 ms 7364 KiB
02_random_06.txt AC 44 ms 7304 KiB
02_random_07.txt AC 44 ms 7448 KiB
02_random_08.txt AC 44 ms 7572 KiB
02_random_09.txt AC 43 ms 7500 KiB
02_random_10.txt AC 38 ms 7428 KiB
02_random_11.txt AC 38 ms 7456 KiB
02_random_12.txt AC 37 ms 7424 KiB
02_random_13.txt AC 37 ms 7496 KiB
02_random_14.txt AC 38 ms 7376 KiB
02_random_15.txt AC 38 ms 7452 KiB
02_random_16.txt AC 38 ms 7448 KiB
02_random_17.txt AC 38 ms 7364 KiB
02_random_18.txt AC 37 ms 7448 KiB
02_random_19.txt AC 38 ms 7572 KiB
02_random_20.txt AC 41 ms 7452 KiB