Submission #1218764

#TimeUsernameProblemLanguageResultExecution timeMemory
1218764atillamaBitaro the Brave (JOI19_ho_t1)C++20
100 / 100
190 ms10776 KiB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;

#define int long long
#define double long double
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define debug(x) cout << #x << " = " << x << '\n';
#define vdebug(a) cout << #a << " = "; for(auto x : a) cout << x << " "; cout << '\n';

const double eps = 1e-9;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int INF = 1e18;

signed main(){
    fastio;
	int h, w;
	cin >> h >> w;
	vector<vector<char>> grid(h + 1, vector<char>(w + 1));
	vector<map<char, int>> row(h + 1);
	vector<map<char, int>> column(w + 1);
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			cin >> grid[i][j];
		}
	}
	int ans = 0;
	for(int i = h; i >= 1; i--){
		for(int j = w; j >= 1; j--){
			row[i][grid[i][j]]++;
			column[j][grid[i][j]]++;
			if(grid[i][j] == 'J'){
				ans += row[i]['O'] * column[j]['I'];
			}
		}
	}
	cout << ans << '\n';
}

/*
    freopen("x.in", "r", stdin);
    freopen("x.out", "w", stdout);
*/

//atilla
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...