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;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define REP(i,a,b) for(int i=a;i<b;i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
const int m=1e9+7;
int main(){
//ios::sync_with_stdio(0);
// cin.tie(0);
//freopen("test_input.txt", "r", stdin);
//freopen("test_output.txt", "w", stdout);
int a,b;cin>>a>>b;
vector<vector<char>> grid(a,vector<char>(b));
REP(i,0,a)REP(j,0,b)cin>>grid[i][j];
vi ic(b,0),oc(a,0);
REP(i,0,a)REP(j,0,b){
if(grid[i][j]=='I')ic[j]++;
else if(grid[i][j]=='O')oc[i]++;
}
ll ans=0;
REP(i,0,a)REP(j,0,b){
if(grid[i][j]=='I')ic[j]--;
else if(grid[i][j]=='O')oc[i]--;
else ans+=(ll)oc[i]*ic[j];
}
cout<<ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |