Submission #601231

# Submission time Handle Problem Language Result Execution time Memory
601231 2022-07-21T13:26:37 Z jjiangly Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
345 ms 160068 KB
#include <bits/stdc++.h>
using namespace std;

#define all(x) x.begin(), x.end()
#define siz(x) int(x.size())
#define ll long long
#define ar array
#define vt vector
#define inf INT_MAX
#define lnf LLONG_MAX

const int nxm = int(3e3) + 7;

int h, w;
vt<string> a(nxm);

namespace sub1 {
  void solve() {
    vt<vt<ll>> c(h, vt<ll> (w, 0));
    vt<vt<ll>> c2(h, vt<ll> (w, 0));
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (a[i][j] == 'I') {
          ++c[i][j];
        } else if (a[i][j] == 'O') {
          ++c2[i][j];
        }
      }
    }
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w - 1; ++j) {
        c2[i][j + 1] += c2[i][j];
      }
    }
    for (int j = 0; j < w; ++j) {
      for (int i = 0; i < h - 1; ++i) {
        c[i + 1][j] += c[i][j];
      }
    }
    ll ans = 0;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (a[i][j] == 'J') {
          ans += (c[h - 1][j] - c[i][j]) * (c2[i][w - 1] - c2[i][j]);
        }
      }
    }
    cout << ans << "\n";
  }
};

int subtask() {
//  if (h <= 100 && w <= 100) {
//    return 1;
//  } else if (h <= 500 && w <= 100) {
//    return 2;
//  }
  return 1;
}

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

  cin >> h >> w;
  for (int i = 0; i < h; ++i) {
    cin >> a[i];
  }
  if (subtask() == 1) {
    sub1::solve();
  }

  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 5 ms 3540 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 2 ms 2516 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 7 ms 4564 KB Output is correct
19 Correct 4 ms 4436 KB Output is correct
20 Correct 4 ms 4436 KB Output is correct
21 Correct 7 ms 4880 KB Output is correct
22 Correct 5 ms 4692 KB Output is correct
23 Correct 4 ms 4764 KB Output is correct
24 Correct 8 ms 4820 KB Output is correct
25 Correct 5 ms 4692 KB Output is correct
26 Correct 6 ms 4780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 0 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 5 ms 3540 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 2 ms 2516 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 7 ms 4564 KB Output is correct
19 Correct 4 ms 4436 KB Output is correct
20 Correct 4 ms 4436 KB Output is correct
21 Correct 7 ms 4880 KB Output is correct
22 Correct 5 ms 4692 KB Output is correct
23 Correct 4 ms 4764 KB Output is correct
24 Correct 8 ms 4820 KB Output is correct
25 Correct 5 ms 4692 KB Output is correct
26 Correct 6 ms 4780 KB Output is correct
27 Correct 345 ms 151160 KB Output is correct
28 Correct 1 ms 980 KB Output is correct
29 Correct 13 ms 11936 KB Output is correct
30 Correct 2 ms 724 KB Output is correct
31 Correct 210 ms 111212 KB Output is correct
32 Correct 217 ms 158972 KB Output is correct
33 Correct 202 ms 159420 KB Output is correct
34 Correct 212 ms 128932 KB Output is correct
35 Correct 229 ms 159076 KB Output is correct
36 Correct 206 ms 159504 KB Output is correct
37 Correct 273 ms 160068 KB Output is correct
38 Correct 136 ms 110348 KB Output is correct
39 Correct 135 ms 110740 KB Output is correct