#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
/**zagaro & lauren <3**/
#define mod 1000000007 //1e9 + 7
#define pi acos(-1)
#define wl while
#define str string
#define ENDL "\n"
#define sal ' '
#define tp_set ll
#define prc(n) cout.precision(n);cout<<fixed;
#define ord_set tree<tp_set, null_type, less<tp_set>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef bool bl;
typedef char car;
using namespace std;
using namespace __gnu_pbds;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll n, m, r=0;
cin>>n>>m;
vector<vector<car> > vec(n+1, vector<car> (m+1));
vector<vector<ll> > O(n+1, vector<ll> (m+1, 0));
vector<vector<ll> > I(n+1, vector<ll> (m+1, 0));
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>vec[i][j];
O[i][j] += O[i][j-1];
I[i][j] += I[i-1][j];
if(vec[i][j] == 'O')O[i][j]++;
if(vec[i][j] == 'I')I[i][j]++;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(vec[i][j] == 'J'){
r += (O[i][m]-O[i][j])*(I[n][j]-I[i][j]);
}
}
}
cout<<r<<ENDL;
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... |