이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<math.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>
#include<cstring>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
//typedef pair<ll,ll>Point;
//typedef pair<ll,ll>Line;
//#define x first
//#define y second
int w,h;
string arr[3000];
int numo[3000][3000];
int numi[3000][3000];
void solve(){
cin>>w>>h;
for(int x=0;x<w;x++){
cin>>arr[x];
}
for(int x=0;x<w;x++){
for(int y=h-1;y>=0;y--){
if(y!=h-1)
numo[x][y]=numo[x][y+1];
if(arr[x][y]=='O')
numo[x][y]++;
}
}
for(int y=0;y<h;y++){
for(int x=w-1;x>=0;x--){
if(x!=w-1)
numi[x][y]=numi[x+1][y];
if(arr[x][y]=='I')
numi[x][y]++;
}
}
ll res=0;
for(int x=0;x<w;x++){
for(int y=0;y<h;y++){
if(arr[x][y]=='J'){
res+=(ll)numi[x][y]*numo[x][y];
//cout<<res<<"\n";
}
}
}
cout<<res<<"\n";
}
int main(){
ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
//freopen("bank.in","r",stdin);freopen("bank.out","w",stdout);
int t=1;//cin>>t;
while(t--)solve();
return 0;
}
/*
4 4
JJOO
JJOO
IIJO
IIIJ
3 4
JOIJ
JIOO
IIII
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |