본문 바로가기
공부/코딩테스트

백준: 6764번 Sounds fishy! (Python3)

by 혼밥맨 2022. 8. 3.
반응형

백준: 6764번 Sounds fishy! (Python3)

Sounds fishy! 성공다국어

 
시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB 2906 1156 1050 39.533%

문제

A fish-finder is a device used by anglers to find fish in a lake. If the fish-finder finds a fish, it will sound an alarm. It uses depth readings to determine whether to sound an alarm. For our purposes, the fish-finder will decide that a fish is swimming past if:

  • there are four consecutive depth readings which form a strictly increasing sequence (such as 3 4 7 9) (which we will call “Fish Rising”), or
  • there are four consecutive depth readings which form a strictly decreasing sequence (such as 9 6 5 2) (which we will call “Fish Diving”), or
  • there are four consecutive depth readings which are identical (which we will call “Constant Depth”).

All other readings will be considered random noise or debris, which we will call “No Fish.”

Your task is to read a sequence of depth readings and determine if the alarm will sound.

입력

The input will be four positive integers, representing the depth readings. Each integer will be on its own line of input.

출력

The output is one of four possibilities. If the depth readings are increasing, then the output should be Fish Rising. If the depth readings are decreasing, then the output should be Fish Diving. If the depth readings are identical, then the output should be Fish At Constant Depth. Otherwise, the output should be No Fish.

예제 입력 1

1
10
12
13

예제 출력 1

Fish Rising

고민의 흔적

 

답안

1
2
3
4
5
6
7
8
9
10
11
12
13
14
lst = [int(input()) for _ in range(4)]
lst_1 = sorted(lst, reverse=True)
lst_2 = sorted(lst, reverse=False)
 
if lst[0]==lst[1and lst[0]==lst[2and lst[0]==lst[-1]:
    print("Fish At Constant Depth")
elif lst.count(lst[0]) > 1 or lst.count(lst[1]) > 1 or lst.count(lst[2]) > 1 or lst.count(lst[-1]) > 1:
    print("No Fish")
elif lst_1==lst:
    print("Fish Diving")
elif lst_2==lst:
    print("Fish Rising")
else:
    print("No Fish")
cs

틀린 제출 답안 01

1
2
3
4
5
6
7
8
9
10
11
12
lst = [int(input()) for _ in range(4)]
lst_1 = sorted(lst, reverse=True)
lst_2 = sorted(lst, reverse=False)
 
if lst[0]==lst[1and lst[0]==lst[2and lst[0]==lst[-1]:
    print("Fish At Constant Depth")
elif lst_1==lst:
    print("Fish Diving")
elif lst_2==lst:
    print("Fish Rising")
else:
    print("No Fish")
cs
반응형

댓글