Submission #936935

#TimeUsernameProblemLanguageResultExecution timeMemory
936935detectivebowonBitaro the Brave (JOI19_ho_t1)C++14
20 / 100
14 ms13412 KiB
#include<bits/stdc++.h> using namespace std; int h,w,qso[3007][3007],qsi[3007][3007],ans; char space[3007][3007]; queue<pair<int,int>> q; int main() { cin>>h>>w; for(int i=1;i<=h;i++) { for(int j=1;j<=w;j++) { cin>>space[i][j]; if(space[i][j]=='J') { q.push({i,j}); } } } for(int i=1;i<=h;i++) { for(int j=1;j<=w;j++) { if(space[i][j]=='I') qsi[i][j]=qsi[i-1][j]+1; else qsi[i][j]=qsi[i-1][j]; if(space[i][j]=='O') qso[i][j]=qso[i][j-1]+1; else qso[i][j]=qso[i][j-1]; } } while(!q.empty()) { int x=q.front().first; int y=q.front().second; q.pop(); ans+=(qsi[h][y]-qsi[x][y])*(qso[x][w]-qso[x][y]); // cout<<x<<" "<<y<<" "<<ans<<" "<<qsi[h][y]<<" "<<qso[x][w]<<"\n"; } cout<<ans; // for(int i=1;i<=h;i++) // { // for(int j=1;j<=w;j++) // { // cout<<qsi[i][j]<<" "; // } // cout<<"\n"; // } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...