#include <bits/stdc++.h>
using namespace std;
int vals[3005][3005];
int oscores[3005][3005];
bool iexist[3005];
bool jexist[3005];
int main() {
ios_base::sync_with_stdio(NULL);
cin.tie(0);
int I, J;
cin >> I >> J;
for (int i = 1; i <= I; i++) {
for (int j = 1; j <= J; j++) {
char v;
cin >> v;
if (v == 'J') {
vals[i][j] = 1;
iexist[i] = true;
jexist[i] = true;
} else if (v == 'I') {
vals[i][j] = 2;
} else {
vals[i][j] = 3;
}
}
}
for (int i = I - 1; i > 0; i--) {
if (!iexist[i]) continue;
int oscore = 0;
for (int j = J; j > 0; j--) {
if (vals[i][j] == 3) {
oscore++;
}
oscores[i][j] = oscore;
}
}
// for (int i = 1; i <= I; i++) {
// for (int j = 1; j <= J; j++) {
// cout << oscores[i][j];
// }
// cout << endl;
// }
int possibilities = 0;
for (int j = J - 1; j > 0; j--) {
if (!jexist[j]) continue;
int iscore = 0;
for (int i = I; i > 0; i--) {
if (vals[i][j] == 2) {
iscore++;
}
if (vals[i][j] == 1) {
possibilities += iscore * oscores[i][j];
}
}
}
cout << possibilities << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1108 KB |
Output is correct |
6 |
Correct |
1 ms |
1108 KB |
Output is correct |
7 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1108 KB |
Output is correct |
6 |
Correct |
1 ms |
1108 KB |
Output is correct |
7 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
1108 KB |
Output is correct |
6 |
Correct |
1 ms |
1108 KB |
Output is correct |
7 |
Incorrect |
1 ms |
1108 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |