Submission #1026486

# Submission time Handle Problem Language Result Execution time Memory
1026486 2024-07-18T06:49:42 Z overwatch9 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
342 ms 88840 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int n, m;
    cin >> n >> m;
    vector <string> grid(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> grid[i];
        grid[i] = "0" + grid[i];
    }
    map <char, vector <vector <int>>> pfx;
    pfx['O'] = pfx['I'] = vector <vector <int>> (n+1, vector <int> (m+1));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (grid[i][j] != 'J')
                pfx[grid[i][j]][i][j]++;
            pfx['O'][i][j] += pfx['O'][i][j-1];
            pfx['I'][i][j] += pfx['I'][i-1][j];
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (grid[i][j] != 'J')
                continue;
            ll a = pfx['O'][i][m] - pfx['O'][i][j];
            ll b = pfx['I'][n][j] - pfx['I'][i][j];
            ans += a * b;
        }
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 8 ms 2140 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 5 ms 1628 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 12 ms 2876 KB Output is correct
19 Correct 7 ms 2620 KB Output is correct
20 Correct 9 ms 2648 KB Output is correct
21 Correct 11 ms 2908 KB Output is correct
22 Correct 8 ms 2652 KB Output is correct
23 Correct 8 ms 2652 KB Output is correct
24 Correct 11 ms 2908 KB Output is correct
25 Correct 10 ms 2624 KB Output is correct
26 Correct 8 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 436 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 8 ms 2140 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 5 ms 1628 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 12 ms 2876 KB Output is correct
19 Correct 7 ms 2620 KB Output is correct
20 Correct 9 ms 2648 KB Output is correct
21 Correct 11 ms 2908 KB Output is correct
22 Correct 8 ms 2652 KB Output is correct
23 Correct 8 ms 2652 KB Output is correct
24 Correct 11 ms 2908 KB Output is correct
25 Correct 10 ms 2624 KB Output is correct
26 Correct 8 ms 2652 KB Output is correct
27 Correct 325 ms 83824 KB Output is correct
28 Correct 2 ms 856 KB Output is correct
29 Correct 21 ms 6648 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 239 ms 61784 KB Output is correct
32 Correct 262 ms 88420 KB Output is correct
33 Correct 272 ms 88696 KB Output is correct
34 Correct 287 ms 71504 KB Output is correct
35 Correct 253 ms 88300 KB Output is correct
36 Correct 270 ms 88404 KB Output is correct
37 Correct 342 ms 88840 KB Output is correct
38 Correct 185 ms 61260 KB Output is correct
39 Correct 211 ms 61524 KB Output is correct