Skip to content

Commit

Permalink
Merge pull request #94 from AlgoLeadMe/21-avocado-13
Browse files Browse the repository at this point in the history
21-avocado-13
  • Loading branch information
avocado-13 authored Mar 14, 2024
2 parents 25513be + 094ffe0 commit 4d7eebc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion avocado-13/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
| 18차시 | 2024.02.28 | DFS&BFS | <a href="https://www.acmicpc.net/problem/1012">유기농배추</a> |<a href="https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/82"> #82 </a>|
| 19차시 | 2024.03.02 | DFS&BFS | <a href="https://www.acmicpc.net/problem/2667">단지번호붙이기</a> |<a href="https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/84"> #84 </a>|
| 20차시 | 2024.03.05 | 누적합 | <a href="https://www.acmicpc.net/problem/16139">인간-컴퓨터상호작용</a> |<a href="https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/90"> #90</a>|

| 21차시 | 2024.03.10 || <a href="https://www.acmicpc.net/problem/6119">Cow line</a> |<a href="https://github.com/AlgoLeadMe/AlgoLeadMe-4/pull/94"> #94 </a>|
27 changes: 27 additions & 0 deletions avocado-13/큐/Cow line.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import sys
from collections import deque

input = sys.stdin.readline
queue = deque()
cowNum = 1
N = int(input()) # 줄에 설 소가 몇마리인지 입력받기
for _ in range(N):
cmd = input().split()
action, side = cmd[0], cmd[1]
if action == "A":
if side == "L":
queue.appendleft(cowNum)
else:
queue.append(cowNum)
cowNum += 1
else : # action == "D"
K = cmd[2]
if side == "L":
for _ in range(int(K)):
queue.popleft()

else:
for _ in range(int(K)):
queue.pop()

print(*queue,sep="\n")

0 comments on commit 4d7eebc

Please sign in to comment.