Submission #769268

#TimeUsernameProblemLanguageResultExecution timeMemory
769268NintsiChkhaidzeBitaro the Brave (JOI19_ho_t1)C++17
100 / 100
226 ms88396 KiB
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define s second
#define f first
#define left (node<<1),l,((l+r)>>1)
#define right ((node<<1)|1),((l+r)>>1) + 1,r
using namespace std;

const int N = 3000 + 5;

char a[N][N];
int O[N][N],I[N][N];

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
	
	int n,m;
	cin>>n>>m;
	
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			cin>>a[i][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]++;
		}
	}
	
	ll ans=0;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= m; j++){
			if (a[i][j] != 'J') continue;
			int OO = O[i][m] - O[i][j];
			int II = I[n][j] - I[i][j];
			ans += OO * II;
		}
	}
	cout<<ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...