Submission #527598

# Submission time Handle Problem Language Result Execution time Memory
527598 2022-02-17T18:04:23 Z SlavicG Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
308 ms 159080 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
 
#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()

const int N = 3005;
char c[N][N];
ll a[N][N], b[N][N];
void solve() { 
    int n, m;
    cin >> n >> m;
    for(int i = 0;i < n; ++i) {
        for(int j = 0;j < m; ++j) {
            cin >> c[i][j];
        }
    }

    for(int i = 0;i < n; ++i) {
        for(int j = m - 1; j >= 0; --j) {
            a[i][j] = a[i][j + 1];
            if(c[i][j] == 'O') ++a[i][j];
        }
    }

    for(int i = 0;i < m; ++i) {
        for(int j = n - 1;j >= 0; --j) {
            b[i][j] = b[i][j + 1];
            if(c[j][i] == 'I') ++b[i][j];
        }
    }

    ll ans = 0;

    for(int i = 0;i < n; ++i) {
        for(int j = 0;j < m; ++j) {
            if(c[i][j] != 'J') continue;

            ans += a[i][j + 1] * b[j][i + 1]; 
        }
    } 
    cout << ans << "\n";
} 
 
int32_t main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 1484 KB Output is correct
6 Correct 1 ms 1356 KB Output is correct
7 Correct 1 ms 1484 KB Output is correct
8 Correct 1 ms 1484 KB Output is correct
9 Correct 1 ms 1356 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Correct 1 ms 1484 KB Output is correct
12 Correct 1 ms 1356 KB Output is correct
13 Correct 2 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 1484 KB Output is correct
6 Correct 1 ms 1356 KB Output is correct
7 Correct 1 ms 1484 KB Output is correct
8 Correct 1 ms 1484 KB Output is correct
9 Correct 1 ms 1356 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Correct 1 ms 1484 KB Output is correct
12 Correct 1 ms 1356 KB Output is correct
13 Correct 2 ms 1484 KB Output is correct
14 Correct 10 ms 8268 KB Output is correct
15 Correct 2 ms 3276 KB Output is correct
16 Correct 5 ms 6092 KB Output is correct
17 Correct 1 ms 1612 KB Output is correct
18 Correct 10 ms 9724 KB Output is correct
19 Correct 9 ms 9420 KB Output is correct
20 Correct 9 ms 9548 KB Output is correct
21 Correct 11 ms 9676 KB Output is correct
22 Correct 10 ms 9420 KB Output is correct
23 Correct 9 ms 9548 KB Output is correct
24 Correct 11 ms 9676 KB Output is correct
25 Correct 12 ms 9408 KB Output is correct
26 Correct 9 ms 9548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 1484 KB Output is correct
6 Correct 1 ms 1356 KB Output is correct
7 Correct 1 ms 1484 KB Output is correct
8 Correct 1 ms 1484 KB Output is correct
9 Correct 1 ms 1356 KB Output is correct
10 Correct 1 ms 1484 KB Output is correct
11 Correct 1 ms 1484 KB Output is correct
12 Correct 1 ms 1356 KB Output is correct
13 Correct 2 ms 1484 KB Output is correct
14 Correct 10 ms 8268 KB Output is correct
15 Correct 2 ms 3276 KB Output is correct
16 Correct 5 ms 6092 KB Output is correct
17 Correct 1 ms 1612 KB Output is correct
18 Correct 10 ms 9724 KB Output is correct
19 Correct 9 ms 9420 KB Output is correct
20 Correct 9 ms 9548 KB Output is correct
21 Correct 11 ms 9676 KB Output is correct
22 Correct 10 ms 9420 KB Output is correct
23 Correct 9 ms 9548 KB Output is correct
24 Correct 11 ms 9676 KB Output is correct
25 Correct 12 ms 9408 KB Output is correct
26 Correct 9 ms 9548 KB Output is correct
27 Correct 283 ms 148904 KB Output is correct
28 Correct 10 ms 16972 KB Output is correct
29 Correct 29 ms 22872 KB Output is correct
30 Correct 6 ms 9928 KB Output is correct
31 Correct 218 ms 131272 KB Output is correct
32 Correct 262 ms 158492 KB Output is correct
33 Correct 254 ms 158676 KB Output is correct
34 Correct 251 ms 142988 KB Output is correct
35 Correct 292 ms 158496 KB Output is correct
36 Correct 288 ms 158772 KB Output is correct
37 Correct 308 ms 159080 KB Output is correct
38 Correct 175 ms 130684 KB Output is correct
39 Correct 168 ms 130916 KB Output is correct