이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
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);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |