Submission #697147

# Submission time Handle Problem Language Result Execution time Memory
697147 2023-02-08T16:00:34 Z kusssso Bob (COCI14_bob) C++17
108 / 120
1000 ms 13984 KB
#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 time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 2868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 152 ms 3232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 104 ms 3404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 3448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 784 ms 10892 KB Output is correct
2 Execution timed out 1065 ms 6200 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 755 ms 13984 KB Output is correct
2 Correct 896 ms 6200 KB Output is correct
3 Correct 743 ms 6192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 764 ms 13784 KB Output is correct
2 Correct 734 ms 6196 KB Output is correct
3 Correct 748 ms 6192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 886 ms 13920 KB Output is correct
2 Correct 916 ms 6208 KB Output is correct
3 Correct 739 ms 6184 KB Output is correct