이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define nl '\n'
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int H, W;
std::cin >> H >> W;
std::vector<std::string> S(H);
for (int i = 0; i < H; i++) {
std::cin >> S[i];
}
std::vector cnt(H, std::vector<int>(W + 1));
for (int i = 0; i < H; i++) {
for (int j = W - 1; j >= 0; j--) {
cnt[i][j] = cnt[i][j + 1] + (S[i][j] == 'O');
}
}
int64_t ans = 0;
for (int j = 0; j < W; j++) {
int64_t tot = 0;
for (int i = 0; i < H; i++) {
tot += (S[i][j] == 'J') * cnt[i][j];
if (S[i][j] == 'I') {
ans += tot;
}
}
}
std::cout << ans << nl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |