Submission #1023561

# Submission time Handle Problem Language Result Execution time Memory
1023561 2024-07-15T02:28:48 Z vjudge1 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
224 ms 212204 KB
#include <bits/stdc++.h>
#define file(name)  if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define REV(i, b, a) for(int i = (b); i >= (a); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define ll long long
#define fi first 
#define se second
#define int long long
using namespace std;
const int N = 3005;
int n, m;
int a[N][N];
int d1[N][N], d2[N][N];
void solve(int tc) {
    cin >> n >> m;
    char ch;
    FOR(i, 1, n) FOR(j, 1, m) {
        cin >> ch;
        a[i][j] = ch == 'J' ? 0 : ch == 'O' ? 1 : 2;
    }
    int ans = 0;
    REV(i, n, 1) {
        REV(j, m, 1) {
            d1[i][j] = d1[i][j + 1] + (a[i][j] == 1);
            d2[i][j] = d2[i + 1][j] + (a[i][j] == 2);
            if(a[i][j] == 0) ans += d1[i][j] * d2[i][j];    
        }
    }
    cout << ans << '\n';
}
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int tc = 1; 
    // cin >> tc;
    for(int i = 1; i <= tc; ++i) solve(tc);
    return (0);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 7004 KB Output is correct
7 Correct 1 ms 7004 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 7004 KB Output is correct
10 Correct 2 ms 7004 KB Output is correct
11 Correct 1 ms 8796 KB Output is correct
12 Correct 1 ms 7004 KB Output is correct
13 Correct 1 ms 7004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 7004 KB Output is correct
7 Correct 1 ms 7004 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 7004 KB Output is correct
10 Correct 2 ms 7004 KB Output is correct
11 Correct 1 ms 8796 KB Output is correct
12 Correct 1 ms 7004 KB Output is correct
13 Correct 1 ms 7004 KB Output is correct
14 Correct 7 ms 29020 KB Output is correct
15 Correct 2 ms 22876 KB Output is correct
16 Correct 3 ms 16988 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 8 ms 29572 KB Output is correct
19 Correct 6 ms 29272 KB Output is correct
20 Correct 6 ms 30812 KB Output is correct
21 Correct 8 ms 28120 KB Output is correct
22 Correct 6 ms 25176 KB Output is correct
23 Correct 6 ms 25324 KB Output is correct
24 Correct 8 ms 25436 KB Output is correct
25 Correct 6 ms 26716 KB Output is correct
26 Correct 6 ms 27880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 8796 KB Output is correct
6 Correct 1 ms 7004 KB Output is correct
7 Correct 1 ms 7004 KB Output is correct
8 Correct 1 ms 8796 KB Output is correct
9 Correct 1 ms 7004 KB Output is correct
10 Correct 2 ms 7004 KB Output is correct
11 Correct 1 ms 8796 KB Output is correct
12 Correct 1 ms 7004 KB Output is correct
13 Correct 1 ms 7004 KB Output is correct
14 Correct 7 ms 29020 KB Output is correct
15 Correct 2 ms 22876 KB Output is correct
16 Correct 3 ms 16988 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 8 ms 29572 KB Output is correct
19 Correct 6 ms 29272 KB Output is correct
20 Correct 6 ms 30812 KB Output is correct
21 Correct 8 ms 28120 KB Output is correct
22 Correct 6 ms 25176 KB Output is correct
23 Correct 6 ms 25324 KB Output is correct
24 Correct 8 ms 25436 KB Output is correct
25 Correct 6 ms 26716 KB Output is correct
26 Correct 6 ms 27880 KB Output is correct
27 Correct 196 ms 212052 KB Output is correct
28 Correct 11 ms 49756 KB Output is correct
29 Correct 8 ms 21596 KB Output is correct
30 Correct 1 ms 2908 KB Output is correct
31 Correct 149 ms 178516 KB Output is correct
32 Correct 150 ms 212048 KB Output is correct
33 Correct 138 ms 211792 KB Output is correct
34 Correct 175 ms 206532 KB Output is correct
35 Correct 149 ms 212052 KB Output is correct
36 Correct 139 ms 211624 KB Output is correct
37 Correct 224 ms 212204 KB Output is correct
38 Correct 112 ms 177748 KB Output is correct
39 Correct 110 ms 177744 KB Output is correct