Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit aa3f574

Browse files
[Silver V] Title: 그룹 단어 체커, Time: 92 ms, Memory: 32420 KB -BaekjoonHub
1 parent 8b7de93 commit aa3f574

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# [Silver V] 그룹 단어 체커 - 1316
2+
3+
[문제 링크](https://www.acmicpc.net/problem/1316)
4+
5+
### 성능 요약
6+
7+
메모리: 32420 KB, 시간: 92 ms
8+
9+
### 분류
10+
11+
구현(implementation), 문자열(string)
12+
13+
### 문제 설명
14+
15+
<p>그룹 단어란 단어에 존재하는 모든 문자에 대해서, 각 문자가 연속해서 나타나는 경우만을 말한다. 예를 들면, ccazzzzbb는 c, a, z, b가 모두 연속해서 나타나고, kin도 k, i, n이 연속해서 나타나기 때문에 그룹 단어이지만, aabbbccb는 b가 떨어져서 나타나기 때문에 그룹 단어가 아니다.</p>
16+
17+
<p>단어 N개를 입력으로 받아 그룹 단어의 개수를 출력하는 프로그램을 작성하시오.</p>
18+
19+
### 입력
20+
21+
<p>첫째 줄에 단어의 개수 N이 들어온다. N은 100보다 작거나 같은 자연수이다. 둘째 줄부터 N개의 줄에 단어가 들어온다. 단어는 알파벳 소문자로만 되어있고 중복되지 않으며, 길이는 최대 100이다.</p>
22+
23+
### 출력
24+
25+
<p>첫째 줄에 그룹 단어의 개수를 출력한다.</p>
26+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 그룹 단어 체커 - 구현
2+
from collections import deque
3+
N = int(input())
4+
ans = 0
5+
for _ in range(N):
6+
S = input()
7+
temp = deque([])
8+
is_group = True
9+
pre_word = ""
10+
for s in S:
11+
if s in temp and pre_word != s:
12+
is_group = False
13+
break
14+
elif s not in temp:
15+
temp.append(s)
16+
pre_word = s
17+
if is_group: ans += 1
18+
print(ans)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /