답안 #646850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
646850 2022-09-30T21:43:58 Z tvladm2009 Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
154 ms 70824 KB
#include <bits/stdc++.h>

using ll = long long;

int const nmax = 3000;

int a[1 + nmax][1 + nmax];
int ingots[1 + nmax][1 + nmax];

/*
1 -> jewel
2 -> orb
3 -> ingot
*/

int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);

  int n, m;
  std::cin >> n >> m;
  for(int i = 1;i <= n; i++) {
    std::string s;
    std::cin >> s;
    for(int j = 1;j <= m; j++) {
      if(s[j - 1] == 'J')
        a[i][j] = 1;
      else if(s[j - 1] == 'O')
        a[i][j] = 2;
      else
        a[i][j] = 3;
    }
  }
  for(int i = n;i >= 1; i--) {
    for(int j = 1;j <= m; j++) {
      ingots[i][j] = ingots[i + 1][j];
      if(a[i][j] == 3)
        ingots[i][j]++;
    }
  }
  
  ll ans = 0;
  for(int i = 1;i <= n; i++) {
    int orbs = 0;
    for(int j = m; j >= 1; j--) {
      if(a[i][j] == 1) {
        ans += orbs * ingots[i][j];
      } else if(a[i][j] == 2) {
        orbs++;
      }
    }
  }
  std::cout << ans;
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 5 ms 5844 KB Output is correct
15 Correct 1 ms 3668 KB Output is correct
16 Correct 2 ms 3412 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 6 ms 6228 KB Output is correct
19 Correct 5 ms 6228 KB Output is correct
20 Correct 3 ms 6100 KB Output is correct
21 Correct 6 ms 6228 KB Output is correct
22 Correct 4 ms 6228 KB Output is correct
23 Correct 3 ms 6100 KB Output is correct
24 Correct 6 ms 6228 KB Output is correct
25 Correct 3 ms 6228 KB Output is correct
26 Correct 4 ms 6100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1108 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1108 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 1 ms 1108 KB Output is correct
12 Correct 1 ms 1108 KB Output is correct
13 Correct 1 ms 1108 KB Output is correct
14 Correct 5 ms 5844 KB Output is correct
15 Correct 1 ms 3668 KB Output is correct
16 Correct 2 ms 3412 KB Output is correct
17 Correct 0 ms 340 KB Output is correct
18 Correct 6 ms 6228 KB Output is correct
19 Correct 5 ms 6228 KB Output is correct
20 Correct 3 ms 6100 KB Output is correct
21 Correct 6 ms 6228 KB Output is correct
22 Correct 4 ms 6228 KB Output is correct
23 Correct 3 ms 6100 KB Output is correct
24 Correct 6 ms 6228 KB Output is correct
25 Correct 3 ms 6228 KB Output is correct
26 Correct 4 ms 6100 KB Output is correct
27 Correct 154 ms 70696 KB Output is correct
28 Correct 8 ms 19096 KB Output is correct
29 Correct 5 ms 6356 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 118 ms 59084 KB Output is correct
32 Correct 75 ms 70824 KB Output is correct
33 Correct 58 ms 70552 KB Output is correct
34 Correct 135 ms 68360 KB Output is correct
35 Correct 70 ms 70732 KB Output is correct
36 Correct 56 ms 70508 KB Output is correct
37 Correct 153 ms 70732 KB Output is correct
38 Correct 56 ms 59048 KB Output is correct
39 Correct 41 ms 58752 KB Output is correct