이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>pii;
int32_t main(){
ios::sync_with_stdio(0);
cin.tie(0);
int r,c;
cin >> r >> c;
char arr[r+5][c+5];
for(int x=1;x<=r;x++){
for(int y=1;y<=c;y++){
cin >> arr[x][y];
}
}
//compute psum
int horizontal[r+5][c+5];
memset(horizontal,0,sizeof(horizontal));
for(int x=1;x<=r;x++){
for(int y=c;y>=1;y--){
horizontal[x][y]=horizontal[x][y+1]+(arr[x][y]=='O');
}
}
int vertical[r+5][c+5];
memset(vertical,0,sizeof(vertical));
for(int x=1;x<=c;x++){
for(int y=r;y>=1;y--){
vertical[y][x]=vertical[y+1][x]+(arr[x][y]=='I');
}
}
int counter=0;
for(int x=1;x<=r;x++){
for(int y=1;y<=c;y++){
if(arr[x][y]=='J'){
counter+=horizontal[x][y]*vertical[x][y];
}
}
}
cout << counter;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |