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;
#pragma GCC optimize("Ofast", "unroll-loops")
#define int long long
const int maxn = 3e3 + 10, block = 320, mod = 1e9 + 7, inf = 2e9 + 10, lg = 22;
int n, m, o[maxn][maxn], ii[maxn][maxn], ans = 0;
char a[maxn][maxn];
void solve(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> a[i][j];
if(a[i][j] == 'I'){
ii[i][j]++;
}
else if(a[i][j] == 'O'){
o[i][j]++;
}
}
}
for(int i = n; i >= 1; i--){
for(int j = m; j >= 1; j--){
ii[i][j] += ii[i + 1][j];
}
}
for(int i = n; i >= 1; i--){
for(int j = m; j >= 1; j--){
o[i][j] += o[i][j + 1];
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(a[i][j] == 'J'){
ans += ii[i + 1][j] * o[i][j + 1];
}
}
}
cout << ans << "\n";
}
signed main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int T = 1;
//cin >> T;
while(T--){
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |