Submission #967564

# Submission time Handle Problem Language Result Execution time Memory
967564 2024-04-22T12:44:24 Z njoop Bob (COCI14_bob) C++14
0 / 120
161 ms 22084 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int n, m, arr[1010][1010], pref[2][1010][1010], w, h, mxh;
ll ans;

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> m;
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            cin >> arr[i][j];
        }
    }
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            if(arr[i][j] == arr[i][j-1]) {
                pref[0][i][j] = pref[0][i][j-1] + 1;
            } else {
                pref[0][i][j] = 1;
            }
        }
    }
    for(int j=1; j<=m; j++) {
        for(int i=1; i<=n; i++) {
            if(arr[i][j] == arr[i-1][j]) {
                pref[1][i][j] = pref[1][i-1][j] + 1;
            } else {
                pref[1][i][j] = 1;
            }
        }
    }
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=m; j++) {
            w = pref[0][i][j];
            h = pref[1][i][j];
            ans += h;
            for(int k=j-1; k>j-w; k--) {
                h = max(h, pref[1][i][k]);
                ans += h;
            }
        }
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 11356 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 11864 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 11868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 11844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 19000 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 97 ms 22072 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 161 ms 21844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 22084 KB Output isn't correct
2 Halted 0 ms 0 KB -