Submission #69076367


Source Code Expand

#include<iostream>
using namespace std;
#define int long long
const int N = 505;

int n,q,a[N][N],b[N][N],vis[N][N],res[N][N];

signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> q;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			char c; cin >> c;
			if(c == '.') a[i][j] = b[i][j] = 1;
		}
	for(int i=1;i<=n-1;i++)
		for(int j=1;j<=n-1;j++)
			if(b[i][j] && b[i+1][j] && b[i][j+1] && b[i+1][j+1]) vis[i][j] = 1;
	for(int i=1;i<=n-1;i++)
		for(int j=1;j<=n-1;j++)
			res[i][j] = res[i-1][j] + res[i][j-1] - res[i-1][j-1] + vis[i][j];
//	for(int i=1;i<=n-1;i++,cout<<endl)
//		for(int j=1;j<=n-1;j++)
//			cout << res[i][j] << " ";
	while(q--)
	{
		int u, d, l, r, ans = 0; cin >> u >> d >> l >> r;
		ans = res[d-1][r-1] - res[u-1][r-1] - res[d-1][l-1] + res[u-1][l-1];
		if(ans < 0) ans = 0;
		cout << ans << '\n';
	}
	return 0;
}

/*

.##...
###.#.
......

----

*/

Submission Info

Submission Time
Task A - 2x2 Erasing
User yangyang1000
Language C++ 20 (gcc 12.2)
Score 400
Code Size 947 Byte
Status AC
Exec Time 46 ms
Memory 11512 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 3536 KiB
00_sample_01.txt AC 1 ms 3576 KiB
01_handmade_00.txt AC 26 ms 3508 KiB
01_handmade_01.txt AC 36 ms 11236 KiB
01_handmade_02.txt AC 1 ms 3444 KiB
01_handmade_03.txt AC 43 ms 9404 KiB
01_handmade_04.txt AC 38 ms 11384 KiB
02_random_00.txt AC 42 ms 9152 KiB
02_random_01.txt AC 36 ms 5700 KiB
02_random_02.txt AC 44 ms 10772 KiB
02_random_03.txt AC 32 ms 4828 KiB
02_random_04.txt AC 33 ms 4008 KiB
02_random_05.txt AC 46 ms 11296 KiB
02_random_06.txt AC 46 ms 11508 KiB
02_random_07.txt AC 45 ms 11312 KiB
02_random_08.txt AC 45 ms 11368 KiB
02_random_09.txt AC 45 ms 11512 KiB
02_random_10.txt AC 41 ms 11320 KiB
02_random_11.txt AC 40 ms 11364 KiB
02_random_12.txt AC 39 ms 11356 KiB
02_random_13.txt AC 40 ms 11292 KiB
02_random_14.txt AC 39 ms 11372 KiB
02_random_15.txt AC 40 ms 11376 KiB
02_random_16.txt AC 38 ms 11508 KiB
02_random_17.txt AC 39 ms 11308 KiB
02_random_18.txt AC 39 ms 11316 KiB
02_random_19.txt AC 39 ms 11376 KiB
02_random_20.txt AC 44 ms 11296 KiB