// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
char a[3005][3005];
pair<int,int> x[3005][3005];
int main() {
// Write C++ code here
int n, m;
long long k = 0ll;
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> a[i][j];
}
}
for(int i = n; i; i--){
for(int j = m; j; j--){
x[i][j].first = x[i+1][j].first;
x[i][j].second = x[i][j+1].second;
if(a[i][j] == 'I')x[i][j].first++;
if(a[i][j] == 'O')x[i][j].second++;
if(a[i][j] == 'J')k += x[i][j].first * x[i][j].second;
}
}
cout << k;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1108 KB |
Output is correct |
6 |
Correct |
2 ms |
992 KB |
Output is correct |
7 |
Correct |
1 ms |
956 KB |
Output is correct |
8 |
Correct |
2 ms |
1108 KB |
Output is correct |
9 |
Correct |
1 ms |
980 KB |
Output is correct |
10 |
Correct |
2 ms |
964 KB |
Output is correct |
11 |
Correct |
2 ms |
1108 KB |
Output is correct |
12 |
Correct |
2 ms |
980 KB |
Output is correct |
13 |
Correct |
2 ms |
956 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1108 KB |
Output is correct |
6 |
Correct |
2 ms |
992 KB |
Output is correct |
7 |
Correct |
1 ms |
956 KB |
Output is correct |
8 |
Correct |
2 ms |
1108 KB |
Output is correct |
9 |
Correct |
1 ms |
980 KB |
Output is correct |
10 |
Correct |
2 ms |
964 KB |
Output is correct |
11 |
Correct |
2 ms |
1108 KB |
Output is correct |
12 |
Correct |
2 ms |
980 KB |
Output is correct |
13 |
Correct |
2 ms |
956 KB |
Output is correct |
14 |
Correct |
15 ms |
5404 KB |
Output is correct |
15 |
Correct |
3 ms |
3284 KB |
Output is correct |
16 |
Correct |
11 ms |
3224 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
20 ms |
5912 KB |
Output is correct |
19 |
Correct |
19 ms |
5816 KB |
Output is correct |
20 |
Correct |
18 ms |
5868 KB |
Output is correct |
21 |
Correct |
20 ms |
5936 KB |
Output is correct |
22 |
Correct |
19 ms |
5800 KB |
Output is correct |
23 |
Correct |
19 ms |
5832 KB |
Output is correct |
24 |
Correct |
20 ms |
5940 KB |
Output is correct |
25 |
Correct |
18 ms |
5860 KB |
Output is correct |
26 |
Correct |
17 ms |
5812 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
312 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
1108 KB |
Output is correct |
6 |
Correct |
2 ms |
992 KB |
Output is correct |
7 |
Correct |
1 ms |
956 KB |
Output is correct |
8 |
Correct |
2 ms |
1108 KB |
Output is correct |
9 |
Correct |
1 ms |
980 KB |
Output is correct |
10 |
Correct |
2 ms |
964 KB |
Output is correct |
11 |
Correct |
2 ms |
1108 KB |
Output is correct |
12 |
Correct |
2 ms |
980 KB |
Output is correct |
13 |
Correct |
2 ms |
956 KB |
Output is correct |
14 |
Correct |
15 ms |
5404 KB |
Output is correct |
15 |
Correct |
3 ms |
3284 KB |
Output is correct |
16 |
Correct |
11 ms |
3224 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
20 ms |
5912 KB |
Output is correct |
19 |
Correct |
19 ms |
5816 KB |
Output is correct |
20 |
Correct |
18 ms |
5868 KB |
Output is correct |
21 |
Correct |
20 ms |
5936 KB |
Output is correct |
22 |
Correct |
19 ms |
5800 KB |
Output is correct |
23 |
Correct |
19 ms |
5832 KB |
Output is correct |
24 |
Correct |
20 ms |
5940 KB |
Output is correct |
25 |
Correct |
18 ms |
5860 KB |
Output is correct |
26 |
Correct |
17 ms |
5812 KB |
Output is correct |
27 |
Correct |
561 ms |
81464 KB |
Output is correct |
28 |
Correct |
12 ms |
16724 KB |
Output is correct |
29 |
Correct |
43 ms |
7756 KB |
Output is correct |
30 |
Correct |
3 ms |
484 KB |
Output is correct |
31 |
Correct |
392 ms |
68372 KB |
Output is correct |
32 |
Correct |
543 ms |
81928 KB |
Output is correct |
33 |
Correct |
547 ms |
81672 KB |
Output is correct |
34 |
Correct |
454 ms |
78908 KB |
Output is correct |
35 |
Correct |
537 ms |
82012 KB |
Output is correct |
36 |
Correct |
559 ms |
81744 KB |
Output is correct |
37 |
Correct |
570 ms |
82064 KB |
Output is correct |
38 |
Correct |
366 ms |
67952 KB |
Output is correct |
39 |
Correct |
377 ms |
68200 KB |
Output is correct |