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