제출 #1331290

#제출 시각아이디문제언어결과실행 시간메모리
1331290sigmaligmaBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
184 ms150464 KiB
#include <bits/stdc++.h>
using namespace std;

#define fastio ios::sync_with_stdio(false); cin.tie(nullptr);
#define s(x) x.size()
#define sort(x) sort(x.begin(),x.end())
#define rsort(x) sort(x.rbegin(),x.rend())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second
#define INF 1e9
#define INFL 1e18
#define rep(a,b) for(int a = 0;a<b;a++)

using ll = long long;
using pii = pair<int, int>;

void solve() {
    int h,w;
    cin >> h >> w;
    vector<vector<char>>ciag(h,vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin  >> ciag[i][j];
        }
    }
    vector<vector<ll>>g(h+1,vector<ll>(w+1)),d(h+1,vector<ll>(w+1));
    ll wynik = 0;
    for (int i = h-1; i >=0; i--) {
        for (int j = w-1; j >=0; j--) {
            g[i][j] = g[i+1][j];
            if(ciag[i][j]=='I') g[i][j]++;
            d[i][j] = d[i][j+1];
            if(ciag[i][j]=='O') d[i][j]++;
            if(ciag[i][j]=='J') wynik += d[i][j]*g[i][j];
        }
    }
    cout << wynik << endl;
}

int main() {
    fastio;
    int t = 1;
    // cin >> t;
    while (t--) solve();
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...