import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
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] = fin.readLine().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]--;
}
}
}
System.out.println(res);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
86 ms |
10368 KB |
Output is correct |
2 |
Correct |
87 ms |
10104 KB |
Output is correct |
3 |
Correct |
89 ms |
10232 KB |
Output is correct |
4 |
Correct |
116 ms |
10344 KB |
Output is correct |
5 |
Correct |
92 ms |
10580 KB |
Output is correct |
6 |
Correct |
88 ms |
10400 KB |
Output is correct |
7 |
Correct |
91 ms |
10392 KB |
Output is correct |
8 |
Correct |
91 ms |
10500 KB |
Output is correct |
9 |
Correct |
87 ms |
10228 KB |
Output is correct |
10 |
Correct |
91 ms |
10268 KB |
Output is correct |
11 |
Correct |
95 ms |
10344 KB |
Output is correct |
12 |
Correct |
94 ms |
10380 KB |
Output is correct |
13 |
Correct |
90 ms |
10396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
86 ms |
10368 KB |
Output is correct |
2 |
Correct |
87 ms |
10104 KB |
Output is correct |
3 |
Correct |
89 ms |
10232 KB |
Output is correct |
4 |
Correct |
116 ms |
10344 KB |
Output is correct |
5 |
Correct |
92 ms |
10580 KB |
Output is correct |
6 |
Correct |
88 ms |
10400 KB |
Output is correct |
7 |
Correct |
91 ms |
10392 KB |
Output is correct |
8 |
Correct |
91 ms |
10500 KB |
Output is correct |
9 |
Correct |
87 ms |
10228 KB |
Output is correct |
10 |
Correct |
91 ms |
10268 KB |
Output is correct |
11 |
Correct |
95 ms |
10344 KB |
Output is correct |
12 |
Correct |
94 ms |
10380 KB |
Output is correct |
13 |
Correct |
90 ms |
10396 KB |
Output is correct |
14 |
Correct |
161 ms |
15020 KB |
Output is correct |
15 |
Correct |
91 ms |
10540 KB |
Output is correct |
16 |
Correct |
128 ms |
14460 KB |
Output is correct |
17 |
Correct |
90 ms |
10228 KB |
Output is correct |
18 |
Correct |
190 ms |
15420 KB |
Output is correct |
19 |
Correct |
134 ms |
14128 KB |
Output is correct |
20 |
Correct |
134 ms |
13976 KB |
Output is correct |
21 |
Correct |
133 ms |
14016 KB |
Output is correct |
22 |
Correct |
144 ms |
14080 KB |
Output is correct |
23 |
Correct |
133 ms |
13976 KB |
Output is correct |
24 |
Correct |
140 ms |
13972 KB |
Output is correct |
25 |
Correct |
136 ms |
14128 KB |
Output is correct |
26 |
Correct |
149 ms |
15444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
86 ms |
10368 KB |
Output is correct |
2 |
Correct |
87 ms |
10104 KB |
Output is correct |
3 |
Correct |
89 ms |
10232 KB |
Output is correct |
4 |
Correct |
116 ms |
10344 KB |
Output is correct |
5 |
Correct |
92 ms |
10580 KB |
Output is correct |
6 |
Correct |
88 ms |
10400 KB |
Output is correct |
7 |
Correct |
91 ms |
10392 KB |
Output is correct |
8 |
Correct |
91 ms |
10500 KB |
Output is correct |
9 |
Correct |
87 ms |
10228 KB |
Output is correct |
10 |
Correct |
91 ms |
10268 KB |
Output is correct |
11 |
Correct |
95 ms |
10344 KB |
Output is correct |
12 |
Correct |
94 ms |
10380 KB |
Output is correct |
13 |
Correct |
90 ms |
10396 KB |
Output is correct |
14 |
Correct |
161 ms |
15020 KB |
Output is correct |
15 |
Correct |
91 ms |
10540 KB |
Output is correct |
16 |
Correct |
128 ms |
14460 KB |
Output is correct |
17 |
Correct |
90 ms |
10228 KB |
Output is correct |
18 |
Correct |
190 ms |
15420 KB |
Output is correct |
19 |
Correct |
134 ms |
14128 KB |
Output is correct |
20 |
Correct |
134 ms |
13976 KB |
Output is correct |
21 |
Correct |
133 ms |
14016 KB |
Output is correct |
22 |
Correct |
144 ms |
14080 KB |
Output is correct |
23 |
Correct |
133 ms |
13976 KB |
Output is correct |
24 |
Correct |
140 ms |
13972 KB |
Output is correct |
25 |
Correct |
136 ms |
14128 KB |
Output is correct |
26 |
Correct |
149 ms |
15444 KB |
Output is correct |
27 |
Correct |
477 ms |
71168 KB |
Output is correct |
28 |
Correct |
99 ms |
11516 KB |
Output is correct |
29 |
Correct |
180 ms |
18820 KB |
Output is correct |
30 |
Correct |
92 ms |
10612 KB |
Output is correct |
31 |
Correct |
385 ms |
64476 KB |
Output is correct |
32 |
Correct |
359 ms |
73044 KB |
Output is correct |
33 |
Correct |
387 ms |
74056 KB |
Output is correct |
34 |
Correct |
429 ms |
68612 KB |
Output is correct |
35 |
Correct |
490 ms |
72788 KB |
Output is correct |
36 |
Correct |
407 ms |
73880 KB |
Output is correct |
37 |
Correct |
473 ms |
72904 KB |
Output is correct |
38 |
Correct |
332 ms |
64868 KB |
Output is correct |
39 |
Execution timed out |
2715 ms |
62464 KB |
Time limit exceeded |