Submission #617757

# Submission time Handle Problem Language Result Execution time Memory
617757 2022-08-01T13:42:15 Z bebra Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
82 ms 54288 KB
#include <bits/stdc++.h>
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int h, w;
    cin >> h >> w;
    vector<string> t(h);
    for (auto& s : t) {
        cin >> s;
    }
    vector<vector<int>> pref_vert(h, vector<int>(w));
    long long ans = 0;
    for (int i = h - 1; i >= 0; --i) {
        vector<int> pref_hor(w);
        pref_hor[w - 1] = t[i].back() == 'O';
        for (int j = w - 2; j >= 0; --j) {
            if (t[i][j] == 'J') {
                ans += (long long)pref_hor[j + 1] * (i + 1 < h ? pref_vert[i + 1][j] : 0);
            }
            pref_hor[j] = pref_hor[j + 1] + (t[i][j] == 'O');
            pref_vert[i][j] = t[i][j] == 'I';
            if (i + 1 < h) {
                pref_vert[i][j] += pref_vert[i + 1][j];
            }
        }
    }
    cout << ans << '\n';
    
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 328 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 328 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 1492 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 1088 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 3 ms 1748 KB Output is correct
19 Correct 2 ms 1732 KB Output is correct
20 Correct 2 ms 1744 KB Output is correct
21 Correct 3 ms 1748 KB Output is correct
22 Correct 2 ms 1760 KB Output is correct
23 Correct 2 ms 1708 KB Output is correct
24 Correct 3 ms 1748 KB Output is correct
25 Correct 2 ms 1704 KB Output is correct
26 Correct 2 ms 1748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 328 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 324 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 1492 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 1088 KB Output is correct
17 Correct 1 ms 320 KB Output is correct
18 Correct 3 ms 1748 KB Output is correct
19 Correct 2 ms 1732 KB Output is correct
20 Correct 2 ms 1744 KB Output is correct
21 Correct 3 ms 1748 KB Output is correct
22 Correct 2 ms 1760 KB Output is correct
23 Correct 2 ms 1708 KB Output is correct
24 Correct 3 ms 1748 KB Output is correct
25 Correct 2 ms 1704 KB Output is correct
26 Correct 2 ms 1748 KB Output is correct
27 Correct 73 ms 51232 KB Output is correct
28 Correct 1 ms 596 KB Output is correct
29 Correct 6 ms 4180 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 53 ms 37728 KB Output is correct
32 Correct 55 ms 53844 KB Output is correct
33 Correct 57 ms 53992 KB Output is correct
34 Correct 63 ms 43600 KB Output is correct
35 Correct 61 ms 53892 KB Output is correct
36 Correct 55 ms 54036 KB Output is correct
37 Correct 82 ms 54288 KB Output is correct
38 Correct 41 ms 37412 KB Output is correct
39 Correct 38 ms 37504 KB Output is correct