# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
250679 | 2020-07-18T17:08:57 Z | kingfran1907 | Bob (COCI14_bob) | C++14 | 173 ms | 8260 KB |
#include <bits/stdc++.h> using namespace std; typedef long long llint; const int maxn = 1010; int n, m; int niz[maxn][maxn]; int cn[maxn][maxn]; vector< int > v; int sol[maxn]; stack< llint > p, q; llint cal() { while (!q.empty()) {q.pop(); p.pop();} llint out = 0; llint tren = 0; for (int i = 0; i < v.size(); i++) { llint cnt = 1; while (!p.empty() && p.top() >= v[i]) { llint ac = q.top(); q.pop(); llint val = p.top(); p.top(); cnt += ac; tren -= ac * (val - v[i]); } tren += v[i]; out += tren; } v.clear(); return out; } int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) scanf("%d", &niz[i][j]); for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (i == 0) cn[i][j] = 1; else { if (niz[i][j] == niz[i - 1][j]) cn[i][j] = 1 + cn[i - 1][j]; else cn[i][j] = 1; } } } llint sol = 0; for (int i = 0; i < n; i++) { v.push_back(cn[i][0]); for (int j = 1; j < m; j++) { if (niz[i][j - 1] != niz[i][j]) sol += cal(); v.push_back(cn[i][j]); } sol += cal(); } printf("%lld", sol); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 768 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 768 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 30 ms | 4252 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 35 ms | 4312 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 35 ms | 4216 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 37 ms | 4216 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 140 ms | 8260 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 173 ms | 8204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 159 ms | 8184 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 156 ms | 8184 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |