Submission #915328

# Submission time Handle Problem Language Result Execution time Memory
915328 2024-01-23T17:10:40 Z ace5 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
223 ms 115352 KB
#include <bits/stdc++.h>

using namespace std;

vector<vector<int>> a;
vector<vector<int>> r;
vector<vector<int>> b;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h,w;
    cin >> h >> w;
    a.resize(h);
    for(int i =0;i < h;++i)
    {
        a[i].resize(w);
        for(int j = 0;j < w;++j)
        {
            char x;
            cin >> x;
            a[i][j] = (x == 'J' ? 0 : (x == 'O' ? 1 : 2));
        }
    }
    r.resize(h);
    for(int i = 0;i < h;++i)
    {
        r[i].resize(w);
        for(int j = w-1;j >= 0;--j)
        {
            r[i][j] = (j == w-1 ? 0 : r[i][j+1] + (a[i][j+1] == 1));
        }
    }
    b.resize(h);
    for(int i = h-1;i >= 0;--i)
    {
        b[i].resize(w);
        for(int j = 0;j < w;++j)
        {
            b[i][j] = (i == h-1 ? 0 : b[i+1][j] + (a[i+1][j] == 2));
        }
    }
    int64_t ans = 0;
    for(int i = 0;i < h;++i)
    {
        for(int j = 0;j < w;++j)
        {
            ans += (a[i][j] == 0)*(r[i][j]*b[i][j]);
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 712 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 476 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 556 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 712 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 476 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 556 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 6 ms 2848 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 4 ms 1884 KB Output is correct
17 Correct 1 ms 452 KB Output is correct
18 Correct 7 ms 3552 KB Output is correct
19 Correct 6 ms 3420 KB Output is correct
20 Correct 5 ms 3420 KB Output is correct
21 Correct 7 ms 3672 KB Output is correct
22 Correct 6 ms 3420 KB Output is correct
23 Correct 6 ms 3416 KB Output is correct
24 Correct 9 ms 3692 KB Output is correct
25 Correct 5 ms 3420 KB Output is correct
26 Correct 7 ms 3628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 712 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 476 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 556 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 6 ms 2848 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 4 ms 1884 KB Output is correct
17 Correct 1 ms 452 KB Output is correct
18 Correct 7 ms 3552 KB Output is correct
19 Correct 6 ms 3420 KB Output is correct
20 Correct 5 ms 3420 KB Output is correct
21 Correct 7 ms 3672 KB Output is correct
22 Correct 6 ms 3420 KB Output is correct
23 Correct 6 ms 3416 KB Output is correct
24 Correct 9 ms 3692 KB Output is correct
25 Correct 5 ms 3420 KB Output is correct
26 Correct 7 ms 3628 KB Output is correct
27 Correct 196 ms 108596 KB Output is correct
28 Correct 2 ms 856 KB Output is correct
29 Correct 13 ms 8652 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 148 ms 80212 KB Output is correct
32 Correct 173 ms 114300 KB Output is correct
33 Correct 164 ms 114772 KB Output is correct
34 Correct 170 ms 92872 KB Output is correct
35 Correct 183 ms 114260 KB Output is correct
36 Correct 169 ms 114776 KB Output is correct
37 Correct 223 ms 115352 KB Output is correct
38 Correct 122 ms 79476 KB Output is correct
39 Correct 118 ms 79696 KB Output is correct