#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
#define int long long
using namespace std;
const long long oo = 1000000000000000000;
long long sum, ans = 0, mx = 0, mn = 1000000000, num, pos;
/*
ViHHiPuh
(( `'-""``""-'` ))
)-__-_.._-__-(
/ --- (o _ o) --- \
\ .-* ( .0. ) *-. /
_'-. ,_ '=' _, .-'_
/ `;#'#'# - #'#'#;` \
\_)) -----'#'----- ((_/
# --------- #
'# ------- ------ #'
/..-'# ------- #'-.\
_\...-\'# -- #'/-.../_
((____)- '#' -(____))
cout << fixed << setprecision(6) << x;
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
freopen ( "sum.in", "r", stdin )
*/
int n, m, mp[ 3001 ][ 3001 ];
char c[ 3001 ][ 3001 ];
main () {
cin >> n >> m;
for ( int i = 1; i <= n; i ++ ) {
for ( int j = 1; j <= m; j ++ ) {
cin >> c[ i ][ j ];
}
}
for ( int i = 1; i <= n; i ++ ) {
num = 0;
for ( int j = m; j >= 1; j -- ) {
if ( c[ i ][ j ] == 'O' )
num ++;
if ( c[ i ][ j ] == 'J' )
mp[ i ][ j ] = num;
}
}
for ( int j = 1; j <= m; j ++ ) {
num = 0;
for ( int i = n; i >= 1; i -- ) {
if ( c[ i ][ j ] == 'I' )
num ++;
if ( c[ i ][ j ] == 'J' ) {
ans += mp[ i ][ j ] * num;
}
}
}
cout << ans;
}
/*
(p[ i ] - p[j - 1] ) - (a[i] - a[j])
p[i] - p[j-1] - a[i] + a[j]
p[i] - a[i] - p[j-1] + a[j]
*/
Compilation message
joi2019_ho_t1.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
49 | main () {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
284 KB |
Output is correct |
2 |
Correct |
1 ms |
288 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
1076 KB |
Output is correct |
6 |
Correct |
2 ms |
936 KB |
Output is correct |
7 |
Correct |
2 ms |
948 KB |
Output is correct |
8 |
Correct |
1 ms |
972 KB |
Output is correct |
9 |
Correct |
1 ms |
972 KB |
Output is correct |
10 |
Correct |
1 ms |
944 KB |
Output is correct |
11 |
Correct |
2 ms |
1072 KB |
Output is correct |
12 |
Correct |
2 ms |
932 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
284 KB |
Output is correct |
2 |
Correct |
1 ms |
288 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
1076 KB |
Output is correct |
6 |
Correct |
2 ms |
936 KB |
Output is correct |
7 |
Correct |
2 ms |
948 KB |
Output is correct |
8 |
Correct |
1 ms |
972 KB |
Output is correct |
9 |
Correct |
1 ms |
972 KB |
Output is correct |
10 |
Correct |
1 ms |
944 KB |
Output is correct |
11 |
Correct |
2 ms |
1072 KB |
Output is correct |
12 |
Correct |
2 ms |
932 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
14 |
Correct |
16 ms |
5424 KB |
Output is correct |
15 |
Correct |
2 ms |
3056 KB |
Output is correct |
16 |
Correct |
10 ms |
2636 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
21 ms |
5916 KB |
Output is correct |
19 |
Correct |
16 ms |
4908 KB |
Output is correct |
20 |
Correct |
17 ms |
4552 KB |
Output is correct |
21 |
Correct |
20 ms |
5920 KB |
Output is correct |
22 |
Correct |
17 ms |
5284 KB |
Output is correct |
23 |
Correct |
16 ms |
4536 KB |
Output is correct |
24 |
Correct |
20 ms |
5844 KB |
Output is correct |
25 |
Correct |
16 ms |
4932 KB |
Output is correct |
26 |
Correct |
16 ms |
4548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
284 KB |
Output is correct |
2 |
Correct |
1 ms |
288 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
2 ms |
1076 KB |
Output is correct |
6 |
Correct |
2 ms |
936 KB |
Output is correct |
7 |
Correct |
2 ms |
948 KB |
Output is correct |
8 |
Correct |
1 ms |
972 KB |
Output is correct |
9 |
Correct |
1 ms |
972 KB |
Output is correct |
10 |
Correct |
1 ms |
944 KB |
Output is correct |
11 |
Correct |
2 ms |
1072 KB |
Output is correct |
12 |
Correct |
2 ms |
932 KB |
Output is correct |
13 |
Correct |
1 ms |
972 KB |
Output is correct |
14 |
Correct |
16 ms |
5424 KB |
Output is correct |
15 |
Correct |
2 ms |
3056 KB |
Output is correct |
16 |
Correct |
10 ms |
2636 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
21 ms |
5916 KB |
Output is correct |
19 |
Correct |
16 ms |
4908 KB |
Output is correct |
20 |
Correct |
17 ms |
4552 KB |
Output is correct |
21 |
Correct |
20 ms |
5920 KB |
Output is correct |
22 |
Correct |
17 ms |
5284 KB |
Output is correct |
23 |
Correct |
16 ms |
4536 KB |
Output is correct |
24 |
Correct |
20 ms |
5844 KB |
Output is correct |
25 |
Correct |
16 ms |
4932 KB |
Output is correct |
26 |
Correct |
16 ms |
4548 KB |
Output is correct |
27 |
Correct |
668 ms |
87868 KB |
Output is correct |
28 |
Correct |
8 ms |
15996 KB |
Output is correct |
29 |
Correct |
38 ms |
4648 KB |
Output is correct |
30 |
Correct |
2 ms |
552 KB |
Output is correct |
31 |
Correct |
495 ms |
72548 KB |
Output is correct |
32 |
Correct |
569 ms |
66196 KB |
Output is correct |
33 |
Correct |
590 ms |
53296 KB |
Output is correct |
34 |
Correct |
578 ms |
84004 KB |
Output is correct |
35 |
Correct |
621 ms |
71864 KB |
Output is correct |
36 |
Correct |
601 ms |
53268 KB |
Output is correct |
37 |
Correct |
713 ms |
88360 KB |
Output is correct |
38 |
Correct |
436 ms |
50160 KB |
Output is correct |
39 |
Correct |
400 ms |
39840 KB |
Output is correct |