이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
const int MAXN = 3005;
char board[MAXN][MAXN];
long long pref_orb[MAXN][MAXN];
long long pref_ingot[MAXN][MAXN];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int h, w;
cin >> h >> w;
for(int i = 1; i <= h; i++)
{
pref_orb[i][0] = 0;
for(int a = 1; a <= w; a++) {
cin >> board[i][a];
pref_orb[i][a] = pref_orb[i][a-1] + (board[i][a] == 'O' ? 1 : 0);
}
}
for(int col = 1; col <= w; col++)
{
for(int row = 1; row <= h; row++)
{
pref_ingot[row][col] = pref_ingot[row-1][col] + (board[row][col] == 'I' ? 1 : 0);
}
}
long long ans = 0;
for(int row = 1; row <= h; row++)
{
for(int col = 1; col <= w; col++)
{
if(board[row][col] == 'J')
{
ans += (pref_orb[row][w] - pref_orb[row][col]) * (pref_ingot[h][col] - pref_ingot[row][col]);
}
//cout << row << " " << col << " " << ans << "\n";
}
}
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... |