Submission #867179

# Submission time Handle Problem Language Result Execution time Memory
867179 2023-10-27T20:06:51 Z dpsaveslives Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
147 ms 115536 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 3010;
int grid[MAXN][MAXN];
int ing[MAXN][MAXN],orb[MAXN][MAXN];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int H,W; cin >> H >> W; //count for every J how many O's are in the row after it and how many I's are in the column after it
    for(int i = 0;i<H;++i){
        string s; cin >> s;
        for(int j = 0;j<W;++j){
            grid[i][j] = s[j];
        }
    }
    for(int i = 0;i<H;++i){
        int cnt = 0;
        for(int j = W-1;j>=0;--j){
            if(grid[i][j] == 'J'){
                orb[i][j] = cnt;
            }
            else if(grid[i][j] == 'O'){
                cnt++;
            }
        }
    }
    for(int i = 0;i<W;++i){
        int cnt = 0;
        for(int j = H-1;j>=0;--j){
            if(grid[j][i] == 'J'){
                ing[j][i] = cnt;
            }
            else if(grid[j][i] == 'I'){
                cnt++;
            }
        }
    }
    ll ans = 0;
    for(int i = 0;i<H;++i){
        for(int j = 0;j<W;++j){
            if(grid[i][j] == 'J'){
                //cout << ing[i][j] << " " << orb[i][j] << "\n";
                ans += ing[i][j]*orb[i][j];
            }
        }
    }
    cout << ans << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 1 ms 8540 KB Output is correct
12 Correct 1 ms 8540 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 1 ms 8540 KB Output is correct
12 Correct 1 ms 8540 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 5 ms 23132 KB Output is correct
15 Correct 2 ms 18780 KB Output is correct
16 Correct 2 ms 12636 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 6 ms 23132 KB Output is correct
19 Correct 3 ms 22876 KB Output is correct
20 Correct 3 ms 22876 KB Output is correct
21 Correct 6 ms 23388 KB Output is correct
22 Correct 4 ms 23352 KB Output is correct
23 Correct 4 ms 23640 KB Output is correct
24 Correct 6 ms 23260 KB Output is correct
25 Correct 4 ms 23128 KB Output is correct
26 Correct 4 ms 23132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 8540 KB Output is correct
6 Correct 1 ms 8540 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 8540 KB Output is correct
9 Correct 2 ms 8540 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 1 ms 8540 KB Output is correct
12 Correct 1 ms 8540 KB Output is correct
13 Correct 1 ms 6492 KB Output is correct
14 Correct 5 ms 23132 KB Output is correct
15 Correct 2 ms 18780 KB Output is correct
16 Correct 2 ms 12636 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 6 ms 23132 KB Output is correct
19 Correct 3 ms 22876 KB Output is correct
20 Correct 3 ms 22876 KB Output is correct
21 Correct 6 ms 23388 KB Output is correct
22 Correct 4 ms 23352 KB Output is correct
23 Correct 4 ms 23640 KB Output is correct
24 Correct 6 ms 23260 KB Output is correct
25 Correct 4 ms 23128 KB Output is correct
26 Correct 4 ms 23132 KB Output is correct
27 Correct 127 ms 114808 KB Output is correct
28 Correct 9 ms 82524 KB Output is correct
29 Correct 4 ms 13276 KB Output is correct
30 Correct 1 ms 4700 KB Output is correct
31 Correct 107 ms 99104 KB Output is correct
32 Correct 68 ms 115336 KB Output is correct
33 Correct 67 ms 115280 KB Output is correct
34 Correct 109 ms 112468 KB Output is correct
35 Correct 76 ms 115316 KB Output is correct
36 Correct 65 ms 115224 KB Output is correct
37 Correct 147 ms 115536 KB Output is correct
38 Correct 51 ms 98672 KB Output is correct
39 Correct 53 ms 99412 KB Output is correct