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