Submission #716293

# Submission time Handle Problem Language Result Execution time Memory
716293 2023-03-29T14:43:17 Z Urvuk3 Bitaro the Brave (JOI19_ho_t1) C++17
100 / 100
350 ms 150572 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
#define fi first
#define se second
#define pii pair<int,int>
#define mid ((l+r)/2)
#define sz(a) (int((a).size()))
#define all(a) a.begin(),a.end()
#define endl "\n"
#define pb push_back

void PRINT(int x) {cerr << x;}
void PRINT(ll x) {cerr << x;}
void PRINT(double x) {cerr << x;}
void PRINT(char x) {cerr << '\'' << x << '\'';}
void PRINT(string x) {cerr << '\"' << x << '\"';}
void PRINT(bool x) {cerr << (x ? "true" : "false");}

template<typename T,typename V>
void PRINT(pair<T,V>& x){
    cerr<<"{";
    PRINT(x.fi);
    cerr<<",";
    PRINT(x.se);
    cerr<<"}";
}
template<typename T>
void PRINT(T &x){
    int id=0;
    cerr<<"{";
    for(auto _i:x){
        cerr<<(id++ ? "," : "");
        PRINT(_i);
    }
    cerr<<"}";
}
void _PRINT(){
    cerr<<"]\n";
}
template<typename Head,typename... Tail>
void _PRINT(Head h,Tail... t){
    PRINT(h);
    if(sizeof...(t)) cerr<<", ";
    _PRINT(t...);
}

#define Debug(x...) cerr<<"["<<#x<<"]=["; _PRINT(x)

void Solve(){
    int N,M; cin>>N>>M;
    vector<vector<char>> a(N+1,vector<char>(M+1));
    for(int i=1;i<=N;i++){
        for(int j=1;j<=M;j++){
            cin>>a[i][j];
        }
    }
    vector<vector<ll>> prefO(N+1,vector<ll>(M+1,0)),prefI(N+1,vector<ll>(M+1,0));
    for(int i=1;i<=N;i++){
        for(int j=1;j<=M;j++){
            prefO[i][j]=prefO[i][j-1]+(a[i][j]=='O');
        }
    }
    for(int j=1;j<=M;j++){
        for(int i=1;i<=N;i++){
            prefI[i][j]=prefI[i-1][j]+(a[i][j]=='I');
        }
    }
    ll res=0;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=M;j++){
            if(a[i][j]=='J'){
                res+=(prefO[i][M]-prefO[i][j-1])*(prefI[N][j]-prefI[i-1][j]);
            }
        }
    }
    cout<<res<<endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t; t=1;
    //cin>>t;
    while(t--){
        Solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 5 ms 3540 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 4 ms 2516 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 8 ms 4436 KB Output is correct
19 Correct 7 ms 4316 KB Output is correct
20 Correct 7 ms 4436 KB Output is correct
21 Correct 9 ms 4548 KB Output is correct
22 Correct 8 ms 4308 KB Output is correct
23 Correct 6 ms 4436 KB Output is correct
24 Correct 8 ms 4436 KB Output is correct
25 Correct 7 ms 4324 KB Output is correct
26 Correct 6 ms 4436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 1 ms 468 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 468 KB Output is correct
14 Correct 5 ms 3540 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 4 ms 2516 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 8 ms 4436 KB Output is correct
19 Correct 7 ms 4316 KB Output is correct
20 Correct 7 ms 4436 KB Output is correct
21 Correct 9 ms 4548 KB Output is correct
22 Correct 8 ms 4308 KB Output is correct
23 Correct 6 ms 4436 KB Output is correct
24 Correct 8 ms 4436 KB Output is correct
25 Correct 7 ms 4324 KB Output is correct
26 Correct 6 ms 4436 KB Output is correct
27 Correct 349 ms 142136 KB Output is correct
28 Correct 1 ms 980 KB Output is correct
29 Correct 19 ms 11088 KB Output is correct
30 Correct 1 ms 724 KB Output is correct
31 Correct 231 ms 104688 KB Output is correct
32 Correct 329 ms 149424 KB Output is correct
33 Correct 322 ms 149900 KB Output is correct
34 Correct 285 ms 121296 KB Output is correct
35 Correct 322 ms 149456 KB Output is correct
36 Correct 321 ms 149836 KB Output is correct
37 Correct 350 ms 150572 KB Output is correct
38 Correct 213 ms 103752 KB Output is correct
39 Correct 209 ms 104192 KB Output is correct