Submission #1050731

# Submission time Handle Problem Language Result Execution time Memory
1050731 2024-08-09T13:39:09 Z fryingduc Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
222 ms 115028 KB
#include "bits/stdc++.h"
using namespace std;

const int maxn = 3005;
int n, m;
int a[maxn][maxn];
int cr[maxn][maxn], cc[maxn][maxn];

int convert(char x) {
    if(x == 'J') return 0;
    if(x == 'O') return 1;
    return 2;
}
void solve() {
    cin >> n >> m;
    char ch;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            cin >> ch;
            a[i][j] = convert(ch);
        }
    }
    vector<int> cnt;
    for(int i = 1; i <= n; ++i) {
        for(int j = m; j; --j) {
            cr[i][j] = cr[i][j + 1] + (a[i][j] == 1);            
        }
    }
    for(int j = 1; j <= m; ++j) {
        for(int i = n; i; --i) {
            cc[i][j] = cc[i + 1][j] + (a[i][j] == 2);
        }
    }
    long long ans = 0;
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= m; ++j) {
            if(a[i][j] == 0) {
                ans += 1ll * cc[i][j] * cr[i][j];
            }
        }
    }
    cout << ans;
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2516 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 3164 KB Output is correct
6 Correct 1 ms 3164 KB Output is correct
7 Correct 1 ms 3164 KB Output is correct
8 Correct 1 ms 3164 KB Output is correct
9 Correct 1 ms 3164 KB Output is correct
10 Correct 1 ms 3164 KB Output is correct
11 Correct 1 ms 3164 KB Output is correct
12 Correct 1 ms 3176 KB Output is correct
13 Correct 1 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2516 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 3164 KB Output is correct
6 Correct 1 ms 3164 KB Output is correct
7 Correct 1 ms 3164 KB Output is correct
8 Correct 1 ms 3164 KB Output is correct
9 Correct 1 ms 3164 KB Output is correct
10 Correct 1 ms 3164 KB Output is correct
11 Correct 1 ms 3164 KB Output is correct
12 Correct 1 ms 3176 KB Output is correct
13 Correct 1 ms 3164 KB Output is correct
14 Correct 5 ms 16476 KB Output is correct
15 Correct 2 ms 12636 KB Output is correct
16 Correct 3 ms 8796 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 6 ms 16868 KB Output is correct
19 Correct 5 ms 16732 KB Output is correct
20 Correct 5 ms 16732 KB Output is correct
21 Correct 7 ms 16728 KB Output is correct
22 Correct 5 ms 16732 KB Output is correct
23 Correct 5 ms 16732 KB Output is correct
24 Correct 7 ms 16704 KB Output is correct
25 Correct 6 ms 16732 KB Output is correct
26 Correct 5 ms 16732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2516 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 3164 KB Output is correct
6 Correct 1 ms 3164 KB Output is correct
7 Correct 1 ms 3164 KB Output is correct
8 Correct 1 ms 3164 KB Output is correct
9 Correct 1 ms 3164 KB Output is correct
10 Correct 1 ms 3164 KB Output is correct
11 Correct 1 ms 3164 KB Output is correct
12 Correct 1 ms 3176 KB Output is correct
13 Correct 1 ms 3164 KB Output is correct
14 Correct 5 ms 16476 KB Output is correct
15 Correct 2 ms 12636 KB Output is correct
16 Correct 3 ms 8796 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 6 ms 16868 KB Output is correct
19 Correct 5 ms 16732 KB Output is correct
20 Correct 5 ms 16732 KB Output is correct
21 Correct 7 ms 16728 KB Output is correct
22 Correct 5 ms 16732 KB Output is correct
23 Correct 5 ms 16732 KB Output is correct
24 Correct 7 ms 16704 KB Output is correct
25 Correct 6 ms 16732 KB Output is correct
26 Correct 5 ms 16732 KB Output is correct
27 Correct 193 ms 114640 KB Output is correct
28 Correct 10 ms 42328 KB Output is correct
29 Correct 8 ms 11100 KB Output is correct
30 Correct 1 ms 2652 KB Output is correct
31 Correct 147 ms 95564 KB Output is correct
32 Correct 161 ms 115024 KB Output is correct
33 Correct 205 ms 114760 KB Output is correct
34 Correct 165 ms 110416 KB Output is correct
35 Correct 163 ms 114932 KB Output is correct
36 Correct 150 ms 114768 KB Output is correct
37 Correct 222 ms 115028 KB Output is correct
38 Correct 110 ms 95592 KB Output is correct
39 Correct 109 ms 95060 KB Output is correct