이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#define ll long long
using namespace std;
int H, W;
string A[3001];
int hor[3001][3001], ver[3001][3001];
int main()
{
ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> H >> W;
for (int i = 0; i < H; i++) cin >> A[i];
for (int i = 0; i < H; i++)
{
for (int j = W - 1; j >= 0; j--)
{
hor[i][j] = (A[i][j] == 'O');
if (j + 1 < W) hor[i][j] += hor[i][j + 1];
}
}
for (int i = H - 1; i >= 0; i--)
{
for (int j = 0; j < W; j++)
{
ver[i][j] = (A[i][j] == 'I');
if (i + 1 < H) ver[i][j] += ver[i + 1][j];
}
}
ll res = 0;
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
res += 1ll * (A[i][j] == 'J') * hor[i][j] * ver[i][j];
}
}
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... |