# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
639141 |
2022-09-08T17:36:00 Z |
classic |
Bob (COCI14_bob) |
C++14 |
|
139 ms |
21912 KB |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<vector<int>> a(n, vector<int>(m));
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
cin >> a[i][j];
}
}
long long res = 0;
vector<vector<long long>> col(n, vector<long long>(m));
for (int i = 0; i < n; i++) {
vector<tuple<int, int, int, long long>> stk;
stk.emplace_back(0, 0, 0, 0);
// sum - a[i][j] - col[i][j] - cur
for (int j = 0; j < m; j++) {
if (i > 0 && a[i - 1][j] == a[i][j]) {
col[i][j] = col[i - 1][j] + 1;
} else {
col[i][j] = 1;
}
int sum = 1;
while (!stk.empty() && get<1>(stk.back()) == a[i][j] && get<2>(stk.back()) == col[i][j]) {
sum += get<0>(stk.back());
stk.pop_back();
}
long long cur = 1LL * sum * col[i][j];
if (get<1>(stk.back()) == a[i][j]) {
cur += get<3>(stk.back());
}
res += cur;
stk.emplace_back(sum, a[i][j], col[i][j], cur);
}
}
cout << res;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
3864 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
29 ms |
4252 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
4436 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
4472 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
92 ms |
18768 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
139 ms |
21912 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
116 ms |
21652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
113 ms |
21792 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |