#include <iostream>
using namespace std;
int nbO[3001][3001];
int nbI[3001][3001];
string terrain[3000];
int main() {
ios_base::sync_with_stdio(false);
int nbLigs, nbCols;
cin >> nbLigs >> nbCols;
for(int iLig = 0;iLig < nbLigs;iLig++) {
cin >> terrain[iLig];
}
for(int iLig = 0;iLig < nbLigs;iLig++) {
for(int iCol = nbCols - 1;iCol >= 0;iCol--) {
nbO[iLig][iCol] = nbO[iLig][iCol + 1] + (terrain[iLig][iCol] == 'O');
}
}
for(int iCol = 0;iCol < nbCols;iCol++) {
for(int iLig = nbLigs - 1;iLig >= 0;iLig--) {
nbI[iLig][iCol] = nbI[iLig + 1][iCol] + (terrain[iLig][iCol] == 'I');
}
}
long long total = 0;
for(int iLig = 0;iLig < nbLigs;iLig++) {
for(int iCol = 0;iCol < nbCols;iCol++) {
if(terrain[iLig][iCol] == 'J') {
total += nbO[iLig][iCol] * (long long) nbI[iLig][iCol];
}
}
}
cout << total << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
3 ms |
512 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1280 KB |
Output is correct |
6 |
Correct |
4 ms |
1280 KB |
Output is correct |
7 |
Correct |
3 ms |
1280 KB |
Output is correct |
8 |
Correct |
3 ms |
1280 KB |
Output is correct |
9 |
Correct |
3 ms |
1280 KB |
Output is correct |
10 |
Correct |
3 ms |
1280 KB |
Output is correct |
11 |
Correct |
3 ms |
1408 KB |
Output is correct |
12 |
Correct |
3 ms |
1280 KB |
Output is correct |
13 |
Correct |
3 ms |
1280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
3 ms |
512 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1280 KB |
Output is correct |
6 |
Correct |
4 ms |
1280 KB |
Output is correct |
7 |
Correct |
3 ms |
1280 KB |
Output is correct |
8 |
Correct |
3 ms |
1280 KB |
Output is correct |
9 |
Correct |
3 ms |
1280 KB |
Output is correct |
10 |
Correct |
3 ms |
1280 KB |
Output is correct |
11 |
Correct |
3 ms |
1408 KB |
Output is correct |
12 |
Correct |
3 ms |
1280 KB |
Output is correct |
13 |
Correct |
3 ms |
1280 KB |
Output is correct |
14 |
Correct |
10 ms |
6272 KB |
Output is correct |
15 |
Correct |
5 ms |
3840 KB |
Output is correct |
16 |
Correct |
7 ms |
3840 KB |
Output is correct |
17 |
Correct |
3 ms |
640 KB |
Output is correct |
18 |
Correct |
12 ms |
6912 KB |
Output is correct |
19 |
Correct |
10 ms |
6784 KB |
Output is correct |
20 |
Correct |
19 ms |
6804 KB |
Output is correct |
21 |
Correct |
10 ms |
6912 KB |
Output is correct |
22 |
Correct |
11 ms |
6784 KB |
Output is correct |
23 |
Correct |
12 ms |
6804 KB |
Output is correct |
24 |
Correct |
14 ms |
6912 KB |
Output is correct |
25 |
Correct |
10 ms |
6784 KB |
Output is correct |
26 |
Correct |
11 ms |
6784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
3 ms |
512 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
1280 KB |
Output is correct |
6 |
Correct |
4 ms |
1280 KB |
Output is correct |
7 |
Correct |
3 ms |
1280 KB |
Output is correct |
8 |
Correct |
3 ms |
1280 KB |
Output is correct |
9 |
Correct |
3 ms |
1280 KB |
Output is correct |
10 |
Correct |
3 ms |
1280 KB |
Output is correct |
11 |
Correct |
3 ms |
1408 KB |
Output is correct |
12 |
Correct |
3 ms |
1280 KB |
Output is correct |
13 |
Correct |
3 ms |
1280 KB |
Output is correct |
14 |
Correct |
10 ms |
6272 KB |
Output is correct |
15 |
Correct |
5 ms |
3840 KB |
Output is correct |
16 |
Correct |
7 ms |
3840 KB |
Output is correct |
17 |
Correct |
3 ms |
640 KB |
Output is correct |
18 |
Correct |
12 ms |
6912 KB |
Output is correct |
19 |
Correct |
10 ms |
6784 KB |
Output is correct |
20 |
Correct |
19 ms |
6804 KB |
Output is correct |
21 |
Correct |
10 ms |
6912 KB |
Output is correct |
22 |
Correct |
11 ms |
6784 KB |
Output is correct |
23 |
Correct |
12 ms |
6804 KB |
Output is correct |
24 |
Correct |
14 ms |
6912 KB |
Output is correct |
25 |
Correct |
10 ms |
6784 KB |
Output is correct |
26 |
Correct |
11 ms |
6784 KB |
Output is correct |
27 |
Correct |
334 ms |
80224 KB |
Output is correct |
28 |
Correct |
20 ms |
19328 KB |
Output is correct |
29 |
Correct |
14 ms |
7424 KB |
Output is correct |
30 |
Correct |
6 ms |
640 KB |
Output is correct |
31 |
Correct |
235 ms |
66168 KB |
Output is correct |
32 |
Correct |
311 ms |
80720 KB |
Output is correct |
33 |
Correct |
309 ms |
80632 KB |
Output is correct |
34 |
Correct |
261 ms |
76432 KB |
Output is correct |
35 |
Correct |
301 ms |
80796 KB |
Output is correct |
36 |
Correct |
347 ms |
80796 KB |
Output is correct |
37 |
Correct |
343 ms |
80908 KB |
Output is correct |
38 |
Correct |
233 ms |
66040 KB |
Output is correct |
39 |
Correct |
211 ms |
65784 KB |
Output is correct |