728x90
(SW) 1210. Ladder1
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
📌 풀이
import java.util.Arrays;
import java.util.Scanner;
public class Solution {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
for(int t=1; t<=10; t++) {
sc.nextLine();
String[][] map = new String[100][100];
for(int i=0; i<100; i++) {
map[i] = sc.nextLine().split(" ");
}
int index = Arrays.asList(map[99]).indexOf("2");
for(int k=99; k>=0; k--) {
// 오른족
for(; index<99 && "1".equals(map[k][index+1]);) {
map[k][index++] = "0";
}
// 왼쪽
for(; 0<index && "1".equals(map[k][index-1]);) {
map[k][index--] = "0";
}
} // end for k
System.out.printf("#%d %d%n", t, index);
}
}
}
728x90
'[알고리즘] > 알고리즘' 카테고리의 다른 글
[알고리즘] 백준 17478. 재귀함수가 뭔가요? (0) | 2022.02.13 |
---|---|
[알고리즘] 백준 10974. 모든 순열 (0) | 2022.02.13 |
[알고리즘] 백준6603. 로또 (0) | 2022.02.13 |
[알고리즘] 백준2563. 색종이 (0) | 2022.02.11 |
[알고리즘] 백준 1009번. 분산처리 (0) | 2022.02.10 |