Submission #69073668


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define rep(i, s, t) for(int i = (s); i <= (t); i ++)
#define per(i, s, t) for(int i = (s); i >= (t); i --)
template<typename T, typename T2>
inline void chmin(T &x, T2 &&y) { x = min(x, y); }
template<typename T, typename T2>
inline void chmax(T &x, T2 &&y) { x = max(x, y); }
typedef long long ll;

const int N = 505;

int n, q;
int s[N][N];
string a[N];

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n >> q;
    rep(i, 1, n) cin >> a[i], a[i] = ' ' + a[i];
    rep(i, 1, n - 1) rep(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(q --)
    {
        int xl, xr, yl, yr;
        cin >> xl >> xr >> yl >> yr;
        xr --, yr --;
        cout << s[xr][yr] - s[xl - 1][yr] - s[xr][yl - 1] + s[xl - 1][yl - 1] << "\n";
    }

    return 0;
}

Submission Info

Submission Time
Task A - 2x2 Erasing
User adam01
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1017 Byte
Status AC
Exec Time 45 ms
Memory 4904 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 3656 KiB
00_sample_01.txt AC 1 ms 3524 KiB
01_handmade_00.txt AC 31 ms 3536 KiB
01_handmade_01.txt AC 37 ms 4900 KiB
01_handmade_02.txt AC 1 ms 3524 KiB
01_handmade_03.txt AC 42 ms 4708 KiB
01_handmade_04.txt AC 39 ms 4788 KiB
02_random_00.txt AC 42 ms 4384 KiB
02_random_01.txt AC 39 ms 3748 KiB
02_random_02.txt AC 44 ms 4572 KiB
02_random_03.txt AC 37 ms 3796 KiB
02_random_04.txt AC 37 ms 3544 KiB
02_random_05.txt AC 45 ms 4720 KiB
02_random_06.txt AC 44 ms 4644 KiB
02_random_07.txt AC 44 ms 4904 KiB
02_random_08.txt AC 45 ms 4676 KiB
02_random_09.txt AC 44 ms 4788 KiB
02_random_10.txt AC 40 ms 4780 KiB
02_random_11.txt AC 40 ms 4704 KiB
02_random_12.txt AC 40 ms 4900 KiB
02_random_13.txt AC 40 ms 4780 KiB
02_random_14.txt AC 40 ms 4852 KiB
02_random_15.txt AC 41 ms 4784 KiB
02_random_16.txt AC 39 ms 4852 KiB
02_random_17.txt AC 39 ms 4904 KiB
02_random_18.txt AC 40 ms 4764 KiB
02_random_19.txt AC 39 ms 4788 KiB
02_random_20.txt AC 42 ms 4648 KiB