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;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class x>
using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>;
#define int long long
#define endl '\n'
#define mod 1000000007
//\
#define mod 1686876991
const int maxn = 3001;
char g[maxn][maxn];
int suffO[maxn][maxn], suffI[maxn][maxn];
signed main () {
cin.tie(0)->sync_with_stdio(0);
int n, m;
cin >> n >> m;
for (int i = 0 ; i < n ; i++) {
for (int j = 0 ; j < m ; j++) cin >> g[i][j];
}
int ans = 0;
for (int i = n - 1 ; i >= 0 ; i--) {
for (int j = m - 1 ; j >= 0 ; j--) {
if (i + 1 < n) suffO[i][j] = suffO[i + 1][j];
suffO[i][j] += g[i][j] == 'I';
if (j + 1 < m) suffI[i][j] = suffI[i][j + 1];
suffI[i][j] += g[i][j] == 'O';
if (g[i][j] == 'J') {
ans += suffO[i][j] * suffI[i][j];
}
}
}
cout << ans << endl;
}
Compilation message (stderr)
joi2019_ho_t1.cpp:14:1: warning: multi-line comment [-Wcomment]
14 | //\
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |