# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
460803 |
2021-08-09T09:54:21 Z |
grt |
Strah (COCI18_strah) |
C++17 |
|
158 ms |
19972 KB |
#include <bits/stdc++.h>
#define PB push_back
#define ST first
#define ND second
#define _ ios_base::sync_with_stdio(0); cin.tie(0);
//mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
const int nax = 2010;
int n, m;
char t[nax][nax];
int up[nax][nax];
int main() {_
cin >> n >> m;
for(int i = 1; i <= n; ++i) {
for(int j = 1; j <= m; ++j) {
cin >> t[i][j];
if(t[i][j] == '.') up[i][j] = up[i - 1][j] + 1;
else up[i][j] = 0;
}
}
ll ans = 0;
for(int i = 1; i <= n; ++i) {
vector<pi> S = {{-1, 0}};
ll cur = 0;
ll sum = 0;
for(int j = 1; j <= m; ++j) {
while((int)S.size() > 0 && S.back().ST >= up[i][j]) {
int p1 = S.back().ND;
int p2 = S[(int)S.size() - 2].ND;
cur -= 1LL * (S.back().ST * (S.back().ST + 1) / 2) * (p1 - p2) * (2*(j-1) - p1 - p2 + 1) / 2;
sum -= 1LL * (p1 - p2) * S.back().ST * (S.back().ST + 1) / 2;
S.pop_back();
}
int p1 = j;
int p2 = S.back().ND;
S.emplace_back(up[i][j], j);
cur += 1LL * (up[i][j] * (up[i][j] + 1) / 2) * ((p1 - p2) * (2*j-p1-p2 + 1)) / 2;
cur += sum;
sum += 1LL * (p1 - p2) * up[i][j] * (up[i][j] + 1) / 2;
ans += cur;
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2472 KB |
Output is correct |
2 |
Correct |
5 ms |
2380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2380 KB |
Output is correct |
2 |
Correct |
5 ms |
2380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2380 KB |
Output is correct |
2 |
Correct |
5 ms |
2380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
8476 KB |
Output is correct |
2 |
Correct |
95 ms |
15196 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
13376 KB |
Output is correct |
2 |
Correct |
138 ms |
19348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
8692 KB |
Output is correct |
2 |
Correct |
102 ms |
16196 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
12252 KB |
Output is correct |
2 |
Correct |
102 ms |
18780 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
19948 KB |
Output is correct |
2 |
Correct |
158 ms |
19972 KB |
Output is correct |