이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int h, w;
cin >> h >> w;
vector<string> stones(h);
for(int i=0; i<h; i++){
cin >> stones[i];
}
vector<vector<int> > orbs(h, vector<int> (w, 0));
vector<vector<int> > ingos(h, vector<int> (w, 0));
for(int i=0; i<h; i++){
if(stones[i][w-1]=='O'){
orbs[i][w-1]=1;
}
for(int j=w-2; j>=0; j--){
orbs[i][j]=orbs[i][j+1]+(stones[i][j]=='O'? 1: 0);
}
}
for(int j=0; j<w; j++){
if(stones[h-1][j]=='I'){
ingos[h-1][j]=1;
}
for(int i=h-2; i>=0; i--){
ingos[i][j]=ingos[i+1][j]+(stones[i][j]=='I'? 1: 0);
}
}
int ans=0;
for(int i=0; i<h; i++){
for(int j=0; j<w; j++){
if(stones[i][j]=='J'){
ans+=orbs[i][j]*ingos[i][j];
}
}
}
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... |