Submission #970470

#TimeUsernameProblemLanguageResultExecution timeMemory
970470jadai007Bob (COCI14_bob)C++14
72 / 120
508 ms21840 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...