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;
int H, W;
vector<string> V;
void solve(){
cin>>H>>W;
V.assign(H, "");
for(int i = 0; i < H; i++) cin>>V[i];
long long ans = 0;
vector<int> orbInRow(H, 0), ingotInCol(W, 0);
for(int i = 0; i < H; i++)
for(int j = 0; j < W; j++) orbInRow[i] += V[i][j] == 'O';
for(int i = 0; i < W; i++)
for(int j = 0; j < H; j++) ingotInCol[i] += V[j][i] == 'I';
for(int i = 0; i < H; i++){
for(int j = 0; j < W; j++){
if(V[i][j] == 'O') orbInRow[i]--;
if(V[i][j] == 'I') ingotInCol[j]--;
if(V[i][j] != 'J') continue;
// mi servono gli ingot sotto i
ans += (long long)orbInRow[i] * (long long)ingotInCol[j];
// cout<<"DEBUG-->"<<i+1<<" "<<j+1<<" "<<orbInRow[i] * ingotInCol[j]<<endl;
}
}
cout<<ans<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
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... |