b_비슷한단어_2607
| source | www.acmicpc.net/problem/2607 |
| type | 📌 개발노트 |
| topics | 600-알고리즘 & 코딩테스트 601 구현 & 완전탐색 |
| types | 문제풀이 |
| 정답여부 | 실수 |
문제
구성이 같다 : 두단어가 같은 문자 ,각문자마다 개수도같음
비슷하다 : 한문자를 더하거나 빼거나 하나를 다른문자하나로 바꾼경우.
답
집합으로 하면 될 것같다 응안대 각 글자별로 개수 새야해서 딕셔너리로 했음
길이의 개수가 작은경우에대한 조건이 부족햇음
길이가 작은경우 무조건 하나의 문자를 추가해야하기에
기존 문자에서 다 해결을 봐야함.
import sys
n = int(sys.stdin.readline().strip())
sta_l = 0
stand = {}
ans = 0
for i in range(n):
tmp = sys.stdin.readline().strip()
if i == 0:
for t in tmp:
if t in stand:
stand[t] +=1
else:
stand[t] =1
sta_l = len(tmp)
# print("stand",stand,sta_l)
else:
t_stand = stand.copy()
wrong = 0
dif = sta_l - len(tmp)
if dif <2 and dif>-2:
for t in tmp:
if t in t_stand and t_stand[t] >0:
t_stand[t]-=1
else:
if dif == 1:
wrong+=1
wrong+=1
if wrong>1:
break
if wrong<2:
# print("비슷",tmp)
ans +=1
print(ans)