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