Submission #492736

# Submission time Handle Problem Language Result Execution time Memory
492736 2021-12-08T16:04:34 Z niloyroot Bitaro the Brave (JOI19_ho_t1) C++14
50 / 100
304 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;
ll cr[3][3005][3005];
ll cc[3][3005][3005];
ll a[3005][3005];
 
void solve(){
    ll h,w; cin>>h>>w;
  	char c;
    forp(i,1,h){
        forp(j,1,w){
            cin>>c;
            if(c=='J'){
              a[i][j]=0;
            }
          	if(c=='O'){
              a[i][j]=1;
            }
          	if(c=='I'){
              a[i][j]=2;
            }
        }
    }
    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 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 3 ms 3660 KB Output is correct
6 Correct 2 ms 3532 KB Output is correct
7 Correct 2 ms 3276 KB Output is correct
8 Correct 3 ms 3660 KB Output is correct
9 Correct 2 ms 3532 KB Output is correct
10 Correct 2 ms 3276 KB Output is correct
11 Correct 2 ms 3660 KB Output is correct
12 Correct 2 ms 3532 KB Output is correct
13 Correct 2 ms 3276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 3 ms 3660 KB Output is correct
6 Correct 2 ms 3532 KB Output is correct
7 Correct 2 ms 3276 KB Output is correct
8 Correct 3 ms 3660 KB Output is correct
9 Correct 2 ms 3532 KB Output is correct
10 Correct 2 ms 3276 KB Output is correct
11 Correct 2 ms 3660 KB Output is correct
12 Correct 2 ms 3532 KB Output is correct
13 Correct 2 ms 3276 KB Output is correct
14 Correct 17 ms 24920 KB Output is correct
15 Correct 6 ms 12492 KB Output is correct
16 Correct 8 ms 14668 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 20 ms 28108 KB Output is correct
19 Correct 19 ms 27560 KB Output is correct
20 Correct 16 ms 27496 KB Output is correct
21 Correct 19 ms 28108 KB Output is correct
22 Correct 17 ms 27552 KB Output is correct
23 Correct 17 ms 27472 KB Output is correct
24 Correct 20 ms 28096 KB Output is correct
25 Correct 17 ms 27568 KB Output is correct
26 Correct 16 ms 27528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 588 KB Output is correct
5 Correct 3 ms 3660 KB Output is correct
6 Correct 2 ms 3532 KB Output is correct
7 Correct 2 ms 3276 KB Output is correct
8 Correct 3 ms 3660 KB Output is correct
9 Correct 2 ms 3532 KB Output is correct
10 Correct 2 ms 3276 KB Output is correct
11 Correct 2 ms 3660 KB Output is correct
12 Correct 2 ms 3532 KB Output is correct
13 Correct 2 ms 3276 KB Output is correct
14 Correct 17 ms 24920 KB Output is correct
15 Correct 6 ms 12492 KB Output is correct
16 Correct 8 ms 14668 KB Output is correct
17 Correct 1 ms 716 KB Output is correct
18 Correct 20 ms 28108 KB Output is correct
19 Correct 19 ms 27560 KB Output is correct
20 Correct 16 ms 27496 KB Output is correct
21 Correct 19 ms 28108 KB Output is correct
22 Correct 17 ms 27552 KB Output is correct
23 Correct 17 ms 27472 KB Output is correct
24 Correct 20 ms 28096 KB Output is correct
25 Correct 17 ms 27568 KB Output is correct
26 Correct 16 ms 27528 KB Output is correct
27 Runtime error 304 ms 274436 KB Execution killed with signal 9
28 Halted 0 ms 0 KB -