#include <iostream>
using namespace std;
#define int long long
#define MAX 3100
string s[MAX];
int h, w, v1[MAX][MAX], v2[MAX][MAX];
main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> h >> w;
for(int i = 0; i < h; i++)
cin >> s[i];
int qt = 0;
for(int j = 0; j < w; j++){
qt = 0;
for(int i = h-1; i >= 0; i--){
v1[i][j] += qt;
if(s[i][j] == 'I'){
qt++;
}
}
}
for(int i = 0; i < h; i++){
qt = 0;
for(int j = w-1; j >= 0; j--){
v2[i][j] += qt;
if(s[i][j] == 'O'){
qt++;
}
}
}
int ans = 0;
for(int i = 0; i < h; i++){
for(int j = 0; j < w; j++){
if(s[i][j] == 'J'){
ans += v1[i][j]*v2[i][j];
}
}
}
cout << ans << "\n";
return 0;
}
Compilation message
joi2019_ho_t1.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1408 KB |
Output is correct |
6 |
Correct |
3 ms |
1408 KB |
Output is correct |
7 |
Correct |
4 ms |
1452 KB |
Output is correct |
8 |
Correct |
4 ms |
1408 KB |
Output is correct |
9 |
Correct |
1 ms |
1408 KB |
Output is correct |
10 |
Correct |
4 ms |
1280 KB |
Output is correct |
11 |
Correct |
3 ms |
1408 KB |
Output is correct |
12 |
Correct |
3 ms |
1408 KB |
Output is correct |
13 |
Correct |
3 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1408 KB |
Output is correct |
6 |
Correct |
3 ms |
1408 KB |
Output is correct |
7 |
Correct |
4 ms |
1452 KB |
Output is correct |
8 |
Correct |
4 ms |
1408 KB |
Output is correct |
9 |
Correct |
1 ms |
1408 KB |
Output is correct |
10 |
Correct |
4 ms |
1280 KB |
Output is correct |
11 |
Correct |
3 ms |
1408 KB |
Output is correct |
12 |
Correct |
3 ms |
1408 KB |
Output is correct |
13 |
Correct |
3 ms |
1280 KB |
Output is correct |
14 |
Correct |
9 ms |
7680 KB |
Output is correct |
15 |
Correct |
5 ms |
3968 KB |
Output is correct |
16 |
Correct |
6 ms |
4736 KB |
Output is correct |
17 |
Correct |
3 ms |
640 KB |
Output is correct |
18 |
Correct |
12 ms |
8704 KB |
Output is correct |
19 |
Correct |
19 ms |
8448 KB |
Output is correct |
20 |
Correct |
13 ms |
8448 KB |
Output is correct |
21 |
Correct |
11 ms |
8704 KB |
Output is correct |
22 |
Correct |
11 ms |
8444 KB |
Output is correct |
23 |
Correct |
12 ms |
8448 KB |
Output is correct |
24 |
Correct |
11 ms |
8704 KB |
Output is correct |
25 |
Correct |
10 ms |
8448 KB |
Output is correct |
26 |
Correct |
11 ms |
8448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1408 KB |
Output is correct |
6 |
Correct |
3 ms |
1408 KB |
Output is correct |
7 |
Correct |
4 ms |
1452 KB |
Output is correct |
8 |
Correct |
4 ms |
1408 KB |
Output is correct |
9 |
Correct |
1 ms |
1408 KB |
Output is correct |
10 |
Correct |
4 ms |
1280 KB |
Output is correct |
11 |
Correct |
3 ms |
1408 KB |
Output is correct |
12 |
Correct |
3 ms |
1408 KB |
Output is correct |
13 |
Correct |
3 ms |
1280 KB |
Output is correct |
14 |
Correct |
9 ms |
7680 KB |
Output is correct |
15 |
Correct |
5 ms |
3968 KB |
Output is correct |
16 |
Correct |
6 ms |
4736 KB |
Output is correct |
17 |
Correct |
3 ms |
640 KB |
Output is correct |
18 |
Correct |
12 ms |
8704 KB |
Output is correct |
19 |
Correct |
19 ms |
8448 KB |
Output is correct |
20 |
Correct |
13 ms |
8448 KB |
Output is correct |
21 |
Correct |
11 ms |
8704 KB |
Output is correct |
22 |
Correct |
11 ms |
8444 KB |
Output is correct |
23 |
Correct |
12 ms |
8448 KB |
Output is correct |
24 |
Correct |
11 ms |
8704 KB |
Output is correct |
25 |
Correct |
10 ms |
8448 KB |
Output is correct |
26 |
Correct |
11 ms |
8448 KB |
Output is correct |
27 |
Correct |
371 ms |
155208 KB |
Output is correct |
28 |
Correct |
16 ms |
19456 KB |
Output is correct |
29 |
Correct |
17 ms |
13312 KB |
Output is correct |
30 |
Correct |
2 ms |
896 KB |
Output is correct |
31 |
Correct |
275 ms |
124792 KB |
Output is correct |
32 |
Correct |
334 ms |
155640 KB |
Output is correct |
33 |
Correct |
345 ms |
155356 KB |
Output is correct |
34 |
Correct |
312 ms |
144760 KB |
Output is correct |
35 |
Correct |
419 ms |
155832 KB |
Output is correct |
36 |
Correct |
375 ms |
155224 KB |
Output is correct |
37 |
Correct |
436 ms |
155824 KB |
Output is correct |
38 |
Correct |
275 ms |
124152 KB |
Output is correct |
39 |
Correct |
231 ms |
124484 KB |
Output is correct |