Submission #677013

#TimeUsernameProblemLanguageResultExecution timeMemory
677013rittin1Bitaro the Brave (JOI19_ho_t1)C++17
100 / 100
271 ms88548 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,m; cin >> n >> m; char arr[n+1][m+1]; int pref1[n+1][m+1]; int pref2[n+1][m+1]; for(int i=0;i<=n;i++){ for(int j=0;j<=m;j++){ pref1[i][j]=0; pref2[i][j]=0; } } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ cin >> arr[i][j]; pref1[i][j]=pref1[i][j-1]; pref2[i][j]=pref2[i-1][j]; if(arr[i][j]=='O'){ pref1[i][j]=pref1[i][j-1]+1; } if(arr[i][j]=='I'){ pref2[i][j]=pref2[i-1][j]+1; } } } long long ans=0; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(arr[i][j]=='J'){ ans+=((pref1[i][m]-pref1[i][j])*(pref2[n][j]-pref2[i][j])); } } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...