-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10845.py
More file actions
57 lines (41 loc) · 917 Bytes
/
10845.py
File metadata and controls
57 lines (41 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import sys
item = int(sys.stdin.readline())
lst = []
def push(lst, num):
lst.append(num)
def pop(lst):
if len(lst) == 0:
print(-1)
else:
print(lst.pop(0))
def size(lst):
print(len(lst))
def empty(lst):
if len(lst) == 0:
print(1)
else:
print(0)
def front(lst):
if len(lst) == 0:
print(-1)
else:
print(lst[0])
def back(lst):
if len(lst) == 0:
print(-1)
else:
print(lst[-1])
for _ in range(item):
command = sys.stdin.readline().strip("\n")
if command[0:4] == "push":
push(lst, int(command[5:]))
elif command == "pop":
pop(lst)
elif command == "size":
size(lst)
elif command == "empty":
empty(lst)
elif command == "front":
front(lst)
elif command == "back":
back(lst)