This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
const int maxn = 3005;
using ll = long long;
char s[maxn][maxn];
ll pref[maxn][maxn], pref1[maxn][maxn];
int main(int argc, char const *argv[])
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= m; ++j){
cin >> s[i][j];
}
}
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= m; ++j){
pref[i][j] = pref[i][j - 1] + (s[i][j] == 'O');
}
}
for(int i = 1; i <= m; ++i){
for(int j = 1; j <= n; ++j){
pref1[j][i] = pref1[j - 1][i] + (s[j][i] == 'I');
}
}
ll ans = 0;
for(int i = 1; i <= n; ++i){
for(int j = 1; j <= m; ++j){
if(s[i][j] == 'J'){
ll x = (pref[i][m] - pref[i][j]) * (pref1[n][j] - pref1[i][j]);
ans += x;
}
}
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |