Submission #69076995
Source Code Expand
/* Code By WCM */
/*
Date:
大致思路:
复杂度:
期望得分:
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <vector>
#include <queue>
using namespace std;
inline int read();
void write(int);
void writeln(int);
const int N = 505;
int n, q, A[N][N], sum[N][N], U, D, L, R;
int main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> q;
vector<string> a(n);
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n - 1; i++)
for(int j = 0; j < n - 1; j++)
if(a[i][j] == '.' && a[i][j + 1] == '.' && a[i + 1][j] == '.' && a[i + 1][j + 1] == '.')
A[i][j] = 1;
for(int i = 0; i < n - 1; i++)
for(int j = 0; j < n - 1; j++)
sum[i + 1][j + 1] = sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + A[i][j];
while(q--) {
cin >> U >> D >> L >> R;
int r1 = U - 1, r2 = D - 2, c1 = L - 1, c2 = R - 2;
if(r1 > r2 || c1 > c2) cout << "0\n";
else cout << sum[r2 + 1][c2 + 1] - sum[r1][c2 + 1] - sum[r2 + 1][c1] + sum[r1][c1] << '\n';
}
// printf("\nThe time used: ");
// printf("%.2lfs",(double)clock()/CLOCKS_PER_SEC);
return 0;
}
inline int read() {
int res = 0, f = 1;
char ch = getchar();
while( !(ch >= '0' && ch <= '9') ) {
if(ch == '-') f = -1;
ch = getchar();
}
while(ch >= '0' && ch <= '9') {
res = (res << 1) + (res << 3) + (ch ^ 48);
ch = getchar();
}
return res * f;
}
void write(int x) {
static int sta[35];
int top = 0;
do {
sta[top++] = x % 10;
x /= 10;
} while(x);
while(top) putchar(sta[--top] ^ 48);
}
void writeln(int x) {
write(x);
putchar('\n');
}
Submission Info
| Submission Time | |
|---|---|
| Task | A - 2x2 Erasing |
| User | WZwangchongming |
| Language | C++ 20 (gcc 12.2) |
| Score | 400 |
| Code Size | 1904 Byte |
| Status | AC |
| Exec Time | 42 ms |
| Memory | 5776 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| 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 | 3432 KiB |
| 00_sample_01.txt | AC | 1 ms | 3496 KiB |
| 01_handmade_00.txt | AC | 28 ms | 3388 KiB |
| 01_handmade_01.txt | AC | 34 ms | 5576 KiB |
| 01_handmade_02.txt | AC | 1 ms | 3468 KiB |
| 01_handmade_03.txt | AC | 39 ms | 4740 KiB |
| 01_handmade_04.txt | AC | 36 ms | 5724 KiB |
| 02_random_00.txt | AC | 40 ms | 4976 KiB |
| 02_random_01.txt | AC | 37 ms | 4108 KiB |
| 02_random_02.txt | AC | 41 ms | 5516 KiB |
| 02_random_03.txt | AC | 33 ms | 3896 KiB |
| 02_random_04.txt | AC | 35 ms | 3636 KiB |
| 02_random_05.txt | AC | 42 ms | 5636 KiB |
| 02_random_06.txt | AC | 41 ms | 5760 KiB |
| 02_random_07.txt | AC | 42 ms | 5728 KiB |
| 02_random_08.txt | AC | 42 ms | 5772 KiB |
| 02_random_09.txt | AC | 41 ms | 5772 KiB |
| 02_random_10.txt | AC | 37 ms | 5572 KiB |
| 02_random_11.txt | AC | 38 ms | 5692 KiB |
| 02_random_12.txt | AC | 37 ms | 5692 KiB |
| 02_random_13.txt | AC | 37 ms | 5704 KiB |
| 02_random_14.txt | AC | 37 ms | 5696 KiB |
| 02_random_15.txt | AC | 37 ms | 5724 KiB |
| 02_random_16.txt | AC | 36 ms | 5776 KiB |
| 02_random_17.txt | AC | 37 ms | 5704 KiB |
| 02_random_18.txt | AC | 37 ms | 5672 KiB |
| 02_random_19.txt | AC | 37 ms | 5696 KiB |
| 02_random_20.txt | AC | 38 ms | 5736 KiB |