This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* author : Lăng Trọng Đạt
* created: 2024-08-25
**/
#include <bits/stdc++.h>
using namespace std;
#ifndef LANG_DAT
#define db(...) ;
#endif // LANG_DAT
#define int long long
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
using pii = pair<int, int>;
using vi = vector<int>;
#define FOR(i, a, b) for (int i = a; (i) <= (b); i++)
void mx(int& a, int b) { if (b > a) a = b; }
void mi(int& a, int b) { if (b < a) a = b; }
#define si(x) (int)(x.size())
const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 3e3 + 5;
int n, m, k, a, b;
string g[N];
int I_in_col[N][N];
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
if (fopen("hi.inp", "r")) {
freopen("hi.inp", "r", stdin);
// freopen("hi.out", "w", stdout);
}
cin >> n >> m;
FOR(i, 1, n) {
cin >> g[i];
g[i] = '#' + g[i];
FOR(j, 1, m) {
I_in_col[i][j] = I_in_col[i - 1][j] + (g[i][j] == 'I');
}
}
int ans = 0;
FOR(i, 1, n) {
int cnt = 0;
FOR(j, 1, m) {
if (g[i][j] == 'J') cnt += I_in_col[n][j] - I_in_col[i - 1][j];
if (g[i][j] == 'O') ans += cnt;
db(i, j, I_in_col[i][j])
}
}
cout << ans;
}
Compilation message (stderr)
joi2019_ho_t1.cpp: In function 'int32_t main()':
joi2019_ho_t1.cpp:34:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
34 | freopen("hi.inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |