# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
170796 |
2019-12-26T11:21:48 Z |
BigChungus |
Strah (COCI18_strah) |
C++14 |
|
142 ms |
4344 KB |
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N = 2009;
struct Nod {
int left, right;
int g;///greutatea
};
int dp[N];
Nod v[N];
int stk[N];
long long ans;
string s;
void dfs(int nod) {
if (nod == 0)
return;
dfs(v[nod].left);
dfs(v[nod].right);
int n(v[v[nod].left].g), m(v[v[nod].right].g);
v[nod].g = n + m + 1;
ans += 1LL * dp[nod] * (dp[nod] + 1) / 2 * (n + 1) * (m + 1) * (1.0 * n / 2 + 1.0 * m / 2 + 1);
}
int main()
{
ios_base::sync_with_stdio(NULL);
cin.tie(0);
cout.tie(0);
int n, m;
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> s;
s = '$' + s;
for (int j = 1; j <= m; ++j) {
if (s[j] == '#')
dp[j] = 0;
else
dp[j]++;
}
memset(v, 0, sizeof v);
int top(0);
for (int j = 1; j <= m; ++j) {///acum parctic trebuie sa construiesc arborele cartezian
while (top && dp[stk[top]] > dp[j])
--top;
v[j].left = v[stk[top]].right;
v[stk[top]].right = j;
stk[++top] = j;
}
dfs(stk[1]);
}
cout << ans;
return 0;
}
/*
2 3
.#.
..#
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
460 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
5 ms |
548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
508 KB |
Output is correct |
2 |
Correct |
5 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
1340 KB |
Output is correct |
2 |
Correct |
83 ms |
2720 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
90 ms |
2796 KB |
Output is correct |
2 |
Correct |
125 ms |
4008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
1912 KB |
Output is correct |
2 |
Correct |
90 ms |
2992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
672 KB |
Output is correct |
2 |
Correct |
84 ms |
3320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
107 ms |
4344 KB |
Output is correct |
2 |
Correct |
142 ms |
4288 KB |
Output is correct |