#include <bits/stdc++.h>
using namespace std;
const int NMAX = 3069;
int vals[NMAX][NMAX];
int oscores[NMAX][NMAX];
bool iexist[NMAX];
bool jexist[NMAX];
int main() {
int I, J;
cin >> I >> J;
for (int i = 0; i < NMAX; i++) {
iexist[i] = false;
jexist[i] = false;
}
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[j] = 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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
236 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 |
980 KB |
Output is correct |
7 |
Correct |
1 ms |
980 KB |
Output is correct |
8 |
Correct |
1 ms |
1108 KB |
Output is correct |
9 |
Correct |
1 ms |
1108 KB |
Output is correct |
10 |
Correct |
1 ms |
980 KB |
Output is correct |
11 |
Correct |
1 ms |
1108 KB |
Output is correct |
12 |
Correct |
1 ms |
1108 KB |
Output is correct |
13 |
Correct |
1 ms |
980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
236 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 |
980 KB |
Output is correct |
7 |
Correct |
1 ms |
980 KB |
Output is correct |
8 |
Correct |
1 ms |
1108 KB |
Output is correct |
9 |
Correct |
1 ms |
1108 KB |
Output is correct |
10 |
Correct |
1 ms |
980 KB |
Output is correct |
11 |
Correct |
1 ms |
1108 KB |
Output is correct |
12 |
Correct |
1 ms |
1108 KB |
Output is correct |
13 |
Correct |
1 ms |
980 KB |
Output is correct |
14 |
Correct |
12 ms |
5972 KB |
Output is correct |
15 |
Correct |
1 ms |
3540 KB |
Output is correct |
16 |
Correct |
6 ms |
3356 KB |
Output is correct |
17 |
Correct |
0 ms |
468 KB |
Output is correct |
18 |
Correct |
16 ms |
6612 KB |
Output is correct |
19 |
Correct |
11 ms |
6356 KB |
Output is correct |
20 |
Incorrect |
11 ms |
6444 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
236 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 |
980 KB |
Output is correct |
7 |
Correct |
1 ms |
980 KB |
Output is correct |
8 |
Correct |
1 ms |
1108 KB |
Output is correct |
9 |
Correct |
1 ms |
1108 KB |
Output is correct |
10 |
Correct |
1 ms |
980 KB |
Output is correct |
11 |
Correct |
1 ms |
1108 KB |
Output is correct |
12 |
Correct |
1 ms |
1108 KB |
Output is correct |
13 |
Correct |
1 ms |
980 KB |
Output is correct |
14 |
Correct |
12 ms |
5972 KB |
Output is correct |
15 |
Correct |
1 ms |
3540 KB |
Output is correct |
16 |
Correct |
6 ms |
3356 KB |
Output is correct |
17 |
Correct |
0 ms |
468 KB |
Output is correct |
18 |
Correct |
16 ms |
6612 KB |
Output is correct |
19 |
Correct |
11 ms |
6356 KB |
Output is correct |
20 |
Incorrect |
11 ms |
6444 KB |
Output isn't correct |
21 |
Halted |
0 ms |
0 KB |
- |