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 task "test"
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define bit(s, i) (((s) >> (i)) & 1)
#define ii pair <int, int>
#define vii vector <ii>
#define vi vector <int>
#define fi first
#define se second
#define ll long long
#define eb emplace_back
#define pb push_back
#define __builtin_popcount __builtin_popcountll
void solve();
int32_t main() {
if(fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
cin.tie(0)->sync_with_stdio(0);
int tc = 1; // cin >> tc;
FOR(i, 1, tc) {
solve();
}
}
const int N = 3300;
int h, w, cnto[N][N], cnti[N][N];
char a[N][N];
void solve() {
cin >> h >> w;
FOR(i, 1, h) FOR(j, 1, w) cin >> a[i][j];
FOR(i, 1, h) FORD(j, w, 1) {
cnto[i][j] = cnto[i][j+1] + (a[i][j] == 'O');
}
FOR(i, 1, w) FORD(j, h, 1) {
cnti[j][i] = cnti[j+1][i] + (a[j][i] == 'I');
}
ll ans = 0;
FOR(i, 1, h) FOR(j, 1, w) if(a[i][j] == 'J') {
ans = ans + 1ll*cnto[i][j]*cnti[i][j];
}
cout << ans;
}
Compilation message (stderr)
joi2019_ho_t1.cpp: In function 'int32_t main()':
joi2019_ho_t1.cpp:25:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
25 | freopen(task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:26:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | freopen(task".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |