제출 #234828

#제출 시각아이디문제언어결과실행 시간메모리
234828davitmargBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
249 ms159124 KiB
/*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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...