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;
#define int long long
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
const int mod = 1e9 + 7;
const int N = 3000;
int n, m;
char a[N][N];
signed main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i = 0;i < n; i++){
for(int j = 0;j < m; j++){
cin >> a[i][j];
}
}
vector<int> col_I(m, 0);
for(int j = 0;j < m; j++){
for(int i = 0;i < n; i++){
col_I[j]+= (a[i][j] == 'I');
}
}
vector<int> row_O(n, 0);
for(int i = 0; i < n; i++){
for(int j = 0;j < m; j++) row_O[i]+= (a[i][j] == 'O');
}
int ans = 0;
for(int i = 0;i < n; i++){
for(int j = 0;j < m; j++){
col_I[j]-= (a[i][j] == 'I');
row_O[i]-= (a[i][j] == 'O');
if(a[i][j] == 'J'){
int I = col_I[j];
int O = row_O[i];
// cout << i+1 << ' ' << j+1 << " = " << I << '\n';
//cout << i+1 << ' ' << j+1 << " = " << O << '\n';
ans+= O*I;
}
}
}
cout << ans;
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... |