# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
263890 |
2020-08-14T03:07:22 Z |
shrek12357 |
Bob (COCI14_bob) |
C++14 |
|
868 ms |
25828 KB |
#include <iostream>
#include <vector>
#include <climits>
#include <cmath>
#include <algorithm>
#include <stack>
using namespace std;
int main(){
int n, m;
cin >> n >> m;
int grid[n][m];
int preL[n][m], preU[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
int temp;
cin >> temp;
grid[i][j] = temp;
preL[i][j] = 1;
preU[i][j] = 1;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (i > 0) {
if (grid[i][j] == grid[i - 1][j]) {
preU[i][j] = preU[i - 1][j] + 1;
}
}
if (j > 0) {
if (grid[i][j] == grid[i][j - 1]) {
preL[i][j] = preL[i][j - 1] + 1;
}
}
}
}
int dp[n][m];
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (i == 0 && j == 0) {
dp[i][j] = 1;
}
else if (i == 0) {
dp[i][j] = preL[i][j];
}
else if (j == 0) {
dp[i][j] = preU[i][j];
}
else {
if (grid[i - 1][j - 1] != grid[i][j]) {
dp[i][j] = preL[i][j] + preU[i][j] - 1;
}
else {
dp[i][j] = min(preL[i][j], preL[i - 1][j - 1] + 1) * min(preU[i][j], preU[i - 1][j - 1] + 1);
}
}
ans += dp[i][j];
}
}
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
79 ms |
4880 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
111 ms |
5116 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
122 ms |
5368 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
125 ms |
5520 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
653 ms |
22648 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
868 ms |
25720 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
840 ms |
25464 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
857 ms |
25828 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |