Submission #548247

# Submission time Handle Problem Language Result Execution time Memory
548247 2022-04-12T19:14:06 Z beaconmc Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
192 ms 158936 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
using namespace std;
using namespace __gnu_pbds;

#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

ll prefx[3001][3001], prefy[3001][3001];
char grid[3001][3001];

int main(){
    fast();
    ll h,w;
    cin >> h >> w;

    FOR(i,0,h){
        string temp;
        cin >> temp;
        FOR(j,0,w){
            grid[i][j] = temp[j];
        }
    }
    FOR(i,0,h){
        FOR(j,0,w){
            if (j==0){
                if (grid[i][j]=='O') prefx[i][j] = 1;
            }else{
                prefx[i][j] = prefx[i][j-1] + (grid[i][j] == 'O');
            }
        }
    }

    FOR(i,0,h){
        FOR(j,0,w){
            if (i==0){
                if (grid[i][j] == 'I') prefy[i][j] = 1;
            }else{
                prefy[i][j] = prefy[i-1][j] + (grid[i][j]=='I');
            }
        }
    }
    ll ans = 0;
    FOR(i,0,h){
        FOR(j,0,w){
            if (grid[i][j] == 'J'){
                ans += (prefx[i][w-1] - prefx[i][j])*(prefy[h-1][j] - prefy[i][j]);
            }
        }
    }
    cout << ans;

}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 6 ms 8828 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 3 ms 5204 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 7 ms 9684 KB Output is correct
19 Correct 6 ms 9556 KB Output is correct
20 Correct 7 ms 9564 KB Output is correct
21 Correct 8 ms 9684 KB Output is correct
22 Correct 8 ms 9556 KB Output is correct
23 Correct 6 ms 9536 KB Output is correct
24 Correct 6 ms 9684 KB Output is correct
25 Correct 6 ms 9556 KB Output is correct
26 Correct 6 ms 9556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 1492 KB Output is correct
6 Correct 1 ms 1492 KB Output is correct
7 Correct 1 ms 1364 KB Output is correct
8 Correct 1 ms 1492 KB Output is correct
9 Correct 1 ms 1492 KB Output is correct
10 Correct 1 ms 1364 KB Output is correct
11 Correct 1 ms 1492 KB Output is correct
12 Correct 1 ms 1492 KB Output is correct
13 Correct 1 ms 1364 KB Output is correct
14 Correct 6 ms 8828 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 3 ms 5204 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 7 ms 9684 KB Output is correct
19 Correct 6 ms 9556 KB Output is correct
20 Correct 7 ms 9564 KB Output is correct
21 Correct 8 ms 9684 KB Output is correct
22 Correct 8 ms 9556 KB Output is correct
23 Correct 6 ms 9536 KB Output is correct
24 Correct 6 ms 9684 KB Output is correct
25 Correct 6 ms 9556 KB Output is correct
26 Correct 6 ms 9556 KB Output is correct
27 Correct 128 ms 150108 KB Output is correct
28 Correct 16 ms 26292 KB Output is correct
29 Correct 11 ms 13896 KB Output is correct
30 Correct 1 ms 732 KB Output is correct
31 Correct 109 ms 131280 KB Output is correct
32 Correct 114 ms 158800 KB Output is correct
33 Correct 120 ms 158328 KB Output is correct
34 Correct 120 ms 152132 KB Output is correct
35 Correct 113 ms 158832 KB Output is correct
36 Correct 112 ms 158304 KB Output is correct
37 Correct 192 ms 158936 KB Output is correct
38 Correct 103 ms 130740 KB Output is correct
39 Correct 100 ms 130744 KB Output is correct