Submission #936626

#TimeUsernameProblemLanguageResultExecution timeMemory
936626adkjtBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
249 ms129364 KiB
#include<bits/stdc++.h> using namespace std; /*struct O { int l,i; bool operator<(const O&o)const{ return l<o.l; } }; struct I { int k,j; bool operator<(const I&o)const{ return k<o.k; } };*/ char t[3333][3333]; int qso[3333][3333]; int qsi[3333][3333]; queue<pair<int,int>> J; int main() { cin.tie()->sync_with_stdio(0); int r,c;cin>>r>>c; for(int i= 1;i<=r;i++) for(int j=1;j<=c;j++) { cin>>t[i][j]; if(t[i][j]=='J') J.push({i,j}); else if(t[i][j]=='O') qso[i][j]=1; else qsi[i][j]=1; } long long ans=0; for(int i=1;i<=r;i++) { for(int j=1;j<=c;j++) { qso[i][j]+=qso[i][j-1]; qsi[i][j]+=qsi[i-1][j]; } } while(!J.empty()) { pair<int,int> now=J.front(); // cout<<now.first<<' '<<now.second<<'\n'; J.pop(); ans+=(qso[now.first][c]-qso[now.first][now.second])*(qsi[r][now.second]-qsi[now.first][now.second]); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...