Submission #819173

# Submission time Handle Problem Language Result Execution time Memory
819173 2023-08-10T08:17:53 Z vjudge1 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
252 ms 150988 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define se second
#define fi first
#define pii pair<int,int>
#define pll pair<long long, long long>

ll h,w,power=0;
vector<vector<char>> thingy;
pll os[3001][3001];

void solve(){
    memset(os,0,sizeof(os));
    cin >> h >> w;
    for(int i=0; i<h; i++){
        vector<char> bruh;
        for(int j=0; j<w; j++){
            char temp;
            cin >> temp;
            bruh.push_back(temp);
        }
        thingy.push_back(bruh);
    }
    for(int i=h-1; i>=0; i--){
        for(int j=w-1; j>=0; j--){
            if(thingy[i][j]=='I'){
                if(i==h-1){
                    os[i][j].fi=1;
                    os[i][j].se=0;
                }else{
                    os[i][j].fi=os[i+1][j].fi+1;
                    os[i][j].se=os[i][j+1].se;
                }
            }else if(thingy[i][j]=='O'){
                if(j==w-1){
                    os[i][j].se=1;
                    os[i][j].fi=0;
                }else{
                    os[i][j].se=os[i][j+1].se+1;
                    os[i][j].fi=os[i+1][j].fi;
                }
            }else{
                if(j==w-1){
                    os[i][j].se=0;
                }else{
                    os[i][j].se=os[i][j+1].se;
                }
                if(i==h-1){
                    os[i][j].fi=0;
                }else{
                    os[i][j].fi=os[i+1][j].fi;
                }
            }
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(thingy[i][j]=='J'){
                power+= os[i][j].fi*os[i][j].se;
            }
        }
    }
    cout << power << endl;
    return;
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 54 ms 141280 KB Output is correct
2 Correct 53 ms 141168 KB Output is correct
3 Correct 48 ms 141404 KB Output is correct
4 Correct 50 ms 141200 KB Output is correct
5 Correct 47 ms 141280 KB Output is correct
6 Correct 46 ms 141208 KB Output is correct
7 Correct 46 ms 141312 KB Output is correct
8 Correct 53 ms 141256 KB Output is correct
9 Correct 44 ms 141280 KB Output is correct
10 Correct 49 ms 141288 KB Output is correct
11 Correct 45 ms 141256 KB Output is correct
12 Correct 54 ms 141296 KB Output is correct
13 Correct 45 ms 141264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 141280 KB Output is correct
2 Correct 53 ms 141168 KB Output is correct
3 Correct 48 ms 141404 KB Output is correct
4 Correct 50 ms 141200 KB Output is correct
5 Correct 47 ms 141280 KB Output is correct
6 Correct 46 ms 141208 KB Output is correct
7 Correct 46 ms 141312 KB Output is correct
8 Correct 53 ms 141256 KB Output is correct
9 Correct 44 ms 141280 KB Output is correct
10 Correct 49 ms 141288 KB Output is correct
11 Correct 45 ms 141256 KB Output is correct
12 Correct 54 ms 141296 KB Output is correct
13 Correct 45 ms 141264 KB Output is correct
14 Correct 56 ms 141604 KB Output is correct
15 Correct 45 ms 141332 KB Output is correct
16 Correct 52 ms 141512 KB Output is correct
17 Correct 49 ms 141228 KB Output is correct
18 Correct 60 ms 141692 KB Output is correct
19 Correct 53 ms 141704 KB Output is correct
20 Correct 59 ms 141888 KB Output is correct
21 Correct 54 ms 141772 KB Output is correct
22 Correct 54 ms 141676 KB Output is correct
23 Correct 52 ms 141708 KB Output is correct
24 Correct 59 ms 141804 KB Output is correct
25 Correct 54 ms 141752 KB Output is correct
26 Correct 50 ms 141800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 141280 KB Output is correct
2 Correct 53 ms 141168 KB Output is correct
3 Correct 48 ms 141404 KB Output is correct
4 Correct 50 ms 141200 KB Output is correct
5 Correct 47 ms 141280 KB Output is correct
6 Correct 46 ms 141208 KB Output is correct
7 Correct 46 ms 141312 KB Output is correct
8 Correct 53 ms 141256 KB Output is correct
9 Correct 44 ms 141280 KB Output is correct
10 Correct 49 ms 141288 KB Output is correct
11 Correct 45 ms 141256 KB Output is correct
12 Correct 54 ms 141296 KB Output is correct
13 Correct 45 ms 141264 KB Output is correct
14 Correct 56 ms 141604 KB Output is correct
15 Correct 45 ms 141332 KB Output is correct
16 Correct 52 ms 141512 KB Output is correct
17 Correct 49 ms 141228 KB Output is correct
18 Correct 60 ms 141692 KB Output is correct
19 Correct 53 ms 141704 KB Output is correct
20 Correct 59 ms 141888 KB Output is correct
21 Correct 54 ms 141772 KB Output is correct
22 Correct 54 ms 141676 KB Output is correct
23 Correct 52 ms 141708 KB Output is correct
24 Correct 59 ms 141804 KB Output is correct
25 Correct 54 ms 141752 KB Output is correct
26 Correct 50 ms 141800 KB Output is correct
27 Correct 238 ms 150440 KB Output is correct
28 Correct 49 ms 141436 KB Output is correct
29 Correct 59 ms 142300 KB Output is correct
30 Correct 49 ms 141312 KB Output is correct
31 Correct 170 ms 148212 KB Output is correct
32 Correct 183 ms 150932 KB Output is correct
33 Correct 168 ms 150920 KB Output is correct
34 Correct 184 ms 149172 KB Output is correct
35 Correct 182 ms 150828 KB Output is correct
36 Correct 163 ms 150932 KB Output is correct
37 Correct 252 ms 150988 KB Output is correct
38 Correct 132 ms 148236 KB Output is correct
39 Correct 124 ms 148196 KB Output is correct