Submission #201490

# Submission time Handle Problem Language Result Execution time Memory
201490 2020-02-10T18:21:00 Z EmmanuelAC Bob (COCI14_bob) C++14
0 / 120
170 ms 33656 KB
#include<bits/stdc++.h>
using namespace std;

#define ll long long

ll dp[1001][1001],
   ps[1001][1001],
   ol[1001][1001]; 

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);

  int n, m; cin >> n >> m;

  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      cin >> ol[i][j];

      if(j > 0){
        dp[i][j] = 1ll + 
                    ((ol[i][j -1] == ol[i][j]) ? dp[i][j -1] : 0ll);
      }
      else{
        dp[i][j] = 1ll;
      }
    }
  }

  /*
  cout << "\n";
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++)  cout << dp[i][j] <<  " ";
    cout << "\n";
  }
  */

  ll sol = 0ll;

  for(int j=0; j<m; j++)  ps[0][j] = dp[0][j],
                          sol += dp[0][j];

  for(int i=1; i<n; i++){
    for(int j=0; j<m; j++){
      ps[i][j] = dp[i][j];

      if(ol[i][j] == ol[i-1][j]){
        ps[i][j] += ps[i-1][j];

        if(dp[i -1][j] > dp[i][j])
          ps[i][j] -= ps[i -1][j -dp[i][j]]; 
      }

      sol += ps[i][j];
    }
  }

  cout << sol << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1016 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1016 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 12664 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 13048 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 13304 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 13304 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 135 ms 30456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 170 ms 33656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 162 ms 33436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 160 ms 33528 KB Output isn't correct
2 Halted 0 ms 0 KB -