Submission #1793000
Source Code Expand
#include <bits/stdc++.h> using namespace std; int a[2001][2001]; int r[2001][2001]; int dr[2001][2001]; int fr[2001][2001]; 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; dr[i][j] = dr[i - 1][j] + dr[i][j - 1] - dr[i - 1][j - 1]; fr[i][j] = fr[i - 1][j] + fr[i][j - 1] - fr[i - 1][j - 1]; if (a[i][j] && a[i][j - 1]) dr[i][j] += 1; if (a[i][j] && a[i - 1][j]) fr[i][j] += 1; r[i][j] = r[i - 1][j] + r[i][j - 1] - r[i - 1][j - 1] + a[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 | 700 |
Code Size | 1009 Byte |
Status | AC |
Exec Time | 514 ms |
Memory | 64384 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
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 | AC | 466 ms | 64124 KB |
02.txt | AC | 514 ms | 63872 KB |
03.txt | AC | 462 ms | 64000 KB |
04.txt | AC | 485 ms | 63744 KB |
05.txt | AC | 472 ms | 64128 KB |
06.txt | AC | 494 ms | 63872 KB |
07.txt | AC | 431 ms | 63744 KB |
08.txt | AC | 469 ms | 63232 KB |
09.txt | AC | 452 ms | 63360 KB |
10.txt | AC | 490 ms | 63744 KB |
11.txt | AC | 457 ms | 64000 KB |
12.txt | AC | 432 ms | 44160 KB |
13.txt | AC | 369 ms | 62080 KB |
14.txt | AC | 357 ms | 7168 KB |
15.txt | AC | 353 ms | 6784 KB |
16.txt | AC | 367 ms | 7040 KB |
17.txt | AC | 372 ms | 62080 KB |
18.txt | AC | 380 ms | 61696 KB |
19.txt | AC | 366 ms | 7168 KB |
20.txt | AC | 452 ms | 62080 KB |
21.txt | AC | 424 ms | 63360 KB |
22.txt | AC | 502 ms | 63744 KB |
23.txt | AC | 361 ms | 14208 KB |
24.txt | AC | 490 ms | 63744 KB |
25.txt | AC | 352 ms | 6784 KB |
26.txt | AC | 359 ms | 11520 KB |
27.txt | AC | 352 ms | 7040 KB |
28.txt | AC | 385 ms | 61696 KB |
29.txt | AC | 370 ms | 62080 KB |
30.txt | AC | 365 ms | 7040 KB |
31.txt | AC | 455 ms | 64384 KB |
32.txt | AC | 461 ms | 64128 KB |
33.txt | AC | 431 ms | 63872 KB |
34.txt | AC | 466 ms | 64000 KB |
35.txt | AC | 428 ms | 63616 KB |
36.txt | AC | 463 ms | 63616 KB |
37.txt | AC | 429 ms | 63616 KB |
38.txt | AC | 458 ms | 63616 KB |
39.txt | AC | 426 ms | 64128 KB |
40.txt | AC | 462 ms | 64000 KB |
41.txt | AC | 430 ms | 63744 KB |
42.txt | AC | 467 ms | 63616 KB |
43.txt | AC | 427 ms | 63232 KB |
44.txt | AC | 469 ms | 63360 KB |
45.txt | AC | 3 ms | 6400 KB |
46.txt | AC | 3 ms | 6400 KB |
47.txt | AC | 2 ms | 6400 KB |
48.txt | AC | 3 ms | 6400 KB |
s1.txt | AC | 2 ms | 6400 KB |
s2.txt | AC | 3 ms | 6400 KB |