Skip to content

Commit 9f320b3

Browse files
committed
add: λ°±μ€€/Contact
1 parent a6681c7 commit 9f320b3

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Contact
2+
// https://www.acmicpc.net/problem/1013
3+
const fs = require('fs');
4+
const stdin = (process.platform === 'linux'
5+
? fs.readFileSync('/dev/stdin').toString().trim()
6+
: `3
7+
10010111
8+
011000100110001
9+
0110001011001
10+
`
11+
).split('\n');
12+
13+
const input = (() => {
14+
let line = 0;
15+
return () => stdin[line++];
16+
})();
17+
18+
const N = parseInt(input());
19+
20+
let re = new RegExp('^((100+1+|01)+)$');
21+
22+
for (let i = 0; i < N; i++) {
23+
let signal = input();
24+
25+
if (re.test(signal)) {
26+
console.log('YES');
27+
} else {
28+
console.log('NO');
29+
}
30+
}
31+
32+
/*
33+
34+
## How
35+
μ •κ·œμ‹ 문제둜 골랐던거라 μ •κ·œμ‹μ„ μ‚¬μš©ν•΄μ•Όκ² λ‹€κ³  μƒκ°ν–ˆλ‹€. λ¬Έμ œμ—μ„œ μ œμ‹œν•œ κ·œμΉ™ μžμ²΄λ„ μ •κ·œμ‹μ„ μ‚¬μš©ν•  수 μžˆκ²Œλ” μ£Όκ³  μžˆμ—ˆλ‹€.
36+
37+
μ •κ·œμ‹μ„ μ‚¬μš©ν•˜μ§€ μ•ŠλŠ”λ‹€λ©΄ μ˜€ν† λ§ˆνƒ€ 전이 κ·Έλž˜ν”„(Deterministic Finite Accepter)λ₯Ό 그리고 μ½”λ“œλ₯Ό μž‘μ„±ν•˜λ©΄ λœλ‹€κ³  ν•œλ‹€.
38+
39+
λ¬Έμ œμ—μ„œ 각각의 μΌ€μ΄μŠ€λ₯Ό μ£Όλ©° μ„€λͺ…ν•΄μ£Όκ³  μžˆλŠ”λ° `+`λŠ” μ•žμ˜ λ¬Έμžκ°€ ν•˜λ‚˜ 이상 λ‚˜μ˜€λ©΄ λœλ‹€λŠ” 의미이고 `(`, `)`λŠ” 문자λ₯Ό κ·Έλ£Ήν™” ν•œλ‹€λŠ” μ˜λ―Έμ΄λ‹€. `|`λŠ” or μ—°μ‚°μžμ΄λ‹€.
40+
41+
μœ„ μ •κ·œν‘œν˜„μ‹ κ·œμΉ™μ„ μ‚¬μš©ν•˜μ—¬ μ™„μ„±λœ ν‘œν˜„μ‹μ„ λ¬Έμ œμ—μ„œ μ•„λž˜μ™€ 같이 μ œκ³΅ν•œλ‹€.
42+
43+
`(100+1+ | 01)+`
44+
45+
ν•΄λ‹Ή νŒ¨ν„΄μ„ κ·Έλƒ₯ μ‚¬μš©ν•œλ‹€λ©΄ λ¬Έμ œκ°€ μƒκ²¨μ„œ μ•΅μ»€λ‘œ 감싸주어야 ν•œλ‹€. `^`둜 μ‹œμž‘ λ¬Έμžμ—΄κ³Ό `$`둜 끝 λ¬Έμžμ—΄μž„μ„ μ•Œ 수 μžˆλ„λ‘ μ²˜λ¦¬ν•΄μ£Όμ–΄μ•Ό ν•œλ‹€.
46+
47+
https://ko.javascript.info/regexp-anchors
48+
49+
50+
## Retrospective
51+
52+
*/

0 commit comments

Comments
Β (0)