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>
#define f first
#define s second
#define pb push_back
#define int long long
#define N 200005
#define pii pair<int, int>
#define piii pair<int, pii>
using namespace std;
int n, m, i, j, d[3003][3003], r[3003][3003], ans;
char a[3003][3003];
main()
{
std::ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for(i = 0; i < n; i++)
for(j = 0; j < m; j++)
cin >> a[i][j];
for(i = n - 1; i >= 0; i--)
for(j = m - 1; j >= 0; j--)
{
if(j == m - 1) r[i][j] = 0;
else if(a[i][j + 1] == 'O') r[i][j] = r[i][j + 1] + 1;
else r[i][j] = r[i][j + 1];
if(i == n - 1) d[i][j] = 0;
else if(a[i + 1][j] == 'I') d[i][j] = d[i + 1][j] + 1;
else d[i][j] = d[i + 1][j];
if(a[i][j] == 'J') ans += r[i][j] * d[i][j];
}
cout << ans << '\n';
}
Compilation message (stderr)
joi2019_ho_t1.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
14 | main()
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |