이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
int h, w;
vector<string> g;
vector<vector<ll>> a;
ll solve() {
ll ans = 0;
for (int i = 0; i < h; i++) {
ll c = 0;
for (int j = 0; j < w; j++) {
if (g[i][j] == 'J') c += a[h - 1][j] - a[i][j];
else if (g[i][j] == 'O') ans += c;
}
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> h >> w;
g.resize(h), a.resize(h, vector<ll>(w, 0));
for (int i = 0; i < h; i++) {
cin >> g[i];
for (int j = 0; j < w; j++) {
a[i][j] = (g[i][j] == 'I') + (i > 0 ? a[i - 1][j] : 0);
}
}
cout << solve() << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |