이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define SZ 3005
using namespace std;
int h,w,rowo[SZ][SZ],coli[SZ][SZ];
int main() {
long long sum=0;
vector<pair<int,int> >coords;
string s;
cin>>h>>w;
for(int i=1;i<=h;i++){
cin>>s;
for(int j=1;j<=w;j++){
rowo[i][j]=rowo[i][j-1];
coli[i][j]=coli[i-1][j];
if(s[j-1]=='J')coords.emplace_back(i,j);
else if(s[j-1]=='O')rowo[i][j]++;
else if(s[j-1]=='I')coli[i][j]++;
}
}
/* for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
cout<<rowo[i][j]<<" ";
}
cout<<"\n";
}
cout<<"\n";
for(int i=1;i<=h;i++){
for(int j=1;j<=w;j++){
cout<<coli[i][j]<<" ";
}
cout<<"\n";
}*/
for(auto x:coords){
sum+=(rowo[x.first][w]-rowo[x.first][x.second])*(coli[h][x.second]-coli[x.first][x.second]);
}
cout<<sum;
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... |