제출 #334412

#제출 시각아이디문제언어결과실행 시간메모리
334412Tahmid690Bitaro the Brave (JOI19_ho_t1)C++14
50 / 100
616 ms274432 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long int h,w; string s[3005]; unordered_map<int,int> rows; unordered_map<int,int> colum; unordered_map<int,map<int,int>> rowsfin; unordered_map<int,map<int,int>> columfin; int main(){ cin >> h >> w; for(int i=0;i<h;i++) cin >> s[i]; for(int i=0;i<h;i++){ int x=0; for(int j=0;j<w;j++){ if(s[i][j]=='O') x++; rowsfin[i][j+1]=x; } rows[i]=x; } for(int i=0;i<w;i++){ int x=0; for(int j=0;j<h;j++){ if(s[j][i]=='I') x++; columfin[i][j+1]=x; } colum[i]=x; } ll ans=0; for(ll i=0;i<h;i++){ for(ll j=0;j<w;j++){ ll a,b,c,d; a=rows[i]; b=rowsfin[i][j]; c=colum[j]; d=columfin[j][i]; if(s[i][j]=='J') ans+=((a-b)*(c-d)); } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...