• 문제 링크
https://www.acmicpc.net/problem/9455
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int t = read();
while (t-- > 0) {
int m = read(), n = read();
boolean[][] mat = new boolean[m][n];
for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) mat[i][j] = read() == 1;
int cnt = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) if (mat[j][i]) for (int k = j + 1; k < m; k++) if (!mat[k][i]) cnt++;
bw.write(cnt + "\n");
}
bw.flush();
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 11816 8진수, 10진수, 16진수 - Implementation / Java (0) | 2025.07.29 |
---|---|
[백준] 2804 크로스워드 만들기 - Implementation / Java (0) | 2025.07.28 |
[백준] 1551 수열의 변화 - Implementation / Java (0) | 2025.07.26 |
[백준] 2985 세 수 - Implementation / Java (0) | 2025.07.25 |
[백준] 9770 GCD - Brute Force / Java (0) | 2025.07.24 |
댓글