#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] * cumulBotToTop[iL][iC];
}
}
}
printf("%lld\n", ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |