//Pantyhose(black) + glasses = infinity
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"
const int MAX_N = 3002;
int m, n;
char a[MAX_N][MAX_N];
int row[MAX_N][MAX_N], col[MAX_N][MAX_N];
void readInput() {
cin >> m >> n;
for (int i=1; i<=m; ++i) {
for (int j=1; j<=n; ++j)
cin >> a[i][j];
}
}
void solve() {
for (int i=1; i<=m; ++i) {
for (int j=n; j>=1; --j)
row[i][j] = row[i][j+1] + (a[i][j]=='O');
}
for (int j=1; j<=n; ++j) {
for (int i=m; i>=1; --i)
col[i][j] = col[i+1][j] + (a[i][j]=='I');
}
int64_t res = 0;
for (int i=1; i<=m; ++i) {
for (int j=1; j<=n; ++j) {
if (a[i][j]=='J')
res += row[i][j] * col[i][j];
}
}
cout << res;
}
int main() {
#ifdef GLASSES_GIRL
freopen(FILE_NAME".in", "r", stdin);
freopen(FILE_NAME".out", "w", stdout);
#endif
ios::sync_with_stdio(0); cin.tie(0);
readInput();
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
3 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1408 KB |
Output is correct |
8 |
Correct |
4 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1280 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
3 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1408 KB |
Output is correct |
8 |
Correct |
4 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1280 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1408 KB |
Output is correct |
14 |
Correct |
16 ms |
7268 KB |
Output is correct |
15 |
Correct |
6 ms |
4992 KB |
Output is correct |
16 |
Correct |
8 ms |
4224 KB |
Output is correct |
17 |
Correct |
2 ms |
480 KB |
Output is correct |
18 |
Correct |
14 ms |
7808 KB |
Output is correct |
19 |
Correct |
19 ms |
7680 KB |
Output is correct |
20 |
Correct |
13 ms |
7680 KB |
Output is correct |
21 |
Correct |
16 ms |
7808 KB |
Output is correct |
22 |
Correct |
15 ms |
7680 KB |
Output is correct |
23 |
Correct |
15 ms |
7744 KB |
Output is correct |
24 |
Correct |
17 ms |
7808 KB |
Output is correct |
25 |
Correct |
14 ms |
7680 KB |
Output is correct |
26 |
Correct |
16 ms |
7680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
3 ms |
1536 KB |
Output is correct |
7 |
Correct |
4 ms |
1408 KB |
Output is correct |
8 |
Correct |
4 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1280 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
13 |
Correct |
2 ms |
1408 KB |
Output is correct |
14 |
Correct |
16 ms |
7268 KB |
Output is correct |
15 |
Correct |
6 ms |
4992 KB |
Output is correct |
16 |
Correct |
8 ms |
4224 KB |
Output is correct |
17 |
Correct |
2 ms |
480 KB |
Output is correct |
18 |
Correct |
14 ms |
7808 KB |
Output is correct |
19 |
Correct |
19 ms |
7680 KB |
Output is correct |
20 |
Correct |
13 ms |
7680 KB |
Output is correct |
21 |
Correct |
16 ms |
7808 KB |
Output is correct |
22 |
Correct |
15 ms |
7680 KB |
Output is correct |
23 |
Correct |
15 ms |
7744 KB |
Output is correct |
24 |
Correct |
17 ms |
7808 KB |
Output is correct |
25 |
Correct |
14 ms |
7680 KB |
Output is correct |
26 |
Correct |
16 ms |
7680 KB |
Output is correct |
27 |
Correct |
431 ms |
79716 KB |
Output is correct |
28 |
Correct |
29 ms |
26104 KB |
Output is correct |
29 |
Correct |
22 ms |
7168 KB |
Output is correct |
30 |
Correct |
3 ms |
640 KB |
Output is correct |
31 |
Correct |
338 ms |
66504 KB |
Output is correct |
32 |
Correct |
420 ms |
79828 KB |
Output is correct |
33 |
Correct |
454 ms |
79224 KB |
Output is correct |
34 |
Correct |
384 ms |
77048 KB |
Output is correct |
35 |
Correct |
425 ms |
79608 KB |
Output is correct |
36 |
Correct |
386 ms |
79608 KB |
Output is correct |
37 |
Correct |
503 ms |
79836 KB |
Output is correct |
38 |
Correct |
345 ms |
66560 KB |
Output is correct |
39 |
Correct |
292 ms |
66256 KB |
Output is correct |