ํฐ์คํ ๋ฆฌ ๋ทฐ
๐ฉ๐ป๐ป ๋ฌธ์
โ๐ป ํ์ด
๐จ Go
// https://www.acmicpc.net/problem/11140
package main
import (
"bufio"
"fmt"
"os"
"regexp"
"strings"
)
func main() {
reader := bufio.NewReader(os.Stdin)
writer := bufio.NewWriter(os.Stdout)
defer writer.Flush()
var t int
fmt.Fscanln(reader, &t)
for i := 0; i < t; i++ {
var input string
fmt.Fscanln(reader, &input)
fmt.Fprintln(writer, solve(input))
}
}
func solve(input string) int {
match, _ := regexp.MatchString("l([a-z])l", input)
if strings.Contains(input, "lol") {
return 0
} else if strings.Contains(input, "lo") || strings.Contains(input, "ol") || strings.Contains(input, "ll") || match {
return 1
} else if strings.Contains(input, "l") || strings.Contains(input, "o") {
return 2
}
return 3
}
๐จ Python3
# https://www.acmicpc.net/problem/11140
import sys
import string
def solve(input):
if "lol" in input:
return 0
elif "lo" in input or "ol" in input or "ll" in input or any("l" + x + "l" in input for x in string.ascii_lowercase):
return 1
elif "l" in input or "o" in input:
return 2
return 3
if __name__ == "__main__":
t = int(sys.stdin.readline())
for i in range(t):
input = sys.stdin.readline().rstrip()
print(solve(input))
728x90
'dev > algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ / 1697๋ฒ / ์จ๋ฐ๊ผญ์ง [Go][Python3] (0) | 2021.03.17 |
---|---|
BOJ / 7576๋ฒ / ํ ๋งํ [Go][Python3] (0) | 2021.03.16 |
BOJ / 5883๋ฒ / ์์ดํฐ 9S [Go][Python3] (0) | 2021.03.14 |
BOJ / 14606๋ฒ / ํผ์ (Small) [Go][Python3] (0) | 2021.03.13 |
BOJ / 2847๋ฒ / ๊ฒ์์ ๋ง๋ ๋์ค์ด [Go][Python3] (0) | 2021.03.12 |
๋๊ธ
๊ธ ๋ณด๊ดํจ
์ต๊ทผ์ ๋ฌ๋ฆฐ ๋๊ธ
TAG
- ๋ฐฑ์ค
- ๋งฅ๋ถํ๋ก
- Golang
- ํ
- MongoDB
- AWS
- dp
- java
- Algorithm
- ๋ธ๋ฃจํธํฌ์ค
- ์คํ
- ballet
- Macbook pro 2012 mid 13
- python3
- ํด์๋งต
- ํ๋ก์ด๋์์ฌ
- ๋ชฝ๊ณ ๋๋น
- ๋งฅ๋ถ
- ๋ถํ ์ ๋ณต
- dfs
- ์ด๋ถํ์
- ๋ฐ๋
- ์๋ฐ
- baekjoon
- BOJ
- ๋งฅ๋ถ ์ ๊ทธ๋ ์ด๋
- ์๊ฐ๊ต์ฒด
- go
- BFS
- ์๊ณ ๋ฆฌ์ฆ
- Total
- Today
- Yesterday