0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 18:16:26 +00:00

#907. 【2018.8雅礼8.12T1】a

https://sjzezoj.com/submission/27607
This commit is contained in:
Baoshuo Ren 2021-09-08 21:35:32 +08:00 committed by Baoshuo Ren
parent 32ac6e85f5
commit 9f939a372d
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

31
S2OJ/907/907.cpp Normal file
View File

@ -0,0 +1,31 @@
#include <bits/stdc++.h>
using namespace std;
int n, m, l, r, g[35][50005];
long long h, t, p, s[35][50005], ans;
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
scanf("%1d", g[i] + j);
s[i][j] = 0ll + s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + g[i][j];
}
}
cin >> l >> r;
for (int i = 1; i <= n; i++) {
for (int j = i; j <= n; j++) {
h = t = p = 1;
while (p <= m && s[j][p] - s[j][0] - s[i - 1][p] + s[i - 1][0] < l) p++;
while (p <= m) {
while (h < p && s[j][p] - s[j][h - 1] - s[i - 1][p] + s[i - 1][h - 1] > r) h++;
while (t < p && s[j][p] - s[j][t] - s[i - 1][p] + s[i - 1][t] >= l) t++;
ans += t - h + 1;
p++;
}
}
}
cout << ans << endl;
return 0;
}