Submission #897218

#TimeUsernameProblemLanguageResultExecution timeMemory
897218duckindogBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
120 ms80116 KiB
// from duckindog wth depression
#include<bits/stdc++.h>

using namespace std;

const int N = 3e3 + 10;
int h, w;
char a[N][N];
int fi[N][N], fo[N][N];

int32_t main() {
  cin.tie(0)->sync_with_stdio(0);

  if (fopen("duck.inp", "r")) {
    freopen("duck.inp", "r", stdin);
    freopen("duck.out", "w", stdout);
  }
  cin >> h >> w;
  for (int i = 1; i <= h; ++i) {
    string s; cin >> s;
    for (int j = 1; j <= w; ++j) a[i][j] = s[j - 1];
  }
  for (int j = 1; j <= w; ++j)
    for (int i = 1; i <= h; ++i) fi[i][j] = fi[i - 1][j] + (a[i][j] == 'I');

  for (int i = 1; i <= h; ++i)
    for (int j = 1; j <= w; ++j) fo[i][j] = fo[i][j - 1] + (a[i][j] == 'O');

  long long answer = 0;
  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      if (a[i][j] != 'J') continue;
      int O = fo[i][w] - fo[i][j - 1];
      int I = fi[h][j] - fi[i - 1][j];
      answer = answer + 1ll * O * I;
    }
  }
  cout << answer;

}

Compilation message (stderr)

joi2019_ho_t1.cpp: In function 'int32_t main()':
joi2019_ho_t1.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen("duck.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen("duck.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...