이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
using namespace std;
const int N = 3e3 + 5;
int dp_orb [N][N];
int dp_ingot [N][N];
char g [N][N];
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
int r, c;
cin >> r >> c;
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
cin >> g[i][j];
}
}
for (int i = 0; i < r; i++) {
for (int j = c - 1; j >= 0; j--) {
dp_orb[i][j] = (g[i][j] == 'O');
if (j < c - 1) dp_orb[i][j] += dp_orb[i][j + 1];
}
}
for (int i = 0; i < c; i++) {
for (int j = r - 1; j >= 0; j--) {
dp_ingot[i][j] = (g[j][i] == 'I');
if (j < r - 1) dp_ingot[i][j] += dp_ingot[i][j + 1];
}
}
long long res = 0;
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
if (g[i][j] != 'J') continue;
int tot_orb = (j + 1 < c ? dp_orb[i][j + 1] : 0);
int tot_ingot = (i + 1 < r ? dp_ingot[j][i + 1] : 0);
res += tot_orb * tot_ingot;
}
}
cout << res << '\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... |