Submission #886276

#TimeUsernameProblemLanguageResultExecution timeMemory
886276stefanneaguBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
332 ms18104 KiB
#include <bits/stdc++.h>
using namespace std;
const int nmax = 3e3 + 1;
char mat[nmax][nmax];
int O[nmax], I[nmax];
int main() {
  int n, m;
  cin >> n >> m;
  for(int i = 1; i <= n; i ++) {
    for(int j = 1; j <= m; j ++) {
      cin >> mat[i][j];
    }
  }
  long long ans = 0;
  for(int  i = n; i>=1; i--) {
    for(int j=m; j>=1; j--) {
      if(mat[i][j] == 'J') {
        ans += (long long) I[j] * O[i];
        // cout << i << " " << j << ": " << O[i] << " " << I[j] << endl;
      }
      if(mat[i][j] == 'O') {
          O[i] ++;
        }
        if(mat[i][j] == 'I') {
          I[j] ++;
      }
    }
  }
  cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...