#include <bits/stdc++.h>
#define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define REV(i, b, a) for(int i = (b); i >= (a); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define ll long long
#define fi first
#define se second
#define int long long
using namespace std;
const int N = 3005;
int n, m;
int a[N][N];
int hang[N][N][3], cot[N][N][3];
void solve(int tc) {
cin >> n >> m;
char ch;
FOR(i, 1, n) FOR(j, 1, m) {
cin >> ch;
switch (ch) {
case 'J' :
a[i][j] = 0;
break;
case 'O' :
a[i][j] = 1;
break;
case 'I' :
a[i][j] = 2;
break;
default :
break;
}
}
FOR(i, 1, n) {
REV(j, m, 1) {
FOR(k, 0, 2) hang[i][j][k] = hang[i][j + 1][k];
hang[i][j][a[i][j]]++;
}
}
FOR(j, 1, m) {
REV(i, n, 1) {
FOR(k, 0, 2) cot[j][i][k] = cot[j][i + 1][k];
cot[j][i][a[i][j]]++;
}
}
int ans = 0;
FOR(i, 1, n) FOR(j, 1, m) {
if(a[i][j] == 0) {
ans += hang[i][j + 1][1] * cot[j][i + 1][2];
}
}
cout << ans << '\n';
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int tc = 1;
// cin >> tc;
for(int i = 1; i <= tc; ++i) solve(tc);
return (0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
2140 KB |
Output is correct |
6 |
Correct |
1 ms |
1884 KB |
Output is correct |
7 |
Correct |
1 ms |
1884 KB |
Output is correct |
8 |
Correct |
1 ms |
2140 KB |
Output is correct |
9 |
Correct |
1 ms |
1884 KB |
Output is correct |
10 |
Correct |
1 ms |
1884 KB |
Output is correct |
11 |
Correct |
1 ms |
2140 KB |
Output is correct |
12 |
Correct |
1 ms |
1884 KB |
Output is correct |
13 |
Correct |
1 ms |
1884 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
2140 KB |
Output is correct |
6 |
Correct |
1 ms |
1884 KB |
Output is correct |
7 |
Correct |
1 ms |
1884 KB |
Output is correct |
8 |
Correct |
1 ms |
2140 KB |
Output is correct |
9 |
Correct |
1 ms |
1884 KB |
Output is correct |
10 |
Correct |
1 ms |
1884 KB |
Output is correct |
11 |
Correct |
1 ms |
2140 KB |
Output is correct |
12 |
Correct |
1 ms |
1884 KB |
Output is correct |
13 |
Correct |
1 ms |
1884 KB |
Output is correct |
14 |
Correct |
15 ms |
16732 KB |
Output is correct |
15 |
Correct |
2 ms |
4188 KB |
Output is correct |
16 |
Correct |
6 ms |
11868 KB |
Output is correct |
17 |
Correct |
1 ms |
1884 KB |
Output is correct |
18 |
Correct |
16 ms |
20524 KB |
Output is correct |
19 |
Correct |
12 ms |
19792 KB |
Output is correct |
20 |
Correct |
11 ms |
20060 KB |
Output is correct |
21 |
Correct |
16 ms |
20552 KB |
Output is correct |
22 |
Correct |
13 ms |
19804 KB |
Output is correct |
23 |
Correct |
11 ms |
20060 KB |
Output is correct |
24 |
Correct |
15 ms |
20316 KB |
Output is correct |
25 |
Correct |
13 ms |
19804 KB |
Output is correct |
26 |
Correct |
12 ms |
20060 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
2140 KB |
Output is correct |
6 |
Correct |
1 ms |
1884 KB |
Output is correct |
7 |
Correct |
1 ms |
1884 KB |
Output is correct |
8 |
Correct |
1 ms |
2140 KB |
Output is correct |
9 |
Correct |
1 ms |
1884 KB |
Output is correct |
10 |
Correct |
1 ms |
1884 KB |
Output is correct |
11 |
Correct |
1 ms |
2140 KB |
Output is correct |
12 |
Correct |
1 ms |
1884 KB |
Output is correct |
13 |
Correct |
1 ms |
1884 KB |
Output is correct |
14 |
Correct |
15 ms |
16732 KB |
Output is correct |
15 |
Correct |
2 ms |
4188 KB |
Output is correct |
16 |
Correct |
6 ms |
11868 KB |
Output is correct |
17 |
Correct |
1 ms |
1884 KB |
Output is correct |
18 |
Correct |
16 ms |
20524 KB |
Output is correct |
19 |
Correct |
12 ms |
19792 KB |
Output is correct |
20 |
Correct |
11 ms |
20060 KB |
Output is correct |
21 |
Correct |
16 ms |
20552 KB |
Output is correct |
22 |
Correct |
13 ms |
19804 KB |
Output is correct |
23 |
Correct |
11 ms |
20060 KB |
Output is correct |
24 |
Correct |
15 ms |
20316 KB |
Output is correct |
25 |
Correct |
13 ms |
19804 KB |
Output is correct |
26 |
Correct |
12 ms |
20060 KB |
Output is correct |
27 |
Runtime error |
317 ms |
274432 KB |
Execution killed with signal 9 |
28 |
Halted |
0 ms |
0 KB |
- |