답안 #757814

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
757814 2023-06-13T18:55:00 Z JANCARAPAN Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
308 ms 88696 KB
#include <bits/stdc++.h>
using namespace std;  
#define ll long long
#define fi first
#define se second
#define sz(a) (long long) a.size()
//#define endl '\n'

const long long INF = 1e18, MOD = 1e9+7;

void test_case() {
  int n, m;
  cin >> n >> m;
  vector a(n, vector<char>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  vector suff_row(n, vector<int>(m)), suff_col(n, vector<int>(m));
  
  for (int i = 0; i < n; i++) {
    for (int j = m - 1; j >= 0; j--) {
      suff_row[i][j] = (j != m - 1 ? suff_row[i][j + 1] : 0) + (a[i][j] == 'O');
    }
  }
  for (int j = 0; j < m; j++) {
    for (int i = n - 1; i >= 0; i--) {
      suff_col[i][j] = (i != n - 1 ? suff_col[i + 1][j] : 0) + (a[i][j] == 'I');
    }
  }
  
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] != 'J') continue;
      ans += suff_row[i][j] * suff_col[i][j];
    }
  }
  cout << ans << endl;
}
 
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tt = 1;
  //cin >> tt;
  while (tt--) {
    test_case();
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 6 ms 2244 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 3 ms 1612 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 7 ms 2764 KB Output is correct
19 Correct 7 ms 2644 KB Output is correct
20 Correct 6 ms 2772 KB Output is correct
21 Correct 7 ms 2772 KB Output is correct
22 Correct 6 ms 2644 KB Output is correct
23 Correct 6 ms 2772 KB Output is correct
24 Correct 7 ms 2772 KB Output is correct
25 Correct 6 ms 2644 KB Output is correct
26 Correct 6 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 316 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 6 ms 2244 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 3 ms 1612 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 7 ms 2764 KB Output is correct
19 Correct 7 ms 2644 KB Output is correct
20 Correct 6 ms 2772 KB Output is correct
21 Correct 7 ms 2772 KB Output is correct
22 Correct 6 ms 2644 KB Output is correct
23 Correct 6 ms 2772 KB Output is correct
24 Correct 7 ms 2772 KB Output is correct
25 Correct 6 ms 2644 KB Output is correct
26 Correct 6 ms 2764 KB Output is correct
27 Correct 303 ms 83780 KB Output is correct
28 Correct 2 ms 852 KB Output is correct
29 Correct 13 ms 6612 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 189 ms 61744 KB Output is correct
32 Correct 284 ms 88116 KB Output is correct
33 Correct 270 ms 88404 KB Output is correct
34 Correct 250 ms 71480 KB Output is correct
35 Correct 278 ms 88136 KB Output is correct
36 Correct 299 ms 88404 KB Output is correct
37 Correct 308 ms 88696 KB Output is correct
38 Correct 184 ms 61260 KB Output is correct
39 Correct 191 ms 61376 KB Output is correct