Submission #915326

# Submission time Handle Problem Language Result Execution time Memory
915326 2024-01-23T17:05:20 Z ace5 Bitaro the Brave (JOI19_ho_t1) C++17
50 / 100
277 ms 274432 KB
#include <bits/stdc++.h>

using namespace std;

#define int int64_t

vector<vector<int>> a;
vector<vector<int>> r[3];
vector<vector<int>> b[3];

signed 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));
        }
    }
    for(int x = 0;x < 3;++x)
    {
        r[x].resize(h);
        for(int i = 0;i < h;++i)
        {
            r[x][i].resize(w);
            for(int j = w-1;j >= 0;--j)
            {
                r[x][i][j] = (j == w-1 ? 0 : r[x][i][j+1] + (a[i][j+1] == x));
            }
        }
    }
    for(int x = 0;x < 3;++x)
    {
        b[x].resize(h);
        for(int i = h-1;i >= 0;--i)
        {
            b[x][i].resize(w);
            for(int j = 0;j < w;++j)
            {
                b[x][i][j] = (i == h-1 ? 0 : b[x][i+1][j] + (a[i+1][j] == x));
            }
        }
    }
    int ans = 0;
    for(int i = 0;i < h;++i)
    {
        for(int j = 0;j < w;++j)
        {
            int f = (a[i][j]+1)%3;
            int s = (a[i][j]+2)%3;
            ans += (a[i][j] == 0)*(r[f][i][j]*b[s][i][j]);
        }
    }
    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 856 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 1 ms 960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 856 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 1 ms 960 KB Output is correct
14 Correct 13 ms 11100 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 9 ms 7768 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 18 ms 14312 KB Output is correct
19 Correct 17 ms 13820 KB Output is correct
20 Correct 15 ms 14172 KB Output is correct
21 Correct 17 ms 14332 KB Output is correct
22 Correct 16 ms 13916 KB Output is correct
23 Correct 15 ms 14172 KB Output is correct
24 Correct 20 ms 14544 KB Output is correct
25 Correct 15 ms 13916 KB Output is correct
26 Correct 16 ms 14172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 860 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 1 ms 860 KB Output is correct
8 Correct 1 ms 860 KB Output is correct
9 Correct 1 ms 856 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 856 KB Output is correct
13 Correct 1 ms 960 KB Output is correct
14 Correct 13 ms 11100 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 9 ms 7768 KB Output is correct
17 Correct 1 ms 604 KB Output is correct
18 Correct 18 ms 14312 KB Output is correct
19 Correct 17 ms 13820 KB Output is correct
20 Correct 15 ms 14172 KB Output is correct
21 Correct 17 ms 14332 KB Output is correct
22 Correct 16 ms 13916 KB Output is correct
23 Correct 15 ms 14172 KB Output is correct
24 Correct 20 ms 14544 KB Output is correct
25 Correct 15 ms 13916 KB Output is correct
26 Correct 16 ms 14172 KB Output is correct
27 Runtime error 277 ms 274432 KB Execution killed with signal 9
28 Halted 0 ms 0 KB -