Submission #913526

#TimeUsernameProblemLanguageResultExecution timeMemory
913526AshiEhsBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
263 ms84636 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
#define pb push_back
#define pob pop_back
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vc vector<char>
#define vvc vector<vc>

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int h, w;
    ll counter = 0;
    cin >> h >> w;
    vvc data(h, vc(w));
    vvi a(h, vi(w)), b(w, vi(h));
    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
            cin >> data[i][j];
    for(int i = 0; i < h; i++){
        int ashkan = 0;
        for(int j = w - 1; j >= 0; j--){
            if(data[i][j] == 'O')
                ashkan++;
            a[i][j] = ashkan;
        }
    }
    for(int i = 0; i < w; i++){
        int ashkan = 0;
        for(int j = h - 1; j >= 0; j--){
            if(data[j][i] == 'I')
                ashkan++;
            b[i][j] = ashkan;
        }
    }
    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
            if(data[i][j] == 'J')
                counter += (ll)(a[i][j] * b[j][i]);
    cout << counter;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...