#include <bits/stdc++.h>
#define mk make_pair
#define sc second
#define fr first
#define pb emplace_back
#define all(s) s.begin(), s.end()
#define sz(s) ( (int)s.size() )
#define int long long
using namespace std;
const int inf = (int)1e9 + 7 ;
const long long mod = 1e9 + 7;
const int N = (int)3007;
int n, m;
char ch[N][N];
int jo[N][N], joop[N][N];
main(){
cin >> n >> m;
for(int i = 1;i <= n; i++){
int cnt = 0;
for(int j = 1;j <= m; j++){
cin >> ch[i][j];
cnt += (ch[i][j] == 'O');
}
for(int j = 1;j <= m; j++){
if(ch[i][j] == 'J'){
jo[i][j] = cnt;
}
cnt -= (ch[i][j] == 'O');
}
}
for(int j = 1;j <= m; j++){
for(int i = 1;i <= n; i++){
joop[i][j] = joop[i - 1][j] + jo[i][j];
}
}
int ans = 0;
for(int i = 1;i <= n; i++){
for(int j = 1;j <= m; j++){
if(ch[i][j] == 'I'){
ans += joop[i][j];
}
}
}
cout << ans;
}
Compilation message
joi2019_ho_t1.cpp:20:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 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 |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
3 ms |
1408 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 |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1664 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 |
2 ms |
384 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 |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
3 ms |
1408 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 |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1664 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
14 |
Correct |
25 ms |
9052 KB |
Output is correct |
15 |
Correct |
7 ms |
4864 KB |
Output is correct |
16 |
Correct |
19 ms |
4864 KB |
Output is correct |
17 |
Correct |
3 ms |
512 KB |
Output is correct |
18 |
Correct |
32 ms |
9976 KB |
Output is correct |
19 |
Correct |
28 ms |
8960 KB |
Output is correct |
20 |
Correct |
28 ms |
8448 KB |
Output is correct |
21 |
Correct |
41 ms |
9976 KB |
Output is correct |
22 |
Correct |
35 ms |
9336 KB |
Output is correct |
23 |
Correct |
32 ms |
8568 KB |
Output is correct |
24 |
Correct |
32 ms |
9976 KB |
Output is correct |
25 |
Correct |
32 ms |
8952 KB |
Output is correct |
26 |
Correct |
31 ms |
8568 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 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 |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
1536 KB |
Output is correct |
6 |
Correct |
3 ms |
1408 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 |
3 ms |
1408 KB |
Output is correct |
11 |
Correct |
5 ms |
1664 KB |
Output is correct |
12 |
Correct |
4 ms |
1536 KB |
Output is correct |
13 |
Correct |
4 ms |
1408 KB |
Output is correct |
14 |
Correct |
25 ms |
9052 KB |
Output is correct |
15 |
Correct |
7 ms |
4864 KB |
Output is correct |
16 |
Correct |
19 ms |
4864 KB |
Output is correct |
17 |
Correct |
3 ms |
512 KB |
Output is correct |
18 |
Correct |
32 ms |
9976 KB |
Output is correct |
19 |
Correct |
28 ms |
8960 KB |
Output is correct |
20 |
Correct |
28 ms |
8448 KB |
Output is correct |
21 |
Correct |
41 ms |
9976 KB |
Output is correct |
22 |
Correct |
35 ms |
9336 KB |
Output is correct |
23 |
Correct |
32 ms |
8568 KB |
Output is correct |
24 |
Correct |
32 ms |
9976 KB |
Output is correct |
25 |
Correct |
32 ms |
8952 KB |
Output is correct |
26 |
Correct |
31 ms |
8568 KB |
Output is correct |
27 |
Correct |
918 ms |
158868 KB |
Output is correct |
28 |
Correct |
24 ms |
25600 KB |
Output is correct |
29 |
Correct |
56 ms |
10872 KB |
Output is correct |
30 |
Correct |
4 ms |
896 KB |
Output is correct |
31 |
Correct |
767 ms |
131588 KB |
Output is correct |
32 |
Execution timed out |
1052 ms |
137080 KB |
Time limit exceeded |
33 |
Halted |
0 ms |
0 KB |
- |