Submission #1084063

# Submission time Handle Problem Language Result Execution time Memory
1084063 2024-09-05T03:08:09 Z May27_th Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
197 ms 159316 KB
#include<bits/stdc++.h>
 
using namespace std;
 
#define i64 long long
#define int long long
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()

void Solve(void) {
  int N, M; cin >> N >> M;
  vector<vector<char>> g(N + 2, vector<char> (M + 2));
  vector<vector<int>> prefI(N + 2, vector<int> (M + 2, 0));
  vector<vector<int>> prefO(N + 2, vector<int> (M + 2, 0));
  for (int i = 1; i <= N; i ++) {
    for (int j = 1; j <= M; j ++) {
      cin >> g[i][j];
      prefO[i][j] = prefO[i][j - 1] + (g[i][j] == 'O');
      prefI[i][j] = prefI[i - 1][j] + (g[i][j] == 'I');
    }
  }
  i64 ans = 0;
  for (int i = 1; i <= N; i ++) {
    for (int j = 1; j <= M; j ++) {
      if (g[i][j] == 'J') {
        ans = ans + 1LL * (prefO[i][M] - prefO[i][j]) * (prefI[N][j] - prefI[i][j]);
      }
    }
  }
  cout << ans << "\n";
}

signed main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int Tests = 1; // cin >> Tests; 
  while (Tests --) {
    Solve();    
  }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 640 KB Output is correct
14 Correct 7 ms 3676 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 5 ms 2636 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 7 ms 4820 KB Output is correct
19 Correct 5 ms 4700 KB Output is correct
20 Correct 5 ms 4700 KB Output is correct
21 Correct 5 ms 4816 KB Output is correct
22 Correct 4 ms 4700 KB Output is correct
23 Correct 4 ms 4860 KB Output is correct
24 Correct 5 ms 4700 KB Output is correct
25 Correct 4 ms 4700 KB Output is correct
26 Correct 5 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 640 KB Output is correct
14 Correct 7 ms 3676 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 5 ms 2636 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 7 ms 4820 KB Output is correct
19 Correct 5 ms 4700 KB Output is correct
20 Correct 5 ms 4700 KB Output is correct
21 Correct 5 ms 4816 KB Output is correct
22 Correct 4 ms 4700 KB Output is correct
23 Correct 4 ms 4860 KB Output is correct
24 Correct 5 ms 4700 KB Output is correct
25 Correct 4 ms 4700 KB Output is correct
26 Correct 5 ms 4696 KB Output is correct
27 Correct 187 ms 150608 KB Output is correct
28 Correct 1 ms 1112 KB Output is correct
29 Correct 13 ms 11884 KB Output is correct
30 Correct 1 ms 860 KB Output is correct
31 Correct 129 ms 110900 KB Output is correct
32 Correct 174 ms 158312 KB Output is correct
33 Correct 168 ms 158804 KB Output is correct
34 Correct 155 ms 128596 KB Output is correct
35 Correct 162 ms 158292 KB Output is correct
36 Correct 167 ms 158800 KB Output is correct
37 Correct 197 ms 159316 KB Output is correct
38 Correct 118 ms 109904 KB Output is correct
39 Correct 114 ms 110416 KB Output is correct