답안 #139590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
139590 2019-08-01T06:42:25 Z mlyean00 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
458 ms 160248 KB
#ifdef DEBUG
#include "debug.hpp"
#else
#pragma GCC optimize("Ofast")
#define trace(...)
#include <bits/stdc++.h>
#define endl '\n'
#endif

using namespace std;
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

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

    vector<vector<ll>> row_o(h + 1, vector<ll>(w + 1));
    for (int i = 0; i < h; ++i) {
        for (int j = w - 1; j >= 0; --j) {
            row_o[i][j] = row_o[i][j + 1] + (grid[i][j] == 'O');
        }
    }
    vector<vector<ll>> col_i(h + 1, vector<ll>(w + 1));
    for (int j = 0; j < w; ++j) {
        for (int i = h - 1; i >= 0; --i) {
            col_i[i][j] = col_i[i + 1][j] + (grid[i][j] == 'I');
        }
    }

    ll ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (grid[i][j] != 'J') continue;
            ans += row_o[i][j] * col_i[i][j];
        }
    }

    cout << ans << endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 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 504 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 500 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 3 ms 632 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 376 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 504 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 500 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 3 ms 632 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 7 ms 3832 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 5 ms 2680 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 9 ms 4856 KB Output is correct
19 Correct 8 ms 4600 KB Output is correct
20 Correct 7 ms 4728 KB Output is correct
21 Correct 9 ms 4856 KB Output is correct
22 Correct 8 ms 4600 KB Output is correct
23 Correct 8 ms 4732 KB Output is correct
24 Correct 9 ms 4856 KB Output is correct
25 Correct 8 ms 4472 KB Output is correct
26 Correct 9 ms 4856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 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 504 KB Output is correct
8 Correct 2 ms 504 KB Output is correct
9 Correct 2 ms 500 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 504 KB Output is correct
12 Correct 3 ms 632 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 7 ms 3832 KB Output is correct
15 Correct 2 ms 504 KB Output is correct
16 Correct 5 ms 2680 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 9 ms 4856 KB Output is correct
19 Correct 8 ms 4600 KB Output is correct
20 Correct 7 ms 4728 KB Output is correct
21 Correct 9 ms 4856 KB Output is correct
22 Correct 8 ms 4600 KB Output is correct
23 Correct 8 ms 4732 KB Output is correct
24 Correct 9 ms 4856 KB Output is correct
25 Correct 8 ms 4472 KB Output is correct
26 Correct 9 ms 4856 KB Output is correct
27 Correct 423 ms 151296 KB Output is correct
28 Correct 4 ms 1016 KB Output is correct
29 Correct 36 ms 11896 KB Output is correct
30 Correct 3 ms 760 KB Output is correct
31 Correct 299 ms 111344 KB Output is correct
32 Correct 421 ms 159076 KB Output is correct
33 Correct 421 ms 159628 KB Output is correct
34 Correct 346 ms 129016 KB Output is correct
35 Correct 452 ms 159176 KB Output is correct
36 Correct 427 ms 159736 KB Output is correct
37 Correct 458 ms 160248 KB Output is correct
38 Correct 270 ms 110328 KB Output is correct
39 Correct 270 ms 110896 KB Output is correct