This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define flush fflush(stdout)
#define debug printf("Hello\n")
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
//priority_queue <int, vector <int>, greater <int> > pq;
int n, m, k, x, y, sum, cnt, h, w, orb[3005][3005], ingot[3005][3005];
ll ans;
string s[3005];
int main () {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> h >> w;
FOR(i, 0, h-1) {
cin >> s[i];
}
FOR(i, 0, h-1) {
FOR(j, 0, w-1) {
orb[i+1][j+1] = orb[i+1][j];
if (s[i][j] == 'O') orb[i+1][j+1]++;
}
}
FOR(j, 0, w-1) {
FOR(i, 0, h-1) {
ingot[i+1][j+1] = ingot[i][j+1];
if (s[i][j] == 'I') ingot[i+1][j+1]++;
}
}
FOR(i, 0, h-1) {
FOR(j, 0, w-1) {
if (s[i][j] == 'J') {
ans += 1LL * (orb[i+1][w] - orb[i+1][j+1]) * (ingot[h][j+1] - ingot[i+1][j+1]);
}
}
}
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... |