Submission #422452

# Submission time Handle Problem Language Result Execution time Memory
422452 2021-06-10T06:51:44 Z snasibov05 Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
495 ms 161776 KB
#include <iostream>
#include <vector>

using namespace std;

#define int long long

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

    vector<vector<int>> row_o(h, vector<int>(w)), col_i(w, vector<int>(h));

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (grid[i][j] == 'O') row_o[i][j]++;
            if (grid[i][j] == 'I') col_i[j][i]++;
        }
    }

    for (int i = 0; i < h; ++i) {
        for (int j = w-2; j >= 0; --j) {
            row_o[i][j] += row_o[i][j+1];
        }
    }

    for (int j = 0; j < w; ++j) {
        for (int i = h-2; i >= 0; --i){
            col_i[j][i] += col_i[j][i+1];
        }
    }

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

    cout << ans << "\n";


    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 420 KB Output is correct
10 Correct 1 ms 428 KB Output is correct
11 Correct 1 ms 424 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 420 KB Output is correct
10 Correct 1 ms 428 KB Output is correct
11 Correct 1 ms 424 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 10 ms 3772 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 6 ms 2636 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 13 ms 4908 KB Output is correct
19 Correct 11 ms 4556 KB Output is correct
20 Correct 11 ms 4812 KB Output is correct
21 Correct 16 ms 4984 KB Output is correct
22 Correct 11 ms 4552 KB Output is correct
23 Correct 11 ms 4912 KB Output is correct
24 Correct 14 ms 4988 KB Output is correct
25 Correct 13 ms 4556 KB Output is correct
26 Correct 14 ms 4812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 2 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 420 KB Output is correct
10 Correct 1 ms 428 KB Output is correct
11 Correct 1 ms 424 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 10 ms 3772 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 6 ms 2636 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 13 ms 4908 KB Output is correct
19 Correct 11 ms 4556 KB Output is correct
20 Correct 11 ms 4812 KB Output is correct
21 Correct 16 ms 4984 KB Output is correct
22 Correct 11 ms 4552 KB Output is correct
23 Correct 11 ms 4912 KB Output is correct
24 Correct 14 ms 4988 KB Output is correct
25 Correct 13 ms 4556 KB Output is correct
26 Correct 14 ms 4812 KB Output is correct
27 Correct 478 ms 153224 KB Output is correct
28 Correct 2 ms 844 KB Output is correct
29 Correct 28 ms 12016 KB Output is correct
30 Correct 2 ms 716 KB Output is correct
31 Correct 343 ms 114048 KB Output is correct
32 Correct 431 ms 160580 KB Output is correct
33 Correct 412 ms 161084 KB Output is correct
34 Correct 404 ms 132140 KB Output is correct
35 Correct 432 ms 160720 KB Output is correct
36 Correct 393 ms 161136 KB Output is correct
37 Correct 495 ms 161776 KB Output is correct
38 Correct 269 ms 113140 KB Output is correct
39 Correct 273 ms 113500 KB Output is correct