제출 #252007

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

const int MAXN = 3003;
long long orb[MAXN], ingot[MAXN];
string grid[MAXN];

int main() {

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);

    int n, m; cin >> n >> m;

    for(int i = 0; i < n; ++i){
        cin >> grid[i];
        for(int j = 0; j < m; ++j){
            if(grid[i][j] == 'I') ++ingot[j];
            else if(grid[i][j] == 'O') ++orb[i];
        }
    }

    long long tot = 0;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            if(grid[i][j] == 'J')
                tot += orb[i] * ingot[j];
            else if(grid[i][j] == 'O')
                --orb[i];
            else if(grid[i][j] == 'I')
                --ingot[j];
        }
    }
    cout << tot << "\n";

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...