#include<bits/stdc++.h>
#define int long long
#define FOR(i, l, r, st) for(int i = l; i <= r; i += st)
#define FOS(i, l, r, sl) for(int i = l; i >= r; i -= sl)
using namespace std;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
void suncuti() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int H, W;
char A[3005][3005];
int row[3005][3005], low[3005][3005];
main() {
suncuti();
cin >> H >> W;
FOR(i, 1, H, 1) {
FOR(j, 1, W, 1) {
cin >> A[i][j];
}
}
FOS(i, H, 1, 1) {
FOS(j, W, 1, 1) {
row[i][j] = row[i][j + 1] + (A[i][j] == 'O');
low[i][j] = low[i + 1][j] + (A[i][j] == 'I');
}
}
int cnt = 0;
FOR(i, 1, H, 1) {
FOR(j, 1, W, 1) {
if(A[i][j] == 'J') {
cnt += row[i][j + 1] * low[i + 1][j];
}
}
}
cout << cnt;
}
Compilation message (stderr)
joi2019_ho_t1.cpp:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
20 | 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... |