import java.io.*;
import java.util.StringTokenizer;
public class joi2019_ho_t1 {
static BufferedReader fin = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
public static void main(String[] args) throws IOException {
st = new StringTokenizer(fin.readLine());
int H = Integer.parseInt(st.nextToken());
int W = Integer.parseInt(st.nextToken());
char[][] board = new char[H][W];
for (int i = 0; i < H; i++) {
board[i] = new StringTokenizer(fin.readLine()).nextToken().toCharArray();
}
int[] countI = new int[W];
int[] countO = new int[H];
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (board[i][j] == 'O') {
countO[i]++;
}
else if (board[i][j] == 'I') {
countI[j]++;
}
}
}
long res = 0;
for (int i = 0; i < H; i++) {
for (int j = 0; j < W; j++) {
if (board[i][j] == 'J') {
res += countI[j]*countO[i];
}
else if (board[i][j] == 'O') {
countO[i]--;
}
else {
countI[j]--;
}
}
}
PrintWriter out = new PrintWriter(System.out);
out.println(res);
out.close();
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
10384 KB |
Output is correct |
2 |
Correct |
92 ms |
10544 KB |
Output is correct |
3 |
Correct |
89 ms |
10360 KB |
Output is correct |
4 |
Correct |
88 ms |
10252 KB |
Output is correct |
5 |
Correct |
92 ms |
10176 KB |
Output is correct |
6 |
Correct |
95 ms |
10460 KB |
Output is correct |
7 |
Correct |
89 ms |
10368 KB |
Output is correct |
8 |
Correct |
102 ms |
10492 KB |
Output is correct |
9 |
Correct |
100 ms |
10468 KB |
Output is correct |
10 |
Correct |
97 ms |
10488 KB |
Output is correct |
11 |
Correct |
98 ms |
10436 KB |
Output is correct |
12 |
Correct |
90 ms |
10576 KB |
Output is correct |
13 |
Correct |
91 ms |
10496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
10384 KB |
Output is correct |
2 |
Correct |
92 ms |
10544 KB |
Output is correct |
3 |
Correct |
89 ms |
10360 KB |
Output is correct |
4 |
Correct |
88 ms |
10252 KB |
Output is correct |
5 |
Correct |
92 ms |
10176 KB |
Output is correct |
6 |
Correct |
95 ms |
10460 KB |
Output is correct |
7 |
Correct |
89 ms |
10368 KB |
Output is correct |
8 |
Correct |
102 ms |
10492 KB |
Output is correct |
9 |
Correct |
100 ms |
10468 KB |
Output is correct |
10 |
Correct |
97 ms |
10488 KB |
Output is correct |
11 |
Correct |
98 ms |
10436 KB |
Output is correct |
12 |
Correct |
90 ms |
10576 KB |
Output is correct |
13 |
Correct |
91 ms |
10496 KB |
Output is correct |
14 |
Correct |
162 ms |
15208 KB |
Output is correct |
15 |
Correct |
96 ms |
10604 KB |
Output is correct |
16 |
Correct |
143 ms |
13780 KB |
Output is correct |
17 |
Correct |
88 ms |
10372 KB |
Output is correct |
18 |
Correct |
173 ms |
15488 KB |
Output is correct |
19 |
Correct |
175 ms |
15760 KB |
Output is correct |
20 |
Correct |
169 ms |
15764 KB |
Output is correct |
21 |
Correct |
179 ms |
15672 KB |
Output is correct |
22 |
Correct |
175 ms |
15720 KB |
Output is correct |
23 |
Correct |
172 ms |
15552 KB |
Output is correct |
24 |
Correct |
180 ms |
15848 KB |
Output is correct |
25 |
Correct |
170 ms |
15848 KB |
Output is correct |
26 |
Correct |
166 ms |
15096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
10384 KB |
Output is correct |
2 |
Correct |
92 ms |
10544 KB |
Output is correct |
3 |
Correct |
89 ms |
10360 KB |
Output is correct |
4 |
Correct |
88 ms |
10252 KB |
Output is correct |
5 |
Correct |
92 ms |
10176 KB |
Output is correct |
6 |
Correct |
95 ms |
10460 KB |
Output is correct |
7 |
Correct |
89 ms |
10368 KB |
Output is correct |
8 |
Correct |
102 ms |
10492 KB |
Output is correct |
9 |
Correct |
100 ms |
10468 KB |
Output is correct |
10 |
Correct |
97 ms |
10488 KB |
Output is correct |
11 |
Correct |
98 ms |
10436 KB |
Output is correct |
12 |
Correct |
90 ms |
10576 KB |
Output is correct |
13 |
Correct |
91 ms |
10496 KB |
Output is correct |
14 |
Correct |
162 ms |
15208 KB |
Output is correct |
15 |
Correct |
96 ms |
10604 KB |
Output is correct |
16 |
Correct |
143 ms |
13780 KB |
Output is correct |
17 |
Correct |
88 ms |
10372 KB |
Output is correct |
18 |
Correct |
173 ms |
15488 KB |
Output is correct |
19 |
Correct |
175 ms |
15760 KB |
Output is correct |
20 |
Correct |
169 ms |
15764 KB |
Output is correct |
21 |
Correct |
179 ms |
15672 KB |
Output is correct |
22 |
Correct |
175 ms |
15720 KB |
Output is correct |
23 |
Correct |
172 ms |
15552 KB |
Output is correct |
24 |
Correct |
180 ms |
15848 KB |
Output is correct |
25 |
Correct |
170 ms |
15848 KB |
Output is correct |
26 |
Correct |
166 ms |
15096 KB |
Output is correct |
27 |
Execution timed out |
1798 ms |
63780 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |