이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define num long long
const int W = 3000;
const int H = W;
num dp0[W][H];
num dp1[W][H];
bool dp2[W][H];
int main () {
int w, h;
cin >> w >> h;
for (int i = 0; i < w; i ++) {
string b;
cin >> b;
for (int j = 0; j < h; j ++) {
if (b[j] == 'J') dp2[i][j] = true;
if (b[j] == 'O') dp1[i][j] = 1;
if (b[j] == 'I') dp0[i][j] = 1;
}
}
for (int i = w - 2; i >= 0; i --)
for (int j = 0; j < h; j ++)
dp0[i][j] += dp0[i + 1][j];
for (int j = h - 2; j >= 0; j --)
for (int i = 0; i < w; i ++)
dp1[i][j] += dp1[i][j + 1];
num ans = 0;
for (int i = 0; i < w; i ++)
for (int j = 0; j < h; j ++)
if (dp2[i][j])
ans += dp0[i][j] * dp1[i][j];
cout << ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |