Submission #1348670

#TimeUsernameProblemLanguageResultExecution timeMemory
1348670sorb852Bitaro the Brave (JOI19_ho_t1)C++17
20 / 100
5 ms3524 KiB
#include <iostream>
#include <vector>

using namespace std;

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

  // freopen("other/input.txt", "r", stdin);

  int H, W;
  cin >> H >> W;

  vector<pair<int, int>> P;
  vector<vector<int>> l(H, vector<int>(W, 0));
  vector<vector<int>> k(H, vector<int>(W, 0));

  char buf;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> buf;
      l[i][j] = l[i][max(j - 1, 0)];
      k[i][j] = k[max(i - 1, 0)][j];
      switch (buf) {
      case 'J':
        P.emplace_back(i, j);
        break;
      case 'I':
        k[i][j]++;
        break;
      case 'O':
        l[i][j]++;
        break;
      }
    }
  }

  // for (int i = 0; i < H; i++) {
  //   for (int j = 0; j < W; j++) {
  //     cout << l[i][j] << ' ';
  //   }
  //   cout << endl;
  // }
  //
  // cout << "#############\n";
  //
  // for (int i = 0; i < H; i++) {
  //   for (int j = 0; j < W; j++) {
  //     cout << k[i][j] << ' ';
  //   }
  //   cout << endl;
  // }

  int ans = 0;
  for (auto p : P) {
    int L = l[p.first][W - 1] - l[p.first][p.second];
    int K = k[H - 1][p.second] - k[p.first][p.second];
    ans += K * L;
  }

  cout << ans;

  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...