답안 #436538

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
436538 2021-06-24T15:14:13 Z dariasc Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
541 ms 88320 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    char grid[h][w];
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < w; j++) {
            grid[i][j] = s[j];
        }
    }

    int orbs[h][w];
    for (int i = 0; i < h; i++) {
        orbs[i][w-1] = grid[i][w-1] == 'O';
        for (int j = w-2; j >= 0; j--) {
            orbs[i][j] = orbs[i][j+1] + (grid[i][j] == 'O');
        }
    }
    int ingots[h][w];
    for (int j = 0; j < w; j++) {
        ingots[h-1][j] = grid[h-1][j] == 'I';
        for (int i = h-2; i >= 0; i--) {
            ingots[i][j] = ingots[i+1][j] + (grid[i][j] == 'I');
        }
    }

    long long ans = 0;
    for (int i = 0; i < h-1; i++) {
        for (int j = 0; j < w-1; j++) {
            if (grid[i][j] != 'J') {
                continue;
            }
            ans += ingots[i+1][j] * orbs[i][j+1];
        }
    }
    cout << ans << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 8 ms 2124 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 5 ms 1460 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 10 ms 2716 KB Output is correct
19 Correct 9 ms 2548 KB Output is correct
20 Correct 9 ms 2636 KB Output is correct
21 Correct 10 ms 2636 KB Output is correct
22 Correct 9 ms 2544 KB Output is correct
23 Correct 9 ms 2636 KB Output is correct
24 Correct 11 ms 2772 KB Output is correct
25 Correct 9 ms 2636 KB Output is correct
26 Correct 9 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 8 ms 2124 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 5 ms 1460 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 10 ms 2716 KB Output is correct
19 Correct 9 ms 2548 KB Output is correct
20 Correct 9 ms 2636 KB Output is correct
21 Correct 10 ms 2636 KB Output is correct
22 Correct 9 ms 2544 KB Output is correct
23 Correct 9 ms 2636 KB Output is correct
24 Correct 11 ms 2772 KB Output is correct
25 Correct 9 ms 2636 KB Output is correct
26 Correct 9 ms 2636 KB Output is correct
27 Correct 413 ms 83436 KB Output is correct
28 Correct 3 ms 460 KB Output is correct
29 Correct 23 ms 6632 KB Output is correct
30 Correct 2 ms 460 KB Output is correct
31 Correct 346 ms 61420 KB Output is correct
32 Correct 539 ms 87724 KB Output is correct
33 Correct 541 ms 88012 KB Output is correct
34 Correct 403 ms 71152 KB Output is correct
35 Correct 445 ms 87736 KB Output is correct
36 Correct 516 ms 88012 KB Output is correct
37 Correct 522 ms 88320 KB Output is correct
38 Correct 345 ms 60852 KB Output is correct
39 Correct 357 ms 61176 KB Output is correct