답안 #170582

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170582 2019-12-25T17:26:47 Z WLZ Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
282 ms 89764 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  vector< vector<int> > cnt_o(h, vector<int>(w, 0)), cnt_i(h, vector<int>(w, 0)); 
  for (int i = 0; i < h; i++) {
    cin >> grid[i];
  }
  for (int i = h - 1; i >= 0; i--) {
    for (int j = w - 1; j >= 0; j--) {
      if (grid[i][j] == 'O') {
        cnt_o[i][j] = 1;
      }
      if (grid[i][j] == 'I') {
        cnt_i[i][j] = 1;
      }
      if (j < w - 1) {
        cnt_o[i][j] += cnt_o[i][j + 1];
      }
      if (i < h - 1) {
        cnt_i[i][j] += cnt_i[i + 1][j];
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (grid[i][j] == 'J') {
        ans += (long long) cnt_o[i][j] * (long long) cnt_i[i][j];
      }
    }
  }
  cout << ans << '\n';
  return 0; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 408 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 408 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 8 ms 2296 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 5 ms 1656 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 10 ms 2808 KB Output is correct
19 Correct 7 ms 2808 KB Output is correct
20 Correct 8 ms 2808 KB Output is correct
21 Correct 11 ms 2808 KB Output is correct
22 Correct 7 ms 2812 KB Output is correct
23 Correct 7 ms 2808 KB Output is correct
24 Correct 10 ms 2808 KB Output is correct
25 Correct 7 ms 2808 KB Output is correct
26 Correct 7 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 408 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 8 ms 2296 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 5 ms 1656 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 10 ms 2808 KB Output is correct
19 Correct 7 ms 2808 KB Output is correct
20 Correct 8 ms 2808 KB Output is correct
21 Correct 11 ms 2808 KB Output is correct
22 Correct 7 ms 2812 KB Output is correct
23 Correct 7 ms 2808 KB Output is correct
24 Correct 10 ms 2808 KB Output is correct
25 Correct 7 ms 2808 KB Output is correct
26 Correct 7 ms 2808 KB Output is correct
27 Correct 268 ms 84600 KB Output is correct
28 Correct 3 ms 888 KB Output is correct
29 Correct 16 ms 6776 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 215 ms 62272 KB Output is correct
32 Correct 191 ms 88956 KB Output is correct
33 Correct 179 ms 89480 KB Output is correct
34 Correct 229 ms 72164 KB Output is correct
35 Correct 182 ms 89180 KB Output is correct
36 Correct 180 ms 89416 KB Output is correct
37 Correct 282 ms 89764 KB Output is correct
38 Correct 130 ms 61816 KB Output is correct
39 Correct 125 ms 62200 KB Output is correct