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
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m; cin >> n >> m;
vector<pair<int,int>> jw;
vector<vector<int>> orb, ing;
orb = ing = vector<vector<int>>(n, vector<int>(m));
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
char c; cin >> c;
if(c == 'J') jw.emplace_back(i, j);
else if(c == 'I') ing[i][j]++;
else if(c == 'O') orb[i][j]++;
}
}
for(int i = 0; i < n; i++){
for(int j = m - 2; j >= 0; j--){
orb[i][j] += orb[i][j + 1];
}
}
for(int i = 0; i < m; i++){
for(int j = n - 2; j >= 0; j--){
ing[j][i] += ing[j+1][i];
}
}
int res = 0;
for(pair<int,int> j : jw){
res += orb[j.first][j.second] * ing[j.first][j.second];
}
cout << res << '\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... |