Submission #743465

#TimeUsernameProblemLanguageResultExecution timeMemory
743465AndrijaMBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
552 ms216344 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); long long n,m; cin>>n>>m; char mat[n][m]; long long ci[n]; long long cj[m]; long long posi[n][m]; long long posj[m][n]; memset(posi,0,sizeof posi); memset(posj,0,sizeof posj); memset(ci,0,sizeof ci); memset(cj,0,sizeof cj); vector<pair<long long,long long>>v; for(long long i=0;i<n;i++) { for(long long j=0;j<m;j++) { cin>>mat[i][j]; if(j>0) { posi[i][j]=posi[i][j-1]; } if(i>0) { posj[j][i]=posj[j][i-1]; } if(mat[i][j]=='O') { ci[i]++; posi[i][j]++; } if(mat[i][j]=='I') { cj[j]++; posj[j][i]++; } if(mat[i][j]=='J') { v.push_back({i,j}); } } } long long ans=0; for(auto idx:v) { long long a=idx.first; long long b=idx.second; if(ci[a]-posi[a][b]>0 && cj[b]-posj[b][a]>0) ans+=(ci[a]-posi[a][b])*(cj[b]-posj[b][a]); } cout<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...