Contest Duration: - (local time) (110 minutes) Back to Home

Submission #8388987

Source Code Expand

Copy
```# include<bits/stdc++.h>

using namespace std;

# define int long long
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pll;

# define S second
# define F first
# define kill(x) return(cout << x << endl, 0)
# define debug(x) cerr<< #x << " : " << x << endl
# define ddebug(x, y) cerr<< #x << " : " << x  << ", " << #y << " : " << y << endl
# define sz(s) (int)s.size()
# define sq(x) (x) * (x)
# define PB(x) push_back(x)
# define smax(x, y) (x) = max((x), (y))
# define smin(x, y) (x) = min((x), (y))
# define all(x) x.begin(), x.end()
# define SP fixed << setprecision(10)

const int MAXN = 2000 + 10;
int cnt[MAXN][MAXN], a1[MAXN][MAXN], a2[MAXN][MAXN];
string s[MAXN];

int32_t main()
{
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int n, m, q;
cin >> n >> m >> q;
for (int i = 0; i < n; i ++)
cin >> s[i];

for (int i = 0; i < n; i ++)
for (int j = 0; j < m; j ++)
cnt[i + 1][j + 1] = cnt[i + 1][j] + cnt[i][j + 1] - cnt[i][j] + (s[i][j] - '0');

for (int i = 0; i < n; i ++)
for (int j = 1; j < m; j ++)
a1[i + 1][j + 1] = a1[i + 1][j] + a1[i][j + 1] - a1[i][j] + (s[i][j] == '1' && s[i][j - 1] == '1');

for (int i = 1; i < n; i ++)
for (int j = 0; j < m; j ++)
a2[i + 1][j + 1] = a2[i + 1][j] + a2[i][j + 1] - a2[i][j] + (s[i][j] == '1' && s[i - 1][j] == '1');

while (q --)
{
int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
cout << (cnt[x2][y2] - (cnt[x2][y1 - 1] + cnt[x1 - 1][y2] - cnt[x1 - 1][y1 - 1])) -
((a1[x2][y2] - (a1[x2][y1] + a1[x1 - 1][y2] - a1[x1 - 1][y1])) +
(a2[x2][y2] - (a2[x1][y2] + a2[x2][y1 - 1] - a2[x1][y1 - 1]))) << endl;
}

return 0;
}

```

#### Submission Info

Submission Time 2019-11-11 02:12:44+0900 C - Nuske vs Phantom Thnook zahra__d C++14 (GCC 5.4.1) 700 1750 Byte AC 475 ms 100608 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
 AC × 2
 AC × 50
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 436 ms 100224 KB
02.txt AC 475 ms 100096 KB
03.txt AC 445 ms 100096 KB
04.txt AC 469 ms 99968 KB
05.txt AC 441 ms 100480 KB
06.txt AC 475 ms 100096 KB
07.txt AC 410 ms 99840 KB
08.txt AC 446 ms 99584 KB
09.txt AC 428 ms 99200 KB
10.txt AC 472 ms 99968 KB
11.txt AC 434 ms 100224 KB
12.txt AC 410 ms 59776 KB
13.txt AC 371 ms 93952 KB
14.txt AC 347 ms 5248 KB
15.txt AC 337 ms 2688 KB
16.txt AC 354 ms 4992 KB
17.txt AC 365 ms 93952 KB
18.txt AC 374 ms 64896 KB
19.txt AC 345 ms 5120 KB
20.txt AC 429 ms 94592 KB
21.txt AC 405 ms 99584 KB
22.txt AC 475 ms 99968 KB
23.txt AC 357 ms 14080 KB
24.txt AC 475 ms 99968 KB
25.txt AC 335 ms 4736 KB
26.txt AC 352 ms 9472 KB
27.txt AC 349 ms 4992 KB
28.txt AC 372 ms 64896 KB
29.txt AC 363 ms 93952 KB
30.txt AC 351 ms 5120 KB
31.txt AC 421 ms 100608 KB
32.txt AC 457 ms 100352 KB
33.txt AC 408 ms 100096 KB
34.txt AC 452 ms 100352 KB
35.txt AC 405 ms 99840 KB
36.txt AC 443 ms 99840 KB
37.txt AC 415 ms 99840 KB
38.txt AC 449 ms 99840 KB
39.txt AC 417 ms 100480 KB
40.txt AC 445 ms 100224 KB
41.txt AC 426 ms 100096 KB
42.txt AC 451 ms 99840 KB
43.txt AC 402 ms 99456 KB
44.txt AC 442 ms 99584 KB
45.txt AC 2 ms 2304 KB
46.txt AC 2 ms 4352 KB
47.txt AC 2 ms 4352 KB
48.txt AC 2 ms 4352 KB
s1.txt AC 2 ms 4352 KB
s2.txt AC 2 ms 4352 KB