이 제출은 이전 버전의 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 prefb[5000][5000];
int fb[5000];
int f[5000];
vector<pair<int,int> > v;
int main(){
cin>>h>>w;
int sumf;
ll tot=0;
for(int i=0;i<h;i++){
int sum=0;
for(int y=0;y<w;y++){
cin>>tab[i][y];
if(i!=0&&tab[i-1][y]=='J')fb[y]+=sumf-prefb[i-1][y];
if(tab[i][y]=='O')sum++;
else if(tab[i][y]=='I'){
f[y]++;
}
else{
tot+=f[y]*fb[y];
f[y]=0;
}
if(tab[i][y]!='J'&&i==h-1){
tot+=f[y]*fb[y];
}
prefb[i][y]=sum;
}
sumf=sum;
}
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... |