답안 #364465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
364465 2021-02-09T09:05:32 Z tushar_2658 Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
475 ms 150392 KB
#include "bits/stdc++.h"
using namespace std;

const int maxn = 3005;
using ll = long long;

char s[maxn][maxn];
ll pref[maxn][maxn], pref1[maxn][maxn];

int main(int argc, char const *argv[])
{
  ios::sync_with_stdio(false); 
  cin.tie(0);

  int n, m;
  cin >> n >> m;
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= m; ++j){
      cin >> s[i][j];
    }
  }
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= m; ++j){
      pref[i][j] = pref[i][j - 1] + (s[i][j] == 'O');
    }
  }
  for(int i = 1; i <= m; ++i){
    for(int j = 1; j <= n; ++j){
      pref1[j][i] = pref1[j - 1][i] + (s[j][i] == 'I');
    }
  }
  ll ans = 0;
  for(int i = 1; i <= n; ++i){
    for(int j = 1; j <= m; ++j){
      if(s[i][j] == 'J'){
        ll x = (pref[i][m] - pref[i][j]) * (pref1[n][j] - pref1[i][j]);
        ans += x;
      }
    }
  }
  cout << ans << '\n';

  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 2 ms 1664 KB Output is correct
6 Correct 1 ms 1516 KB Output is correct
7 Correct 1 ms 1516 KB Output is correct
8 Correct 1 ms 1644 KB Output is correct
9 Correct 2 ms 1792 KB Output is correct
10 Correct 1 ms 1516 KB Output is correct
11 Correct 2 ms 1644 KB Output is correct
12 Correct 1 ms 1516 KB Output is correct
13 Correct 1 ms 1536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 2 ms 1664 KB Output is correct
6 Correct 1 ms 1516 KB Output is correct
7 Correct 1 ms 1516 KB Output is correct
8 Correct 1 ms 1644 KB Output is correct
9 Correct 2 ms 1792 KB Output is correct
10 Correct 1 ms 1516 KB Output is correct
11 Correct 2 ms 1644 KB Output is correct
12 Correct 1 ms 1516 KB Output is correct
13 Correct 1 ms 1536 KB Output is correct
14 Correct 10 ms 8812 KB Output is correct
15 Correct 3 ms 5100 KB Output is correct
16 Correct 6 ms 5228 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 15 ms 9708 KB Output is correct
19 Correct 11 ms 9580 KB Output is correct
20 Correct 12 ms 9580 KB Output is correct
21 Correct 12 ms 9708 KB Output is correct
22 Correct 11 ms 9580 KB Output is correct
23 Correct 11 ms 9580 KB Output is correct
24 Correct 12 ms 9708 KB Output is correct
25 Correct 12 ms 9580 KB Output is correct
26 Correct 11 ms 9580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 1 ms 492 KB Output is correct
5 Correct 2 ms 1664 KB Output is correct
6 Correct 1 ms 1516 KB Output is correct
7 Correct 1 ms 1516 KB Output is correct
8 Correct 1 ms 1644 KB Output is correct
9 Correct 2 ms 1792 KB Output is correct
10 Correct 1 ms 1516 KB Output is correct
11 Correct 2 ms 1644 KB Output is correct
12 Correct 1 ms 1516 KB Output is correct
13 Correct 1 ms 1536 KB Output is correct
14 Correct 10 ms 8812 KB Output is correct
15 Correct 3 ms 5100 KB Output is correct
16 Correct 6 ms 5228 KB Output is correct
17 Correct 1 ms 492 KB Output is correct
18 Correct 15 ms 9708 KB Output is correct
19 Correct 11 ms 9580 KB Output is correct
20 Correct 12 ms 9580 KB Output is correct
21 Correct 12 ms 9708 KB Output is correct
22 Correct 11 ms 9580 KB Output is correct
23 Correct 11 ms 9580 KB Output is correct
24 Correct 12 ms 9708 KB Output is correct
25 Correct 12 ms 9580 KB Output is correct
26 Correct 11 ms 9580 KB Output is correct
27 Correct 448 ms 150392 KB Output is correct
28 Correct 17 ms 26348 KB Output is correct
29 Correct 21 ms 13292 KB Output is correct
30 Correct 1 ms 896 KB Output is correct
31 Correct 343 ms 125416 KB Output is correct
32 Correct 442 ms 150208 KB Output is correct
33 Correct 441 ms 149868 KB Output is correct
34 Correct 402 ms 145260 KB Output is correct
35 Correct 453 ms 150380 KB Output is correct
36 Correct 444 ms 149868 KB Output is correct
37 Correct 475 ms 150380 KB Output is correct
38 Correct 332 ms 124872 KB Output is correct
39 Correct 316 ms 124928 KB Output is correct