Submission #1792992


Source Code Expand

#include <bits/stdc++.h>

#define int long long

using namespace std;

int a[2001][2001];
int d[3001][3001];
int f[3001][3001];
int r[3001][3001];
int dr[3001][3001];
int fr[3001][3001];

 main () {
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	int n, m, q;
	cin >> n >> m >> q;
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
			char te;
			cin >> te;
			if (te == '1') a[i][j] = 1;
			else a[i][j] = 0;
			if (a[i][j] && a[i][j - 1]) d[i][j] = 1;
			if (a[i][j] && a[i - 1][j]) f[i][j] = 1;
			r[i][j] = r[i - 1][j] + r[i][j - 1] - r[i - 1][j - 1] + a[i][j];
		}
	}
	for (int i = 1;i <= n;i ++) {
		for (int j = 1;j <= m;j ++) {
			dr[i][j] = dr[i - 1][j] + dr[i][j - 1] - dr[i - 1][j - 1] + d[i][j];
			fr[i][j] = fr[i - 1][j] + fr[i][j - 1] - fr[i - 1][j - 1] + f[i][j];	
		}
	} 
	while (q --) {
		int x, y, x1, y1;
		cin >> x >> y >> x1 >> y1;
		int cur = r[x1][y1] - r[x1][y - 1] - r[x - 1][y1] + r[x - 1][y - 1];
		int jkl = dr[x1][y1] - dr[x1][y] - dr[x - 1][y1] + dr[x - 1][y];
		int lkj = fr[x1][y1] - fr[x1][y - 1] - fr[x][y1] + fr[x][y - 1];
		cout << cur - jkl - lkj << endl;
	}
	return 0;
}

Submission Info

Submission Time
Task C - Nuske vs Phantom Thnook
User almasalmas
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1166 Byte
Status MLE
Exec Time 572 ms
Memory 275840 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 2
AC × 30
MLE × 20
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt MLE 530 ms 275584 KB
02.txt MLE 555 ms 275456 KB
03.txt MLE 531 ms 275584 KB
04.txt MLE 564 ms 275456 KB
05.txt MLE 536 ms 275840 KB
06.txt MLE 567 ms 275456 KB
07.txt AC 475 ms 197504 KB
08.txt MLE 525 ms 267264 KB
09.txt MLE 514 ms 267136 KB
10.txt MLE 546 ms 275456 KB
11.txt MLE 540 ms 275584 KB
12.txt AC 475 ms 157952 KB
13.txt MLE 431 ms 273792 KB
14.txt AC 364 ms 11392 KB
15.txt AC 341 ms 6784 KB
16.txt AC 365 ms 11136 KB
17.txt MLE 430 ms 273792 KB
18.txt AC 438 ms 224256 KB
19.txt AC 349 ms 9216 KB
20.txt AC 481 ms 162048 KB
21.txt AC 458 ms 178816 KB
22.txt MLE 568 ms 275456 KB
23.txt AC 376 ms 38400 KB
24.txt MLE 568 ms 275456 KB
25.txt AC 355 ms 10880 KB
26.txt AC 355 ms 23808 KB
27.txt AC 355 ms 9088 KB
28.txt AC 419 ms 224256 KB
29.txt MLE 432 ms 273792 KB
30.txt AC 357 ms 11264 KB
31.txt AC 472 ms 179712 KB
32.txt AC 507 ms 179456 KB
33.txt MLE 490 ms 275456 KB
34.txt AC 506 ms 179456 KB
35.txt AC 506 ms 228096 KB
36.txt AC 572 ms 226048 KB
37.txt MLE 500 ms 275200 KB
38.txt AC 545 ms 228096 KB
39.txt AC 479 ms 179584 KB
40.txt AC 515 ms 179456 KB
41.txt MLE 502 ms 275456 KB
42.txt MLE 528 ms 275200 KB
43.txt MLE 490 ms 274816 KB
44.txt AC 521 ms 227840 KB
45.txt AC 2 ms 6400 KB
46.txt AC 2 ms 6400 KB
47.txt AC 3 ms 8448 KB
48.txt AC 4 ms 10496 KB
s1.txt AC 4 ms 10496 KB
s2.txt AC 3 ms 10496 KB