#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define vl vector < ll >
#define pi pair < int, int >
#define pii pair < int, pi >
#define vii vector < pi >
const int N = 3007;
const int INF = 1e9 + 7;
char a[N][N];
int orb[N][N], ing[N][N];
int n, m;
ll ans;
main(){
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> a[i][j];
for (int i = 1; i <= n; i++){
for (int j = m; j >= 1; j--){
orb[i][j] = orb[i][j + 1];
if (a[i][j] == 'O')
orb[i][j]++;
}
}
for (int j = 1; j <= m; j++){
for (int i = n; i >= 1; i--){
ing[i][j] = ing[i + 1][j];
if (a[i][j] == 'I')
ing[i][j]++;
}
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (a[i][j] == 'J')
ans += (ll) orb[i][j] * ing[i][j];
cout << ans;
}
Compilation message
joi2019_ho_t1.cpp:24:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
408 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
5 ms |
1536 KB |
Output is correct |
6 |
Correct |
5 ms |
1536 KB |
Output is correct |
7 |
Correct |
3 ms |
1408 KB |
Output is correct |
8 |
Correct |
5 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1380 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
408 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
5 ms |
1536 KB |
Output is correct |
6 |
Correct |
5 ms |
1536 KB |
Output is correct |
7 |
Correct |
3 ms |
1408 KB |
Output is correct |
8 |
Correct |
5 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1380 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
14 |
Correct |
22 ms |
7552 KB |
Output is correct |
15 |
Correct |
8 ms |
4992 KB |
Output is correct |
16 |
Correct |
15 ms |
4352 KB |
Output is correct |
17 |
Correct |
3 ms |
512 KB |
Output is correct |
18 |
Correct |
37 ms |
8016 KB |
Output is correct |
19 |
Correct |
28 ms |
8060 KB |
Output is correct |
20 |
Correct |
26 ms |
7876 KB |
Output is correct |
21 |
Correct |
27 ms |
8184 KB |
Output is correct |
22 |
Correct |
25 ms |
7928 KB |
Output is correct |
23 |
Correct |
26 ms |
7900 KB |
Output is correct |
24 |
Correct |
26 ms |
8056 KB |
Output is correct |
25 |
Correct |
27 ms |
7928 KB |
Output is correct |
26 |
Correct |
26 ms |
7800 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
408 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
5 ms |
1536 KB |
Output is correct |
6 |
Correct |
5 ms |
1536 KB |
Output is correct |
7 |
Correct |
3 ms |
1408 KB |
Output is correct |
8 |
Correct |
5 ms |
1536 KB |
Output is correct |
9 |
Correct |
4 ms |
1536 KB |
Output is correct |
10 |
Correct |
4 ms |
1380 KB |
Output is correct |
11 |
Correct |
4 ms |
1536 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
14 |
Correct |
22 ms |
7552 KB |
Output is correct |
15 |
Correct |
8 ms |
4992 KB |
Output is correct |
16 |
Correct |
15 ms |
4352 KB |
Output is correct |
17 |
Correct |
3 ms |
512 KB |
Output is correct |
18 |
Correct |
37 ms |
8016 KB |
Output is correct |
19 |
Correct |
28 ms |
8060 KB |
Output is correct |
20 |
Correct |
26 ms |
7876 KB |
Output is correct |
21 |
Correct |
27 ms |
8184 KB |
Output is correct |
22 |
Correct |
25 ms |
7928 KB |
Output is correct |
23 |
Correct |
26 ms |
7900 KB |
Output is correct |
24 |
Correct |
26 ms |
8056 KB |
Output is correct |
25 |
Correct |
27 ms |
7928 KB |
Output is correct |
26 |
Correct |
26 ms |
7800 KB |
Output is correct |
27 |
Correct |
907 ms |
88184 KB |
Output is correct |
28 |
Correct |
29 ms |
26104 KB |
Output is correct |
29 |
Correct |
46 ms |
7800 KB |
Output is correct |
30 |
Correct |
4 ms |
640 KB |
Output is correct |
31 |
Correct |
703 ms |
72960 KB |
Output is correct |
32 |
Correct |
840 ms |
88788 KB |
Output is correct |
33 |
Correct |
826 ms |
88416 KB |
Output is correct |
34 |
Correct |
696 ms |
84412 KB |
Output is correct |
35 |
Correct |
839 ms |
88604 KB |
Output is correct |
36 |
Correct |
790 ms |
88480 KB |
Output is correct |
37 |
Correct |
980 ms |
88812 KB |
Output is correct |
38 |
Correct |
590 ms |
72780 KB |
Output is correct |
39 |
Correct |
598 ms |
72568 KB |
Output is correct |