Submission #720965

# Submission time Handle Problem Language Result Execution time Memory
720965 2023-04-10T00:09:12 Z Pring Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
326 ms 184084 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
typedef pair<int, int> pii;

const int MXN = 5005;
int n, m, O[MXN][MXN], I[MXN][MXN], ans;
string s[MXN];
char c[MXN][MXN];

void GO() {
    for (int i = 0; i < n; i++) {
        for (int j = m - 2; j >= 0; j--) {
            O[i][j] = O[i][j + 1];
            if (s[i][j + 1] == 'O') O[i][j]++;
        }
    }
}

void GI() {
    for (int j = 0; j < m; j++) {
        for (int i = n - 2; i >= 0; i--) {
            I[i][j] = I[i + 1][j];
            if (s[i + 1][j] == 'I') I[i][j]++;
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> s[i];
    GO();
    GI();
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j] != 'J') continue;
            ans += O[i][j] * I[i][j];
        }
    }
    cout << ans << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 496 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1396 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 1 ms 1388 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 2 ms 1364 KB Output is correct
12 Correct 1 ms 1388 KB Output is correct
13 Correct 1 ms 1268 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 496 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1396 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 1 ms 1388 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 2 ms 1364 KB Output is correct
12 Correct 1 ms 1388 KB Output is correct
13 Correct 1 ms 1268 KB Output is correct
14 Correct 7 ms 7844 KB Output is correct
15 Correct 2 ms 3924 KB Output is correct
16 Correct 4 ms 4820 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 9 ms 8956 KB Output is correct
19 Correct 6 ms 8680 KB Output is correct
20 Correct 6 ms 8788 KB Output is correct
21 Correct 9 ms 8916 KB Output is correct
22 Correct 8 ms 8680 KB Output is correct
23 Correct 8 ms 8676 KB Output is correct
24 Correct 7 ms 8916 KB Output is correct
25 Correct 6 ms 8780 KB Output is correct
26 Correct 6 ms 8700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 500 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 496 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1396 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 2 ms 1364 KB Output is correct
9 Correct 1 ms 1388 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 2 ms 1364 KB Output is correct
12 Correct 1 ms 1388 KB Output is correct
13 Correct 1 ms 1268 KB Output is correct
14 Correct 7 ms 7844 KB Output is correct
15 Correct 2 ms 3924 KB Output is correct
16 Correct 4 ms 4820 KB Output is correct
17 Correct 1 ms 596 KB Output is correct
18 Correct 9 ms 8956 KB Output is correct
19 Correct 6 ms 8680 KB Output is correct
20 Correct 6 ms 8788 KB Output is correct
21 Correct 9 ms 8916 KB Output is correct
22 Correct 8 ms 8680 KB Output is correct
23 Correct 8 ms 8676 KB Output is correct
24 Correct 7 ms 8916 KB Output is correct
25 Correct 6 ms 8780 KB Output is correct
26 Correct 6 ms 8700 KB Output is correct
27 Correct 317 ms 175024 KB Output is correct
28 Correct 10 ms 19660 KB Output is correct
29 Correct 11 ms 13900 KB Output is correct
30 Correct 1 ms 852 KB Output is correct
31 Correct 208 ms 131176 KB Output is correct
32 Correct 276 ms 182784 KB Output is correct
33 Correct 269 ms 183464 KB Output is correct
34 Correct 264 ms 152152 KB Output is correct
35 Correct 273 ms 182820 KB Output is correct
36 Correct 263 ms 183272 KB Output is correct
37 Correct 326 ms 184084 KB Output is correct
38 Correct 180 ms 130320 KB Output is correct
39 Correct 193 ms 130580 KB Output is correct