[BOJ] 1013. Contact
2021. 9. 25. 16:43ㆍ알고리즘/백준 문제 풀이
https://www.acmicpc.net/problem/1013
접근 방법
정규식만 잘 안다면 풀 수 있는 문제이다.
정규식에 모르거나 연습할 문제로 충분하다.
Need Know
전체 코드 ( Java )
import java.io.*;
class Main {
static int N;
static StringBuilder sb = new StringBuilder();
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) throws IOException {
set();
solve();
bw.flush();
br.close();
bw.close();
}
static void set() throws IOException {
// (100+1+ | 01)+
N = Integer.parseInt(br.readLine());
for(int i=0; i<N; i++){
String str = br.readLine();
if(str.matches("((10(0)+(1)+)|(01)+)+")){
sb.append("YES").append("\n");
}else{
sb.append("NO").append("\n");
}
}
}
static void solve() throws IOException {
bw.write(sb.toString());
}
}
'알고리즘 > 백준 문제 풀이' 카테고리의 다른 글
[BOJ] 1107. 리모콘 (0) | 2021.09.25 |
---|---|
[BOJ] 2174. 로봇 시뮬레이션 (0) | 2021.09.19 |
[BOJ] 10800. 컬러볼 (0) | 2021.09.18 |
[BOJ] 20056. 마법사 상어와 파이어볼 (0) | 2021.09.18 |
[BOJ] 1182. 부분수열의 합 (0) | 2021.04.21 |