Submission #967566

#TimeUsernameProblemLanguageResultExecution timeMemory
967566njoopBob (COCI14_bob)C++14
120 / 120
551 ms14416 KiB
#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 = min(h, pref[1][i][k]); ans += h; } } } cout << ans; return 0; }
#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...