이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
int main() {
std::ios::sync_with_stdio(0);
int h, w; std::cin >> h >> w;
std::vector <std::vector <char>> g(3001, std::vector <char> (3001));
std::vector <std::vector <ll>> a(3001, std::vector <ll> (3001, 0)), b(a);
for (int i = 1; i <= h; i++)
for (int j = 1; j <= w; j++) {
std::cin >> g[i][j];
a[i][j] = a[i][j - 1];
b[i][j] = b[i - 1][j];
a[i][j] += g[i][j] == 'O';
b[i][j] += g[i][j] == 'I';
}
ll ans = 0;
for (int i = 1; i <= h; i++)
for (int j = 1; j <= w; j++)
if (g[i][j] == 'J')
ans += (a[i][w] - a[i][j]) * (b[h][j] - b[i][j]);
std::cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |