Submission #102697

#TimeUsernameProblemLanguageResultExecution timeMemory
102697dsjongBitaro the Brave (JOI19_ho_t1)C++14
100 / 100
331 ms83320 KiB
#include<bits/stdc++.h> using namespace std; int O[3005][3005]; int I[3005][3005]; char c[3005][3005]; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int H,W; cin>>H>>W; for(int i=1;i<=H;i++){ for(int j=1;j<=W;j++){ cin>>c[i][j]; O[i][j]=O[i-1][j]+O[i][j-1]-O[i-1][j-1]; I[i][j]=I[i-1][j]+I[i][j-1]-I[i-1][j-1]; if(c[i][j]=='O') O[i][j]++; if(c[i][j]=='I') I[i][j]++; } } long long ans=0; for(int i=1;i<=H;i++){ for(int j=1;j<=W;j++){ if(c[i][j]=='J'){ long long a=O[i][W]-O[i-1][W]-O[i][j]+O[i-1][j]; long long b=I[H][j]-I[H][j-1]-I[i][j]+I[i][j-1]; ans+=a*b; } } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...