Submission #1165221

#TimeUsernameProblemLanguageResultExecution timeMemory
1165221TsaganaBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
63 ms10204 KiB
#include<bits/stdc++.h>

#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second

using namespace std;

void solve () {
	int n, m; cin >> n >> m;
	vector<string> s(n); 
	for (auto &i: s) cin >> i;

	vector<int> vo(n+1);
	vector<int> vi(m+1);
	int ans = 0;

	for (int i = n-1; i >= 0; i--) {
		for (int j = m-1; j >= 0; j--) {
			if (s[i][j] == 'J') ans += vo[i] * vi[j];
			if (s[i][j] == 'O') vo[i]++;
			if (s[i][j] == 'I') vi[j]++;
		}
	}
	cout << ans;
}
signed main() {IOS solve(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...