Submission #697147

#TimeUsernameProblemLanguageResultExecution timeMemory
697147kussssoBob (COCI14_bob)C++17
108 / 120
1065 ms13984 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 1005; int n, m; int a[N][N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) cin >> a[i][j]; } ll ans = 0; for (int x = 1; x <= n; x++) { vector<int> d(m + 1, 1); for (int y = x; y <= n; y++) { if (y > x) { for (int j = 1; j <= m; j++) { d[j] &= (a[y][j] == a[y - 1][j]); } } for (int j = 1; j <= m; j++) { if (!d[j]) continue; int t = j; while (t <= m && d[t] && a[y][t] == a[y][j]) t++; ans += 1LL * (t - j) * (t - j + 1) / 2; j = t - 1; } } } 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...