Submission #971114

# Submission time Handle Problem Language Result Execution time Memory
971114 2024-04-28T01:37:15 Z Roumak77 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
94 ms 160140 KB
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <limits>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
using namespace std;

using ll = long long;

void solve(){
    ll h, w;
    cin >> h >> w;

    vector<string> grid(h);

    for(ll i = 0; i < h; i++){
        cin >> grid[i];
    }

    ll total = 0;

    vector<vector<pair<ll, ll>>> grid_val(h + 1, vector<pair<ll, ll>>(w + 1, pair<ll,ll>{0, 0})); // Orbs, Ignots
    for(ll i = h - 1; i >= 0; i--){
        for(ll j = w - 1; j >= 0; j--){
            grid_val[i][j].first = grid_val[i][j + 1].first;
            grid_val[i][j].second = grid_val[i + 1][j].second;

            if(grid[i][j] == 'O'){
                grid_val[i][j].first += 1;
            }else if(grid[i][j] == 'I'){
                grid_val[i][j].second += 1;
            }else{
                total += grid_val[i][j].first * grid_val[i][j].second;
            }
        }
    }


    cout << total << endl;

}


int main(){

    ios_base::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);

    ll t = 1;

    while(t--){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 2 ms 3796 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 3 ms 4832 KB Output is correct
19 Correct 3 ms 4560 KB Output is correct
20 Correct 3 ms 4696 KB Output is correct
21 Correct 3 ms 4696 KB Output is correct
22 Correct 3 ms 4700 KB Output is correct
23 Correct 3 ms 4692 KB Output is correct
24 Correct 3 ms 4952 KB Output is correct
25 Correct 3 ms 4700 KB Output is correct
26 Correct 3 ms 4848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 0 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 2 ms 3796 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 3 ms 4832 KB Output is correct
19 Correct 3 ms 4560 KB Output is correct
20 Correct 3 ms 4696 KB Output is correct
21 Correct 3 ms 4696 KB Output is correct
22 Correct 3 ms 4700 KB Output is correct
23 Correct 3 ms 4692 KB Output is correct
24 Correct 3 ms 4952 KB Output is correct
25 Correct 3 ms 4700 KB Output is correct
26 Correct 3 ms 4848 KB Output is correct
27 Correct 81 ms 151056 KB Output is correct
28 Correct 1 ms 856 KB Output is correct
29 Correct 6 ms 11868 KB Output is correct
30 Correct 1 ms 860 KB Output is correct
31 Correct 58 ms 111332 KB Output is correct
32 Correct 94 ms 159060 KB Output is correct
33 Correct 84 ms 159668 KB Output is correct
34 Correct 72 ms 129308 KB Output is correct
35 Correct 83 ms 159104 KB Output is correct
36 Correct 89 ms 159672 KB Output is correct
37 Correct 87 ms 160140 KB Output is correct
38 Correct 57 ms 110620 KB Output is correct
39 Correct 63 ms 110732 KB Output is correct