# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
81698 |
2018-10-26T08:37:08 Z |
Saboon |
Strah (COCI18_strah) |
C++14 |
|
1000 ms |
7932 KB |
#include <iostream>
#include <sstream>
#include <queue>
#include <stack>
#include <vector>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <iomanip>
#define F first
#define S second
#define PB push_back
#define PF push_front
#define MP make_pair
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int maxn = 1e5 + 37;
int n, m;
int a[maxn];
int l[maxn], r[maxn];
ll get () {
stack <int> s;
for (int i = m - 1; i >= 0; i--) {
while (!s.empty() and a[s.top()] >= a[i])
s.pop();
if (!s.empty())
r[i] = s.top();
else
r[i] = m;
s.push (i);
}
while (!s.empty())
s.pop();
for (int i = 0; i < m; i++) {
while (!s.empty() and a[s.top()] > a[i])
s.pop();
if (!s.empty())
l[i] = s.top();
else
l[i] = -1;
s.push (i);
}
ll ret = 0;
for (int i = 0; i < m; i++) {
for (int j = i; j < r[i]; j++) {
for (int k = i; k > l[i]; k--) {
ret += a[i] * (a[i] + 1) * (j - k + 1) / 2;
}
}
}
return ret;
}
string s[maxn];
int main() {
ios_base::sync_with_stdio(false);
cin >> n >> m;
for (int i = 0; i < n; i++)
cin >> s[i];
ll ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (s[i][j] == '#')
a[j] = 0;
else
a[j] ++;
}
ans += get ();
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3448 KB |
Output is correct |
2 |
Correct |
5 ms |
3572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
3776 KB |
Output is correct |
2 |
Correct |
4 ms |
3776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
3776 KB |
Output is correct |
2 |
Correct |
26 ms |
3776 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
3776 KB |
Output is correct |
2 |
Correct |
28 ms |
3948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
3948 KB |
Output is correct |
2 |
Correct |
26 ms |
3948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
950 ms |
4988 KB |
Output is correct |
2 |
Execution timed out |
1072 ms |
6264 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1076 ms |
6268 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1074 ms |
6268 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
44 ms |
6268 KB |
Output is correct |
2 |
Execution timed out |
1078 ms |
6780 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1072 ms |
7932 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |