Submission #230162

# Submission time Handle Problem Language Result Execution time Memory
230162 2020-05-08T19:03:55 Z Haunted_Cpp Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
314 ms 80248 KB
#include <iostream>

using namespace std;

const int N = 3e3 + 5;

int dp_orb [N][N];
int dp_ingot [N][N];

char g [N][N];

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int r, c;
  cin >> r >> c;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> g[i][j];
    }
  }
  for (int i = 0; i < r; i++) {
    for (int j = c - 1; j >= 0; j--) {
      dp_orb[i][j] = (g[i][j] == 'O');
      if (j < c - 1) dp_orb[i][j] += dp_orb[i][j + 1];
    }
  }
  for (int i = 0; i < c; i++) {
    for (int j = r - 1; j >= 0; j--) {
      dp_ingot[i][j] = (g[j][i] == 'I');
      if (j < r - 1) dp_ingot[i][j] += dp_ingot[i][j + 1];
    }
  }
  long long res = 0;
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      if (g[i][j] != 'J') continue;
      int tot_orb = (j + 1 < c ? dp_orb[i][j + 1] : 0);
      int tot_ingot = (i + 1 < r ? dp_ingot[j][i + 1] : 0);
      res += tot_orb * tot_ingot;
    }
  }
  cout << res << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 1536 KB Output is correct
6 Correct 5 ms 1408 KB Output is correct
7 Correct 5 ms 1408 KB Output is correct
8 Correct 5 ms 1536 KB Output is correct
9 Correct 5 ms 1408 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 5 ms 1536 KB Output is correct
12 Correct 6 ms 1408 KB Output is correct
13 Correct 6 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 1536 KB Output is correct
6 Correct 5 ms 1408 KB Output is correct
7 Correct 5 ms 1408 KB Output is correct
8 Correct 5 ms 1536 KB Output is correct
9 Correct 5 ms 1408 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 5 ms 1536 KB Output is correct
12 Correct 6 ms 1408 KB Output is correct
13 Correct 6 ms 1536 KB Output is correct
14 Correct 12 ms 7040 KB Output is correct
15 Correct 6 ms 3328 KB Output is correct
16 Correct 11 ms 5372 KB Output is correct
17 Correct 5 ms 1536 KB Output is correct
18 Correct 14 ms 8064 KB Output is correct
19 Correct 15 ms 7808 KB Output is correct
20 Correct 15 ms 7936 KB Output is correct
21 Correct 14 ms 8064 KB Output is correct
22 Correct 13 ms 7936 KB Output is correct
23 Correct 14 ms 7936 KB Output is correct
24 Correct 16 ms 8064 KB Output is correct
25 Correct 13 ms 7936 KB Output is correct
26 Correct 13 ms 7936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 6 ms 1536 KB Output is correct
6 Correct 5 ms 1408 KB Output is correct
7 Correct 5 ms 1408 KB Output is correct
8 Correct 5 ms 1536 KB Output is correct
9 Correct 5 ms 1408 KB Output is correct
10 Correct 6 ms 1408 KB Output is correct
11 Correct 5 ms 1536 KB Output is correct
12 Correct 6 ms 1408 KB Output is correct
13 Correct 6 ms 1536 KB Output is correct
14 Correct 12 ms 7040 KB Output is correct
15 Correct 6 ms 3328 KB Output is correct
16 Correct 11 ms 5372 KB Output is correct
17 Correct 5 ms 1536 KB Output is correct
18 Correct 14 ms 8064 KB Output is correct
19 Correct 15 ms 7808 KB Output is correct
20 Correct 15 ms 7936 KB Output is correct
21 Correct 14 ms 8064 KB Output is correct
22 Correct 13 ms 7936 KB Output is correct
23 Correct 14 ms 7936 KB Output is correct
24 Correct 16 ms 8064 KB Output is correct
25 Correct 13 ms 7936 KB Output is correct
26 Correct 13 ms 7936 KB Output is correct
27 Correct 294 ms 78328 KB Output is correct
28 Correct 16 ms 16768 KB Output is correct
29 Correct 27 ms 17152 KB Output is correct
30 Correct 9 ms 9856 KB Output is correct
31 Correct 217 ms 66936 KB Output is correct
32 Correct 277 ms 80120 KB Output is correct
33 Correct 310 ms 80120 KB Output is correct
34 Correct 252 ms 72824 KB Output is correct
35 Correct 291 ms 79992 KB Output is correct
36 Correct 286 ms 80248 KB Output is correct
37 Correct 314 ms 80248 KB Output is correct
38 Correct 190 ms 66680 KB Output is correct
39 Correct 198 ms 66808 KB Output is correct