Submission #947219

# Submission time Handle Problem Language Result Execution time Memory
947219 2024-03-15T17:11:09 Z devkudawla Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
355 ms 89496 KB
#include <bits/stdc++.h>
using namespace std;
void solve(bool testCases = true) {
    int T = 1;
    if (testCases) cin >> T;
    while (T--) {
        int n, m;
        cin >> n >> m;
        vector<string> v(n);
        for (int i = 0; i < n; i++) {
            cin >> v[i];
        }
        int r[n][m] = {0};
        memset(r, 0, sizeof(r));
        for (int i = 0; i < n; i++) {
            for (int j = m - 2; j >= 0; j--) {
                r[i][j] += r[i][j + 1];
                if (v[i][j + 1] == 'O') {
                    r[i][j]++;
                }
            }
        }
        int c[n][m] = {0};
        memset(c, 0, sizeof(c));
        for (int j = 0; j < m; j++) {
            for (int i = n - 2; i >= 0; i--) {
                c[i][j] += c[i + 1][j];
                if (v[i + 1][j] == 'I') {
                    c[i][j]++;
                }
            }
        }
        long long int answer = 0;
        for (int j = 0; j < m; j++) {
            for (int i = 0; i < n; i++) {
                if (v[i][j] == 'J') {
                    answer += (r[i][j] * 1LL * c[i][j]);
                }
            }
        }
        cout << answer;
        cout << "\n";
    }
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve(false);
    return 0;
}
# 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 0 ms 348 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 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 0 ms 348 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 4 ms 2140 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 1612 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 5 ms 2908 KB Output is correct
19 Correct 3 ms 2652 KB Output is correct
20 Correct 3 ms 2652 KB Output is correct
21 Correct 5 ms 2908 KB Output is correct
22 Correct 4 ms 2648 KB Output is correct
23 Correct 3 ms 2652 KB Output is correct
24 Correct 5 ms 2888 KB Output is correct
25 Correct 3 ms 2652 KB Output is correct
26 Correct 4 ms 2648 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 0 ms 348 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 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 4 ms 2140 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 1612 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 5 ms 2908 KB Output is correct
19 Correct 3 ms 2652 KB Output is correct
20 Correct 3 ms 2652 KB Output is correct
21 Correct 5 ms 2908 KB Output is correct
22 Correct 4 ms 2648 KB Output is correct
23 Correct 3 ms 2652 KB Output is correct
24 Correct 5 ms 2888 KB Output is correct
25 Correct 3 ms 2652 KB Output is correct
26 Correct 4 ms 2648 KB Output is correct
27 Correct 281 ms 84440 KB Output is correct
28 Correct 1 ms 604 KB Output is correct
29 Correct 8 ms 6748 KB Output is correct
30 Correct 1 ms 604 KB Output is correct
31 Correct 197 ms 62188 KB Output is correct
32 Correct 204 ms 88656 KB Output is correct
33 Correct 273 ms 89252 KB Output is correct
34 Correct 229 ms 71852 KB Output is correct
35 Correct 287 ms 88868 KB Output is correct
36 Correct 276 ms 89172 KB Output is correct
37 Correct 355 ms 89496 KB Output is correct
38 Correct 145 ms 61612 KB Output is correct
39 Correct 166 ms 61848 KB Output is correct