백준 #31669번 특별한 학교 탈출

jhj·2024년 5월 19일

백준 JAVA

목록 보기
473/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		String[] a = new String[n];
		
		int i;
		for(i = 0; i < n; i++) {
			a[i] = sc.next();
		}
		
		for(i = 0; i < m; i++) {
			int count = 0;
			for(int j = 0; j < n; j++) {
				if(a[j].charAt(i) == 'X') {
					count++;
				}
			}
			if(count == n) {
				System.out.println(i + 1);
				break;
			}
		}
		
		if(i == m) {
			System.out.println("ESCAPE FAILED");
		}
		sc.close();
	}
}
profile
개발자를 꿈꾸는

0개의 댓글