#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i >= _a; i--)
#define pa pair<ll, ll>
#define fi first
#define se second
#define bit(mask, j) ((mask >> j) & 1)
#define t_test int t;cin >> t;while(t--)
const ll mod = 1e9 + 7;
const ll INF = 1e18;
inline void adm(ll &x){if(x>=mod)x%=mod;else if(x<0)x+=mod;}
//--------------------------------------------------------------------
string T = "JOI";
int n, m;
const int N = 5003;
int s[N][N][4], c[N][N];
int get(int u, int v, int x, int y, int t) {
return s[x][y][t] - s[u - 1][y][t] - s[x][v - 1][t] + s[u - 1][v - 1][t];
}
void hbmt() {
cin >> n >> m;
FOR(i, 1, n) {
FOR(j, 1, m) {
char x;
cin >> x;
int e = T.find(x);
c[i][j] = e;
FOR(u, 0, 2) {
s[i][j][u] = s[i - 1][j][u] + s[i][j - 1][u] - s[i - 1][j - 1][u] + (e == u);
}
}
}
int ans = 0;
FOR(i, 1, n) {
FOR(j, 1, m) {
if(c[i][j] == 0) {
ans += get(i, j, i, m, 1) * get(i, j, n, j, 2);
}
}
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
if(fopen("hbmt.inp", "r")) {
freopen("hbmt.inp", "r", stdin);
freopen("hbmt.out", "w", stdout);
}
// t_test
hbmt();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
joi2019_ho_t1.cpp: In function 'int main()':
joi2019_ho_t1.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
53 | freopen("hbmt.inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
joi2019_ho_t1.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
54 | freopen("hbmt.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... |