Submission #949370

#TimeUsernameProblemLanguageResultExecution timeMemory
949370PM1Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
71 ms79956 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int mxn=3e3+5; int n,m; string s; char c[mxn][mxn]; int rast[mxn][mxn],pain[mxn][mxn]; ll ans; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>m; for(int i=0;i<n;i++){ cin>>s; for(int j=0;j<m;j++) c[i][j]=s[j]; } for(int i=n-1;i>=0;i--){ for(int j=m-1;j>=0;j--){ if(i!=n-1)pain[i][j]=pain[i+1][j]+(c[i+1][j]=='I'); if(j!=m-1)rast[i][j]=rast[i][j+1]+(c[i][j+1]=='O'); if(c[i][j]=='J')ans+=(ll)pain[i][j]*rast[i][j]; } } cout<<ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...