제출 #375985

#제출 시각아이디문제언어결과실행 시간메모리
375985valerikkBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
301 ms89836 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int main() { #ifdef LOCAL freopen("input.txt", "r", stdin); #endif ios::sync_with_stdio(false); cin.tie(0); int h, w; cin >> h >> w; vector<string> s(h); for (int i = 0; i < h; ++i) { cin >> s[i]; } vector<vector<int>> r(h, vector<int>(w, 0)); for (int i = 0; i < h; ++i) { int cnt = 0; for (int j = w - 1; j >= 0; --j) { if (s[i][j] == 'O') ++cnt; r[i][j] = cnt; } } vector<vector<int>> d(h, vector<int>(w, 0)); for (int j = 0; j < w; ++j) { int cnt = 0; for (int i = h - 1; i >= 0; --i) { if (s[i][j] == 'I') ++cnt; d[i][j] = cnt; } } ll ans = 0; for (int i = 0; i < h; ++i) { for (int j = 0; j < w; ++j) { if (s[i][j] == 'J') ans += r[i][j] * d[i][j]; } } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...