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;
using ll = long long;
#define MAXN (1000005)
int main() {
ios_base::sync_with_stdio(false);cin.tie(0);
ll H,W;
cin>>H>>W;
char arr[H][W];
ll row[H]; //number of unvisited orbs in row i
ll col[W]; //number of unvisited ingots in col j
memset(row,0,sizeof(row));
memset(col,0,sizeof(col));
for(ll i = 0;i < H;i++){
for(ll j = 0;j < W;j++){
cin>>arr[i][j];
if(arr[i][j] == 'O') row[i]++;
if(arr[i][j] == 'I') col[j]++;
}
}
ll sum = 0;
for(ll i = 0;i < H;i++){
for(ll j = 0;j < W;j++){
if(arr[i][j] == 'J'){
sum += row[i] * col[j];
}else if(arr[i][j] == 'O'){
row[i]--;
}else if(arr[i][j] == 'I'){
col[j]--;
}
}
}
cout<<sum<<'\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |