이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <math.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ifstream in("input.txt");
ofstream out("output.txt");
typedef long long ll;
int h,w;
char tab[5000][5000];
int pref[5000][5000];
int prefb[5000][5000];
int sump[5000];
int main(){
cin>>h>>w;
for(int i=0;i<h;i++){
int sum=0;
for(int y=0;y<w;y++){
cin>>tab[i][y];
if(tab[i][y]=='O')sum++;
else if(tab[i][y]=='I')sump[y]++;
prefb[i][y]=sum;
pref[i][y]=sump[y];
}
}
/*for(int i=0;i<w;i++){
int sum=0;
for(int y=0;y<h;y++){
if(tab[y][i]=='I')sum++;
pref[y][i]=sum;
}
}*/
ll tot=0;
for(int i=0;i<h;i++){
for(int y=0;y<w;y++){
if(tab[i][y]=='J'){
tot+=(prefb[i][w-1]-prefb[i][y])*(pref[h-1][y]-pref[i][y]);
}
}
}
cout<<tot;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |