Created
April 8, 2018 14:57
-
-
Save qkreltms/17f36df51bd949772dce401b3789bb03 to your computer and use it in GitHub Desktop.
LRU Caching - <https://www.acmicpc.net/problem/4568>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def f(n, seq): | |
| print("Simulation %d" % ctn) | |
| cache = [] | |
| for i in seq: | |
| for j in i: | |
| if j is "!": | |
| print(''.join(reversed(cache))) | |
| continue | |
| if j in cache: | |
| cache.pop(cache.index(j)) | |
| if len(cache) >= n: | |
| cache.pop() | |
| cache.insert(0, j) | |
| ctn = 1 | |
| while True: | |
| user = list(input().split()) | |
| if user[0] is '0': | |
| break | |
| n, seq = user | |
| f(int(n), seq) | |
| ctn += 1 |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
설명
있으면 해당 아이템 삭제
(1~3 반복...)