본문 바로가기

Algorithm/백준

백준 9933 민균이의 비밀번호

package practice;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Boj9933 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        List<String> list = new ArrayList<>();
        for(int i= 0; i < n ; i ++){
            list.add(br.readLine());
        }
        for(int i = 0 ; i < n ; i ++){
            StringBuffer sb = new StringBuffer(list.get(i));
            if(list.contains(sb.reverse().toString())){
                System.out.println(list.get(i).length() + " " + list.get(i).charAt((list.get(i).length()-1) /2));
                break;
            }
        }

    }
}

'Algorithm > 백준' 카테고리의 다른 글

백준 1260 DFS와 BFS  (0) 2024.07.27
백준 19583 싸이버개강총회  (0) 2024.07.26
백준 4358 생태학  (0) 2024.07.26
백준 1764 듣보잡  (0) 2024.07.26
백준 1269 대칭 차집합  (0) 2024.07.26