Submission #947614

#TimeUsernameProblemLanguageResultExecution timeMemory
947614packmaniMecho (IOI09_mecho)C++14
5 / 100
19 ms28332 KiB
#include<bits/stdc++.h> using namespace std; #define int long long int int n,m; string s[3005]; int suff_o[3005][3005]; int suff_i[3005][3005]; int sum; int32_t main() { cin >> n >> m; for(int i=0;i<n;i++) cin >> s[i]; for(int i=0;i<n;i++) { for(int j=m-1;j>0;j--) { suff_o[i][j-1]=suff_o[i][j]; if(s[i][j]=='O') suff_o[i][j-1]++; } } for(int i=0;i<m;i++) { for(int j=n-1;j>0;j--) { suff_i[j-1][i]=suff_i[j][i]; if(s[j][i]=='I') suff_i[j-1][i]++; } } sum=0; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { if(s[i][j]=='J') { sum+=suff_i[i][j]*suff_o[i][j]; } } } cout << sum; /*for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { cout << suff_o[i][j] << ' '; } cout << '\n'; } cout << '\n'; for(int i=0;i<n;i++) { for(int j=0;j<m;j++) { cout << suff_i[i][j] << ' '; } cout << '\n'; }*/ }
#Verdict Execution timeMemoryGrader output
Fetching results...