Submission #492733

# Submission time Handle Problem Language Result Execution time Memory
492733 2021-12-08T15:37:11 Z niloyroot Bitaro the Brave (JOI19_ho_t1) C++14
50 / 100
342 ms 274436 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pl = pair<ll,ll>;
#define pb push_back
#define form(m,it) for(auto it=m.begin(); it!=m.end(); it++)
#define forp(i,a,b) for(ll i=a; i<=b; i++)
#define forn(i,a,b) for(ll i=a; i>=b; i--)
#define newl '\n'
#define ff first
#define ss second
const ll mod = 1000000007;

void solve(){
    ll h,w; cin>>h>>w;
    ll a[h+1][w+1];
    char c; map<char,ll> m; m['J']=0; m['O']=1; m['I']=2;
    forp(i,1,h){
        forp(j,1,w){
            cin>>c;
            a[i][j]=m[c];
        }
    }
    ll cr[3][h+1][w+1];
    ll cc[3][h+1][w+1];
    memset(cr,0,sizeof(cr));
    memset(cc,0,sizeof(cc));
    forp(i,1,h){
        forp(j,1,w){
            forp(k,0,2){
                cr[k][i][j]=cr[k][i][j-1]+(a[i][j]==k);
            }
        }
    }
    forp(i,1,h){
        forp(j,1,w){
            forp(k,0,2){
                cc[k][i][j]=cc[k][i-1][j]+(a[i][j]==k);
            }
        }
    }

    ll ans=0;
    forp(i,1,h){
        forp(j,1,w){
            if(a[i][j]==0){
                ans+=(cr[1][i][w]-cr[1][i][j-1])*(cc[2][h][j]-cc[2][i-1][j]);
            }
        }
    }

    cout<<ans<<newl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1; //cin>>t;
    while(t--)solve();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 2 ms 844 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 844 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 844 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 2 ms 844 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 844 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 844 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 13 ms 10952 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 7 ms 7524 KB Output is correct
17 Correct 1 ms 440 KB Output is correct
18 Correct 17 ms 14240 KB Output is correct
19 Correct 13 ms 13632 KB Output is correct
20 Correct 12 ms 13996 KB Output is correct
21 Correct 17 ms 14256 KB Output is correct
22 Correct 16 ms 13636 KB Output is correct
23 Correct 14 ms 13960 KB Output is correct
24 Correct 17 ms 14284 KB Output is correct
25 Correct 14 ms 13740 KB Output is correct
26 Correct 18 ms 13900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 2 ms 844 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 716 KB Output is correct
8 Correct 1 ms 844 KB Output is correct
9 Correct 1 ms 716 KB Output is correct
10 Correct 1 ms 716 KB Output is correct
11 Correct 1 ms 844 KB Output is correct
12 Correct 1 ms 716 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 13 ms 10952 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 7 ms 7524 KB Output is correct
17 Correct 1 ms 440 KB Output is correct
18 Correct 17 ms 14240 KB Output is correct
19 Correct 13 ms 13632 KB Output is correct
20 Correct 12 ms 13996 KB Output is correct
21 Correct 17 ms 14256 KB Output is correct
22 Correct 16 ms 13636 KB Output is correct
23 Correct 14 ms 13960 KB Output is correct
24 Correct 17 ms 14284 KB Output is correct
25 Correct 14 ms 13740 KB Output is correct
26 Correct 18 ms 13900 KB Output is correct
27 Runtime error 342 ms 274436 KB Execution killed with signal 9
28 Halted 0 ms 0 KB -