#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
int nbLigs, nbCols;
cin >> nbLigs >> nbCols;
vector<string> tab(nbLigs);
for(int iL =0; iL < nbLigs; iL++)
{
cin >>tab[iL];
}
vector<vector<int>>cumulBotToTop(nbLigs+1, vector<int>(nbCols+1, 0));
vector<vector<int>>cumulRightToLeft(nbLigs+1, vector<int>(nbCols+1, 0));
for(int iL = nbLigs-1; iL >=0; iL--)
{
for(int iC = nbCols-1; iC >= 0; iC--)
{
cumulRightToLeft[iL][iC] = cumulRightToLeft[iL][iC+1];
if(tab[iL][iC] == 'O')
cumulRightToLeft[iL][iC]++;
}
}
for(int iC = nbCols-1; iC >= 0; iC--)
{
for(int iL = nbLigs-1; iL >=0; iL--)
{
cumulBotToTop[iL][iC] = cumulBotToTop[iL+1][iC];
if(tab[iL][iC] == 'I')
cumulBotToTop[iL][iC]++;
}
}
int ans = 0;
for(int iL = 0; iL < nbLigs; iL++)
{
for(int iC = 0; iC < nbCols; iC++)
{
if(tab[iL][iC] == 'J')
{
ans += cumulBotToTop[iL][iC] * cumulRightToLeft[iL][iC];
}
}
}
printf("%lld\n", ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
440 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
440 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
440 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
440 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
6 ms |
3928 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
4 ms |
2652 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
8 ms |
4952 KB |
Output is correct |
19 |
Correct |
7 ms |
4700 KB |
Output is correct |
20 |
Correct |
7 ms |
5000 KB |
Output is correct |
21 |
Correct |
9 ms |
4956 KB |
Output is correct |
22 |
Correct |
7 ms |
4700 KB |
Output is correct |
23 |
Correct |
7 ms |
4952 KB |
Output is correct |
24 |
Correct |
10 ms |
5720 KB |
Output is correct |
25 |
Correct |
7 ms |
4700 KB |
Output is correct |
26 |
Correct |
7 ms |
4956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
440 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
440 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
6 ms |
3928 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
4 ms |
2652 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
8 ms |
4952 KB |
Output is correct |
19 |
Correct |
7 ms |
4700 KB |
Output is correct |
20 |
Correct |
7 ms |
5000 KB |
Output is correct |
21 |
Correct |
9 ms |
4956 KB |
Output is correct |
22 |
Correct |
7 ms |
4700 KB |
Output is correct |
23 |
Correct |
7 ms |
4952 KB |
Output is correct |
24 |
Correct |
10 ms |
5720 KB |
Output is correct |
25 |
Correct |
7 ms |
4700 KB |
Output is correct |
26 |
Correct |
7 ms |
4956 KB |
Output is correct |
27 |
Correct |
394 ms |
153552 KB |
Output is correct |
28 |
Correct |
1 ms |
1368 KB |
Output is correct |
29 |
Correct |
20 ms |
12120 KB |
Output is correct |
30 |
Correct |
2 ms |
860 KB |
Output is correct |
31 |
Correct |
279 ms |
114068 KB |
Output is correct |
32 |
Correct |
376 ms |
160596 KB |
Output is correct |
33 |
Correct |
360 ms |
161108 KB |
Output is correct |
34 |
Correct |
316 ms |
132180 KB |
Output is correct |
35 |
Correct |
394 ms |
160848 KB |
Output is correct |
36 |
Correct |
369 ms |
161292 KB |
Output is correct |
37 |
Correct |
421 ms |
161844 KB |
Output is correct |
38 |
Correct |
264 ms |
113316 KB |
Output is correct |
39 |
Correct |
271 ms |
113504 KB |
Output is correct |