This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
#define fastIO ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int N = 3005;
int n, m;
char a[N][N];
LL ans = 0, O[N][N], I[N][N];
int main()
{
fastIO;
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> a[i][j];
for (int i = n; i >= 1; i--)
for (int j = m; j >= 1; j--)
{
O[i][j] = O[i][j + 1];
I[i][j] = I[i + 1][j];
if (a[i][j] == 'O')
O[i][j]++;
if (a[i][j] == 'I')
I[i][j]++;
if (a[i][j] == 'J')
ans += O[i][j] * I[i][j];
}
cout << ans << 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... |