Submission #743177

# Submission time Handle Problem Language Result Execution time Memory
743177 2023-05-17T08:37:54 Z josanneo22 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
466 ms 159024 KB
#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;

#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second 
#define int long long

void solve() { 
    int n,m; cin >> n >> m;
    vector<vector<int>> ingot(n, vector<int>(m)), orb(n, vector<int>(m));
    vector<vector<char>> grid(n, vector<char>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> grid[i][j];
            if (grid[i][j] == 'I') ingot[i][j]++;
            if (grid[i][j] == 'O') orb[i][j]++;
        }
    }
    for (int j = 0;j < m; j++) {
        for(int i=n-2;i>=0;i--){
            ingot[i][j] += ingot[i+1][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = m - 2; j >= 0; j--) {
            orb[i][j] += orb[i][j + 1];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (grid[i][j] == 'J') {
                ans += ingot[i][j] * orb[i][j];
            }
        }
    }
    cout << ans << '\n';
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 572 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 452 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 572 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 452 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 9 ms 3668 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 5 ms 2516 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 12 ms 4692 KB Output is correct
19 Correct 9 ms 4552 KB Output is correct
20 Correct 11 ms 4692 KB Output is correct
21 Correct 12 ms 4692 KB Output is correct
22 Correct 10 ms 4564 KB Output is correct
23 Correct 9 ms 4692 KB Output is correct
24 Correct 11 ms 4692 KB Output is correct
25 Correct 11 ms 4604 KB Output is correct
26 Correct 13 ms 4564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 572 KB Output is correct
7 Correct 1 ms 456 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 452 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 9 ms 3668 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 5 ms 2516 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 12 ms 4692 KB Output is correct
19 Correct 9 ms 4552 KB Output is correct
20 Correct 11 ms 4692 KB Output is correct
21 Correct 12 ms 4692 KB Output is correct
22 Correct 10 ms 4564 KB Output is correct
23 Correct 9 ms 4692 KB Output is correct
24 Correct 11 ms 4692 KB Output is correct
25 Correct 11 ms 4604 KB Output is correct
26 Correct 13 ms 4564 KB Output is correct
27 Correct 393 ms 150280 KB Output is correct
28 Correct 2 ms 980 KB Output is correct
29 Correct 27 ms 11752 KB Output is correct
30 Correct 2 ms 724 KB Output is correct
31 Correct 324 ms 110656 KB Output is correct
32 Correct 360 ms 158092 KB Output is correct
33 Correct 313 ms 158604 KB Output is correct
34 Correct 356 ms 128256 KB Output is correct
35 Correct 357 ms 158200 KB Output is correct
36 Correct 352 ms 158604 KB Output is correct
37 Correct 466 ms 159024 KB Output is correct
38 Correct 256 ms 109748 KB Output is correct
39 Correct 238 ms 110220 KB Output is correct