# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1115123 |
2024-11-20T05:04:51 Z |
duytuandao21 |
Bob (COCI14_bob) |
C++17 |
|
940 ms |
55900 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 7;
const int inf = 1e9 + 7;
typedef pair<int, int> pii;
int n, m;
int a[2000][2000], b[2000][2000], c[2000][2000];
int bit[2000][2000];
int get(int j, int x, int y) {
int ans = 0;
int mVal = inf;
for (int i = x; i <= y; i++) {
mVal = min(mVal, b[i][j]);
ans += mVal;
}
return ans + (-j + 1) * (y - x + 1);
}
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) cin >> a[i][j];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
for (int k = j; k <= m + 1; k++) {
if (a[i][k] != a[i][j]) {
b[i][j] = k - 1;
break;
}
}
}
}
for (int j = 1; j <= m; j++) {
for (int i = 1; i <= n; i++) {
for (int k = i; k <= n + 1; k++) {
if (a[k][j] != a[i][j]) {
c[i][j] = k - 1;
break;
}
}
}
}
int res = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
// int minCol = inf;
// for (int k = i; k <= n; k++) {
// if (a[k][j] != a[i][j]) break;
// minCol = min(minCol, b[k][j]);
// res += minCol - j + 1;
// }
res += get(j, i, c[i][j]);
}
}
cout << res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
29008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
29008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
29008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
29008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
104 ms |
53724 KB |
Output is correct |
2 |
Correct |
874 ms |
53580 KB |
Output is correct |
3 |
Correct |
940 ms |
55900 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
53716 KB |
Output is correct |
2 |
Correct |
402 ms |
53756 KB |
Output is correct |
3 |
Correct |
890 ms |
53736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
154 ms |
53576 KB |
Output is correct |
2 |
Correct |
883 ms |
53840 KB |
Output is correct |
3 |
Correct |
940 ms |
55624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
148 ms |
53576 KB |
Output is correct |
2 |
Correct |
863 ms |
53748 KB |
Output is correct |
3 |
Correct |
930 ms |
55764 KB |
Output is correct |