이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int main()
{
//freopen("i.txt","r",stdin);
cin.tie(0);
ios_base::sync_with_stdio(false);
int rows, cols;
cin >> rows >> cols;
int arr[rows][cols];
for(int r = 0;r < rows;r++){
string s;
cin >> s;
for(int c = 0;c < cols;c++){
if(s[c] == 'J') arr[r][c] = 0;
else if(s[c] == 'O') arr[r][c] = 1;
else arr[r][c] = 2;
}
}
int O[rows][cols];
int I[rows][cols];
for(int r = 0;r < rows;r++){
for(int c = 0;c < cols;c++){
O[r][c] = 0;
I[r][c] = 0;
}
}
for(int r = 0;r < rows;r++){
for(int c = cols-1;c >= 0;c--){
if(arr[r][c] == 1) O[r][c]++;
if(c != cols-1) O[r][c] += O[r][c+1];
}
}
for(int c = 0;c < cols;c++){
for(int r = rows-1;r >= 0;r--){
if(arr[r][c] == 2) I[r][c]++;
if(r != rows-1) I[r][c] += I[r+1][c];
}
}
long long ans = 0ll;
for(int r = 0;r < rows;r++){
for(int c = 0;c < cols;c++){
if(arr[r][c] == 0){
long long x = O[r][c];
long long y = I[r][c];
ans += x * y;
}
}
}
cout << ans;
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... |