Submission #970470

# Submission time Handle Problem Language Result Execution time Memory
970470 2024-04-26T15:02:06 Z jadai007 Bob (COCI14_bob) C++14
72 / 120
508 ms 21840 KB
#include<bits/stdc++.h>

using namespace std;

int n,m, arr[1001][1001], dp1[1001][1001], dp2[1001][1001], ans;

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    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]) dp1[i][j] = dp1[i][j - 1] + 1;
            else dp1[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]) dp2[i][j] = dp2[i - 1][j] + 1;
            else dp2[i][j] = 1;
        }
    }
    for(int i = 1; i<=n; ++i){
        for(int j = 1; j<=m; ++j){
            int M = dp1[i][j], N = dp2[i][j], k = j - 1;
            ans+=N;
            while(k > j - M){
                N = min(N, dp2[i][k]);
                ans+=N;
                k--;
            }
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 11356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 11608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 11868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 11868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 18772 KB Output is correct
2 Incorrect 479 ms 14164 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 104 ms 21692 KB Output is correct
2 Incorrect 218 ms 14160 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 146 ms 21584 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 114 ms 21840 KB Output is correct
2 Incorrect 508 ms 14156 KB Output isn't correct
3 Halted 0 ms 0 KB -