잠수함식별 2671

LJM·2023년 7월 6일
0

백준풀기

목록 보기
163/259

https://www.acmicpc.net/problem/2671

그냥 짜서 해결하려다가.. 시간이 너무 아까워서 그냥 풀이보고 풀었다..;;

import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String input = br.readLine();

        Pattern p = Pattern.compile("(100+1+|01)+");
        Matcher m = p.matcher(input);

        if (m.matches()) {
            System.out.println("SUBMARINE");
        } else {
            System.out.println("NOISE");
        }

    }
}
public class Main {
    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String input = br.readLine();

        String regex = "(100+1+|01)+";

        if (input.matches(regex)) {
            System.out.println("SUBMARINE");
        } else {
            System.out.println("NOISE");
        }

    }
}
profile
게임개발자 백엔드개발자

0개의 댓글