제출 #464416

#제출 시각아이디문제언어결과실행 시간메모리
464416MKutayBozkurtBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
361 ms159156 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define int long long

struct item {
  int o, i;
};

int32_t main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n, m; cin >> n >> m;
  vector<vector<char>> a(n + 1, vector<char>(m + 1));
  vector<vector<item>> cnt(n + 1, vector<item>(m + 1));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'O') cnt[i][j].o++;
      if (a[i][j] == 'I') cnt[i][j].i++;
      cnt[i][j].o += cnt[i][j - 1].o;
      cnt[i][j].i += cnt[i - 1][j].i;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == 'J') {
        ans += (cnt[i][m].o - cnt[i][j].o) * (cnt[n][j].i - cnt[i][j].i);
      }
    }
  }
  cout << ans << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...