Submission #418248

# Submission time Handle Problem Language Result Execution time Memory
418248 2021-06-05T08:43:04 Z jasmin Bitaro the Brave (JOI19_ho_t1) C++14
100 / 100
303 ms 151748 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int h, w;
    cin >> h >> w;
    vector<string> stones(h);
    for(int i=0; i<h; i++){
        cin >> stones[i];
    }

    vector<vector<int> > orbs(h, vector<int> (w, 0));
    vector<vector<int> > ingos(h, vector<int> (w, 0));
    for(int i=0; i<h; i++){
        if(stones[i][w-1]=='O'){
            orbs[i][w-1]=1;
        }
        for(int j=w-2; j>=0; j--){
            orbs[i][j]=orbs[i][j+1]+(stones[i][j]=='O'? 1: 0);
        }
    }
    for(int j=0; j<w; j++){
        if(stones[h-1][j]=='I'){
            ingos[h-1][j]=1;
        }
        for(int i=h-2; i>=0; i--){
            ingos[i][j]=ingos[i+1][j]+(stones[i][j]=='I'? 1: 0);
        }
    }

    int ans=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(stones[i][j]=='J'){
                ans+=orbs[i][j]*ingos[i][j];
            }
        }
    }

    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 448 KB Output is correct
12 Correct 1 ms 444 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 448 KB Output is correct
12 Correct 1 ms 444 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 5 ms 3660 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 3 ms 2632 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 6 ms 4788 KB Output is correct
19 Correct 5 ms 4556 KB Output is correct
20 Correct 5 ms 4676 KB Output is correct
21 Correct 6 ms 4684 KB Output is correct
22 Correct 5 ms 4556 KB Output is correct
23 Correct 5 ms 4684 KB Output is correct
24 Correct 6 ms 4684 KB Output is correct
25 Correct 5 ms 4516 KB Output is correct
26 Correct 5 ms 4684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 448 KB Output is correct
12 Correct 1 ms 444 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 5 ms 3660 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 3 ms 2632 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 6 ms 4788 KB Output is correct
19 Correct 5 ms 4556 KB Output is correct
20 Correct 5 ms 4676 KB Output is correct
21 Correct 6 ms 4684 KB Output is correct
22 Correct 5 ms 4556 KB Output is correct
23 Correct 5 ms 4684 KB Output is correct
24 Correct 6 ms 4684 KB Output is correct
25 Correct 5 ms 4516 KB Output is correct
26 Correct 5 ms 4684 KB Output is correct
27 Correct 284 ms 143292 KB Output is correct
28 Correct 1 ms 844 KB Output is correct
29 Correct 13 ms 11684 KB Output is correct
30 Correct 1 ms 716 KB Output is correct
31 Correct 189 ms 105600 KB Output is correct
32 Correct 268 ms 150740 KB Output is correct
33 Correct 266 ms 151272 KB Output is correct
34 Correct 230 ms 122324 KB Output is correct
35 Correct 264 ms 150788 KB Output is correct
36 Correct 259 ms 151244 KB Output is correct
37 Correct 303 ms 151748 KB Output is correct
38 Correct 171 ms 104724 KB Output is correct
39 Correct 169 ms 105156 KB Output is correct