#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
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);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
3420 KB |
Output is correct |
6 |
Correct |
1 ms |
3420 KB |
Output is correct |
7 |
Correct |
1 ms |
3420 KB |
Output is correct |
8 |
Correct |
1 ms |
3420 KB |
Output is correct |
9 |
Correct |
1 ms |
3420 KB |
Output is correct |
10 |
Correct |
1 ms |
3420 KB |
Output is correct |
11 |
Correct |
1 ms |
3420 KB |
Output is correct |
12 |
Correct |
1 ms |
3420 KB |
Output is correct |
13 |
Correct |
1 ms |
3492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
3420 KB |
Output is correct |
6 |
Correct |
1 ms |
3420 KB |
Output is correct |
7 |
Correct |
1 ms |
3420 KB |
Output is correct |
8 |
Correct |
1 ms |
3420 KB |
Output is correct |
9 |
Correct |
1 ms |
3420 KB |
Output is correct |
10 |
Correct |
1 ms |
3420 KB |
Output is correct |
11 |
Correct |
1 ms |
3420 KB |
Output is correct |
12 |
Correct |
1 ms |
3420 KB |
Output is correct |
13 |
Correct |
1 ms |
3492 KB |
Output is correct |
14 |
Correct |
7 ms |
11608 KB |
Output is correct |
15 |
Correct |
2 ms |
8792 KB |
Output is correct |
16 |
Correct |
3 ms |
6748 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
6 ms |
11868 KB |
Output is correct |
19 |
Correct |
5 ms |
11868 KB |
Output is correct |
20 |
Correct |
5 ms |
11868 KB |
Output is correct |
21 |
Correct |
6 ms |
11868 KB |
Output is correct |
22 |
Correct |
5 ms |
11868 KB |
Output is correct |
23 |
Correct |
5 ms |
11868 KB |
Output is correct |
24 |
Correct |
6 ms |
11868 KB |
Output is correct |
25 |
Correct |
5 ms |
11864 KB |
Output is correct |
26 |
Correct |
5 ms |
11868 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
3420 KB |
Output is correct |
6 |
Correct |
1 ms |
3420 KB |
Output is correct |
7 |
Correct |
1 ms |
3420 KB |
Output is correct |
8 |
Correct |
1 ms |
3420 KB |
Output is correct |
9 |
Correct |
1 ms |
3420 KB |
Output is correct |
10 |
Correct |
1 ms |
3420 KB |
Output is correct |
11 |
Correct |
1 ms |
3420 KB |
Output is correct |
12 |
Correct |
1 ms |
3420 KB |
Output is correct |
13 |
Correct |
1 ms |
3492 KB |
Output is correct |
14 |
Correct |
7 ms |
11608 KB |
Output is correct |
15 |
Correct |
2 ms |
8792 KB |
Output is correct |
16 |
Correct |
3 ms |
6748 KB |
Output is correct |
17 |
Correct |
0 ms |
604 KB |
Output is correct |
18 |
Correct |
6 ms |
11868 KB |
Output is correct |
19 |
Correct |
5 ms |
11868 KB |
Output is correct |
20 |
Correct |
5 ms |
11868 KB |
Output is correct |
21 |
Correct |
6 ms |
11868 KB |
Output is correct |
22 |
Correct |
5 ms |
11868 KB |
Output is correct |
23 |
Correct |
5 ms |
11868 KB |
Output is correct |
24 |
Correct |
6 ms |
11868 KB |
Output is correct |
25 |
Correct |
5 ms |
11864 KB |
Output is correct |
26 |
Correct |
5 ms |
11868 KB |
Output is correct |
27 |
Correct |
193 ms |
88144 KB |
Output is correct |
28 |
Correct |
8 ms |
38744 KB |
Output is correct |
29 |
Correct |
11 ms |
9564 KB |
Output is correct |
30 |
Correct |
1 ms |
604 KB |
Output is correct |
31 |
Correct |
115 ms |
73344 KB |
Output is correct |
32 |
Correct |
143 ms |
88148 KB |
Output is correct |
33 |
Correct |
143 ms |
87888 KB |
Output is correct |
34 |
Correct |
132 ms |
85584 KB |
Output is correct |
35 |
Correct |
154 ms |
88184 KB |
Output is correct |
36 |
Correct |
150 ms |
87940 KB |
Output is correct |
37 |
Correct |
180 ms |
88144 KB |
Output is correct |
38 |
Correct |
101 ms |
73300 KB |
Output is correct |
39 |
Correct |
107 ms |
73040 KB |
Output is correct |