# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
372494 | armanmohammadi | Bitaro the Brave (JOI19_ho_t1) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
_________ .---""" """---.
:______.-': : .--------------. :
| ______ | | : : |
|:______B:| | | Little Error: | |
|:______B:| | | | |
|:______B:| | | Power not | |
| | | | found. | |
|:_____: | | | | |
| == | | : : |
| O | : '--------------' :
| o | :'---...______...---'
| o |-._.-i___/' \._
|'-.____o_| '-. '-...______...-' `-._
:_________: `.____________________ `-.___.-.
.'.eeeeeeeeeeeeeeeeee.'. :___:
fsc .'.eeeeeeeeeeeeeeeeeeeeee.'.
:____________________________:
*/
//in the name of god
//if you read this code please search about imam hussain
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define endl "\n"
#define X first
#define Y second
#define pii pair<int,int>
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define read freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout)
const int maxn=2e5+5;
const int mod=1e9+7;
const int inf=1e9;
const int del=728729;
ll poww(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));}
ll n;
ll m ;
ll ss[maxn][maxn];
ll ff[maxn][maxn] ;
string s[maxn];
ll ans;
int main(){
migmig;
cin >> n >> m;
for (int i = 1; i <= n; ++ i)
cin >> s[i];
for (int i = 1; i <= n; ++ i)
for (int j = m; j >= 1; -- j)
ss[i][j] = ss[i][j + 1] + (s[i][j - 1] == 'O');
for (int i = n; i >= 1; -- i){
for (int j = 1; j <= m; ++ j){
ff[i][j] = ff[i + 1][j] + (s[i][j - 1] == 'I');
}
}
for (int i = n; i >= 1; -- i){
for (int j = 1; j <= m; ++ j){
if (s[i][j - 1] == 'J')
ans += ss[i][j] * ff[i][j];
}
}
cout << ans << endl;
return 0;
}