이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 3010;
int pfCol[MAXN][MAXN];
int pfRow[MAXN][MAXN];
char mat[MAXN][MAXN];
int32_t main() {
//freopen("in", "r", stdin);
int h, w;
cin >> h >> w;
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
cin >> mat[i][j];
}
}
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
pfRow[i][j] = pfRow[i][j - 1];
if (mat[i][j] == 'O') pfRow[i][j]++;
}
}
for (int i = 1; i <= w; i++) {
for (int j = 1; j <= h; j++) {
pfCol[i][j] = pfCol[i][j - 1];
if (mat[j][i] == 'I') pfCol[i][j]++; // coluna i, row j
}
}
int ans = 0;
for (int i = 1; i <= h; i++) {
for (int j = 1; j <= w; j++) {
if (mat[i][j] == 'J') ans += ((pfRow[i][w] - pfRow[i][j - 1])*(pfCol[j][h] - pfCol[j][i - 1]));
}
}
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... |