# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
397069 |
2021-05-01T09:21:11 Z |
mewnian |
Bob (COCI14_bob) |
C++14 |
|
159 ms |
32860 KB |
#include <bits/stdc++.h>
#define sze(x) (ll)x.size()
#define idx(x, a) get<x>(a)
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
const ll MAXN = 1e3 + 3;
const ll INF = 1e18 + 7;
ll a[MAXN][MAXN], h[MAXN][MAXN], l[MAXN][MAXN], cnt[MAXN][MAXN], m, n, res = 0;
int main()
{
ios_base::sync_with_stdio(0); cout.tie(0);
#ifdef OFFLINE
freopen("input.inp", "r", stdin);
#endif
cin >> m >> n;
for (ll i = 1; i <= m; ++i)
{
for (ll j = 1; j <= n; ++j) cin >> a[i][j];
h[i][0] = h[i][n + 1] = -INF;
}
fill(h[1] + 1, h[1] + n + 1, 1);
for (ll i = 2; i <= m; ++i)
for (ll j = 1; j <= n; ++j)
h[i][j] = (a[i][j] == a[i - 1][j] ? h[i - 1][j] + 1 : 1);
for (ll i = 1; i <= m; ++i)
{
stack<ll> posL, posR;
for (ll j = 1; j <= n; ++j)
{
if (j == 1 || a[i][j] != a[i][j - 1])
{
while (!posL.empty()) posL.pop();
posL.push(j - 1);
}
else while (h[i][j] <= h[i][posL.top()]) posL.pop();
l[i][j] = posL.top();
posL.push(j);
cnt[i][j] = (j - l[i][j]) * h[i][j] + cnt[i][l[i][j]] * (a[i][l[i][j]] == a[i][j]);
//cout << cnt[i][j] << ' ';
res += cnt[i][j];
}
//cout << endl;
}
cout << res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
1356 KB |
Execution killed with signal 11 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
1328 KB |
Execution killed with signal 11 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
30 ms |
16324 KB |
Execution killed with signal 11 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
33 ms |
16376 KB |
Execution killed with signal 11 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
35 ms |
16340 KB |
Execution killed with signal 11 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
35 ms |
16380 KB |
Execution killed with signal 11 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
130 ms |
32860 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
144 ms |
32276 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
149 ms |
32360 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
159 ms |
32352 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |