s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s104556770 | p02265 | u728700495 | 1476541316 | Python | Python3 | py | Runtime Error | 40 | 7732 | 746 | class LinkedList(object):
def __init__(self):
self.data = []
def insert(self, d):
self.data.insert(0, d)
def delete(self, d):
self.data.remove(d)
def delete_first(self):
self.data.pop(0)
def delete_last(self):
self.data.pop(len(self.data)-1)
data = LinkedList()
for _ in range(int(input())):
line_data = input().split()
command = line_data[0]
if len(line_data) == 2:
d = int(line_data[1])
if command == 'insert':
data.insert(d)
elif command == 'delete':
data.delete(d)
elif command == 'deleteFirst':
data.delete_first()
elif command == 'deleteLast':
data.delete_last()
print(" ".join(list(map(str, data.data)))) |
s727770418 | p02265 | u813534019 | 1476555321 | Python | Python | py | Runtime Error | 10 | 6284 | 342 | cnt=input()
lst=[]
for x in xrange(cnt):
cmd = raw_input().split()
if cmd[0] == "insert":
lst = [int(cmd[1])] + lst
elif cmd[0] == "delete":
lst.remove(int(cmd[1]))
elif cmd[0] == "deleteFirst":
lst = lst[1:]
elif cmd[0] == "deleteLast":
lst = lst[:-1]
print " ".join([str(x) for x in lst]) |
s421497876 | p02265 | u159356473 | 1477285023 | Python | Python3 | py | Runtime Error | 0 | 0 | 571 | #coding:UTF-8
def DLL(n,C):
ans=[]
for i in range(n):
if C[i]=="deleteFirst":
ans.pop(len(ans))
elif C[i]=="delereLast":
ans.pop(0)
else:
command=C[i].split(" ")[0]
num=C[i].split(" ")[1]
if command=="delete":
ans.remove(num)
else:
ans.append(num)
ans.reverse()
print(" ".join(ans))
if __name__=="__main__":
n=int(input())
Command=[]
for i in range(n):
Command.append(input())
DLL(n,Command) |
s157492890 | p02265 | u159356473 | 1477285924 | Python | Python3 | py | Runtime Error | 20 | 7740 | 641 | #coding:UTF-8
def DLL(n,C):
ans=[]
for i in range(n):
if C[i]=="deleteFirst":
ans.pop(len(ans)-1)
elif C[i]=="deleteLast":
ans.pop(0)
else:
command=C[i].split(" ")[0]
num=C[i].split(" ")[1]
if command=="delete":
ans.reverse()
ans.pop(ans.index(num))
ans.reverse()
else:
ans.append(num)
ans.reverse()
print(" ".join(ans))
if __name__=="__main__":
n=int(input())
Command=[]
for i in range(n):
Command.append(input())
DLL(n,Command) |
s515107500 | p02265 | u022407960 | 1477928315 | Python | Python3 | py | Runtime Error | 0 | 0 | 750 | # encoding: utf-8
import sys
from collections import deque
class Solution:
@staticmethod
def doubly_linked_list():
# write your code here
array_length = int(input())
_input = sys.stdin.readlines()
task_list = list(map(lambda x: dict(action=x.split()[0], value=int(x.split()[-1])), _input))
task_deque = deque()
for task in task_list:
if task.get('action')=='insertion':
task_deque.appendleft(task.get('value'))
else:
task_deque.remove(task.get('value'))
print(" ".join(map(str, task_deque)))
assert len(task_deque) <= array_length
if __name__ == '__main__':
solution = Solution()
solution.doubly_linked_list() |
s874817377 | p02265 | u022407960 | 1477928356 | Python | Python3 | py | Runtime Error | 0 | 0 | 747 | # encoding: utf-8
import sys
from collections import deque
class Solution:
@staticmethod
def doubly_linked_list():
# write your code here
array_length = int(input())
_input = sys.stdin.readlines()
task_list = list(map(lambda x: dict(action=x.split()[0], value=int(x.split()[-1])), _input))
task_deque = deque()
for task in task_list:
if task.get('action')=='insert':
task_deque.appendleft(task.get('value'))
else:
task_deque.remove(task.get('value'))
print(" ".join(map(str, task_deque)))
assert len(task_deque) <= array_length
if __name__ == '__main__':
solution = Solution()
solution.doubly_linked_list() |
s519393751 | p02265 | u022407960 | 1477928716 | Python | Python3 | py | Runtime Error | 0 | 0 | 931 | # encoding: utf-8
import sys
from collections import deque
class Solution:
@staticmethod
def doubly_linked_list():
# write your code here
array_length = int(input())
_input = sys.stdin.readlines()
task_list = list(map(lambda x: dict(action=x.split()[0], value=int(x.split()[-1])), _input))
task_deque = deque()
for task in task_list:
action = task.get('action')
if action == 'insert':
task_deque.appendleft(task.get('value'))
elif action == 'deleteFirst':
task_deque.popleft()
elif action == 'deleteLast':
task_deque.pop()
else:
task_deque.remove(task.get('value'))
print(" ".join(map(str, task_deque)))
assert len(task_deque) <= array_length
if __name__ == '__main__':
solution = Solution()
solution.doubly_linked_list() |
s601498701 | p02265 | u022407960 | 1477928802 | Python | Python3 | py | Runtime Error | 30 | 8084 | 926 | # encoding: utf-8
import sys
from collections import deque
class Solution:
@staticmethod
def doubly_linked_list():
# write your code here
array_length = int(input())
_input = sys.stdin.readlines()
task_list = list(map(lambda x: dict(action=x.split()[0], value=x.split()[-1]), _input))
task_deque = deque()
for task in task_list:
action = task.get('action')
if action == 'insert':
task_deque.appendleft(task.get('value'))
elif action == 'deleteFirst':
task_deque.popleft()
elif action == 'deleteLast':
task_deque.pop()
else:
task_deque.remove(task.get('value'))
print(" ".join(map(str, task_deque)))
assert len(task_deque) <= array_length
if __name__ == '__main__':
solution = Solution()
solution.doubly_linked_list() |
s425104613 | p02265 | u022407960 | 1477929411 | Python | Python3 | py | Runtime Error | 30 | 8076 | 959 | # encoding: utf-8
import sys
from collections import deque
class Solution:
@staticmethod
def doubly_linked_list():
# write your code here
array_length = int(input())
_input = sys.stdin.readlines()
task_list = list(map(lambda x: dict(action=x.split()[0], value=x.split()[-1]), _input))
task_deque = deque()
for task in task_list:
action = task.get('action')
value = task.get('value')
if action == 'insert':
task_deque.appendleft(value)
elif action == 'deleteFirst':
task_deque.popleft()
elif action == 'deleteLast':
task_deque.pop()
elif action == 'delete':
task_deque.remove(value)
print(" ".join(map(str, task_deque)))
assert len(task_deque) <= array_length
if __name__ == '__main__':
solution = Solution()
solution.doubly_linked_list() |
s625468076 | p02265 | u022407960 | 1477930048 | Python | Python3 | py | Runtime Error | 50 | 8048 | 1045 | # encoding: utf-8
import sys
from collections import deque
class Solution:
@staticmethod
def doubly_linked_list():
# write your code here
array_length = int(input())
_input = sys.stdin.readlines()
task_list = list(map(lambda x: dict(action=x.split()[0], value=x.split()[-1]), _input))
assert len(task_list) == array_length
task_deque = deque()
for i in range(array_length):
task = task_list[i]
action = task.get('action')
value = task.get('value')
if action == 'insert':
task_deque.appendleft(value)
elif action == 'deleteFirst':
task_deque.popleft()
elif action == 'deleteLast':
task_deque.pop()
elif action == 'delete':
task_deque.remove(value)
print(" ".join(map(str, task_deque)))
assert len(task_deque) <= array_length
if __name__ == '__main__':
solution = Solution()
solution.doubly_linked_list() |
s843936838 | p02265 | u659302741 | 1477934245 | Python | Python3 | py | Runtime Error | 50 | 8004 | 404 | import sys
from collections import deque
d = deque()
n = int(input())
lines = sys.stdin.readlines()
for i in range(n):
ins = lines[i].split()
command = ins[0]
if command == "insert":
d.appendleft(ins[1])
elif command == "delete":
d.remove(ins[1])
elif command == "deleteFirst":
d.popleft()
elif command == "deleteLast":
d.pop()
print(" ".join(d)) |
s305515079 | p02265 | u451769769 | 1478597904 | Python | Python | py | Runtime Error | 10 | 6772 | 553 | #!/usr/bin/env python
#-*- coding:utf-8 -*-
from collections import deque
def parse_cmd(deque,input_cmd):
if input_cmd[0] == 'insert':
deque.appendleft(input_cmd[1])
elif input_cmd[0] == 'delete':
deque.remove(input_cmd[1])
elif input_cmd[0] == 'deleteFirst':
deque.popleft()
elif input_cmd[0] == 'deleteLast':
deque.pop()
def main():
que = deque()
n = int(raw_input())
cmd = [raw_input().split() for _ in range(n)]
for i in cmd:
parse_cmd(que,i)
print " ".join(que)
#def test():
if __name__ == '__main__':
main()
#test() |
s657132244 | p02265 | u742013327 | 1479200005 | Python | Python3 | py | Runtime Error | 60 | 7812 | 2538 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????
#??¬?????????????????¬????????§????????¨???????????????????????????dummy????????????????????¨??§???????????????????????????????????§??????
def dll_processor(operations):
dll = Doubly_Linked_List()
for o in operations:
opcode = o[0]
if opcode == "insert":
dll.insert(o[1])
elif opcode == "delete":
dll.delete(o[1])
elif opcode == "deleteFirst":
dll.deleteFirst()
elif opcode == "deleteLast":
dll.deleteLast()
#print(dll.prev.data)
return dll.get_list()
class Doubly_Linked_List:
def __init__(self):
self.next = None
self.prev = None
self.data = "dummy"
def get_list(self):
first = self
while first.prev:
first = first.prev
target = first
l = [target.data]
while target.next:
if not target.next.data == "dummy":
l.append(target.next.data)
target = target.next
return l
def insert(self, x):
first = self
while first.prev:
first = first.prev
first.prev = Doubly_Linked_List()#???????????????
first.prev.next = first
first.prev.data = x
def deleteFirst(self):
first = self
while first.prev:
first = first.prev
if first.data == "dummy" :
first.next = first.next.next
first.next.last = first
else:
first.next.prev = None
def deleteLast(self):
last = self
while last.next:
last = last.next
if last.data == "dummy":
last.prev = last.prev.prev
last.prev.next = last
else:
last.prev.next = None
def delete(self, x):
first = self
while first.prev:
first = first.prev
target = first
while not target.data == x:
target = target.next
if target.prev == None:
target.next.prev = None
elif target.next == None:
target.prev.next = None
else:
target.next.prev = target.prev
target.prev.next = target.next
def main():
n_list = int(input())
target_list = [input().split() for i in range(n_list)]
print(*dll_processor(target_list))
if __name__ == "__main__":
main() |
s567041704 | p02265 | u742013327 | 1479200322 | Python | Python3 | py | Runtime Error | 20 | 7864 | 2616 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????
#??¬?????????????????¬????????§????????¨???????????????????????????dummy????????????????????¨??§???????????????????????????????????§??????
def dll_processor(operations):
dll = Doubly_Linked_List()
for o in operations:
opcode = o[0]
if opcode == "insert":
dll.insert(o[1])
elif opcode == "delete":
dll.delete(o[1])
elif opcode == "deleteFirst":
dll.deleteFirst()
elif opcode == "deleteLast":
dll.deleteLast()
#print(dll.get_list())
return dll.get_list()
class Doubly_Linked_List:
def __init__(self):
self.next = None
self.prev = None
self.data = "dummy"
def get_list(self):
first = self
while first.prev:
first = first.prev
target = first
l = [target.data]
while target.next:
if not target.next.data == "dummy":
l.append(target.next.data)
target = target.next
return l
def insert(self, x):
first = self
while first.prev:
first = first.prev
first.prev = Doubly_Linked_List()#???????????????
first.prev.next = first
first.prev.data = x
def deleteFirst(self):
first = self
while first.prev:
first = first.prev
if first.data == "dummy" :
first.next = first.next.next
first.next.last = first
else:
first.next.prev = None
def deleteLast(self):
last = self
while last.next:
last = last.next
if last.data == "dummy":
last.prev = last.prev.prev
last.prev.next = last
else:
last.prev.next = None
def delete(self, x):
first = self
while first.prev:
first = first.prev
target = first
while not target.data == x:
if target.next:
target = target.next
else:
return
if target.prev == None:
target.next.prev = None
elif target.next == None:
target.prev.next = None
else:
target.next.prev = target.prev
target.prev.next = target.next
def main():
n_list = int(input())
target_list = [input().split() for i in range(n_list)]
print(*dll_processor(target_list))
if __name__ == "__main__":
main() |
s122996356 | p02265 | u195186080 | 1480147793 | Python | Python3 | py | Runtime Error | 0 | 0 | 414 | import collections
q = collections.deque(maxlen=1000000)
n = int(input())
for i in range(n):
com = input().split()
if com[0]=='insert':
q.appendleft(int(com[1]))
elif com[0]=='delete':
try:
q.remove(int(com[0]))
except ValueError:
pass
elif com[0]=='deleteFirst':
q.popleft()
elif com[0]=='deleteLast':
q.pop()
print(' '.join(q)) |
s933872277 | p02265 | u195186080 | 1480147853 | Python | Python3 | py | Runtime Error | 0 | 0 | 403 | import collections
q = collections.deque(maxlen=1000000)
n = int(input())
for i in range(n):
com = input().split()
if com[0]=='insert':
q.appendleft(int(com[1]))
elif com[0]=='delete':
try:
q.remove(int(com[0]))
except:
pass
elif com[0]=='deleteFirst':
q.popleft()
elif com[0]=='deleteLast':
q.pop()
print(' '.join(q)) |
s004277442 | p02265 | u195186080 | 1480148068 | Python | Python3 | py | Runtime Error | 0 | 0 | 414 | import collections
q = collections.deque(maxlen=1000000)
n = int(input())
for i in range(n):
com = input().split()
if com[0]=='insert':
q.appendleft(int(com[1]))
elif com[0]=='delete':
try:
q.remove(int(com[0]))
except ValueError:
pass
elif com[0]=='deleteFirst':
q.popleft()
elif com[0]=='deleteLast':
q.pop()
print(' '.join(q)) |
s747031980 | p02265 | u195186080 | 1480148135 | Python | Python3 | py | Runtime Error | 0 | 0 | 414 | import collections
q = collections.deque(maxlen=1000000)
n = int(input())
for i in range(n):
com = input().split()
if com[0]=='insert':
q.appendleft(int(com[1]))
elif com[0]=='delete':
try:
q.remove(int(com[1]))
except ValueError:
pass
elif com[0]=='deleteFirst':
q.popleft()
elif com[0]=='deleteLast':
q.pop()
print(' '.join(q)) |
s280247403 | p02265 | u195186080 | 1480148307 | Python | Python3 | py | Runtime Error | 0 | 0 | 403 | import collections
q = collections.deque(maxlen=1000000)
n = int(input())
for i in range(n):
com = input().split()
if com[0]=='insert':
q.appendleft(int(com[1]))
elif com[0]=='delete':
try:
q.remove(int(com[1]))
except:
pass
elif com[0]=='deleteFirst':
q.popleft()
elif com[0]=='deleteLast':
q.pop()
print(' '.join(q)) |
s400000074 | p02265 | u195186080 | 1480148674 | Python | Python3 | py | Runtime Error | 0 | 0 | 411 | import collections
q = collections.deque(maxlen=1000000)
n = int(input())
for i in range(n):
com = input().split()
if com[0] == 'insert':
q.appendleft(int(com[1]))
elif com[0] == 'delete':
try:
q.remove(int(com[1]))
except:
pass
elif com[0] == 'deleteFirst':
q.popleft()
elif com[0] == 'deleteLast':
q.pop()
print(' '.join(q)) |
s587630270 | p02265 | u195186080 | 1480148681 | Python | Python3 | py | Runtime Error | 0 | 0 | 409 | import collections
q = collections.deque(maxlen=10000)
n = int(input())
for i in range(n):
com = input().split()
if com[0] == 'insert':
q.appendleft(int(com[1]))
elif com[0] == 'delete':
try:
q.remove(int(com[1]))
except:
pass
elif com[0] == 'deleteFirst':
q.popleft()
elif com[0] == 'deleteLast':
q.pop()
print(' '.join(q)) |
s691006798 | p02265 | u195186080 | 1480149190 | Python | Python3 | py | Runtime Error | 0 | 0 | 397 | import collections
q = collections.deque()
n = int(input())
for i in range(n):
com = input().split()
if com[0] == 'insert':
q.appendleft(int(com[1]))
elif com[0] == 'delete':
try:
q.remove(int(com[1]))
except:
pass
elif com[0] == 'deleteFirst':
q.popleft()
elif com[0] == 'deleteLast':
q.pop()
print(' '.join(q)) |
s701047930 | p02265 | u195186080 | 1480149248 | Python | Python3 | py | Runtime Error | 0 | 0 | 347 | import collections
q = collections.deque()
n = int(input())
for i in range(n):
com = input().split()
if com[0] == 'insert':
q.appendleft(int(com[1]))
elif com[0] == 'delete':
q.remove(int(com[1]))
elif com[0] == 'deleteFirst':
q.popleft()
elif com[0] == 'deleteLast':
q.pop()
print(' '.join(q)) |
s646475879 | p02265 | u195186080 | 1480150087 | Python | Python3 | py | Runtime Error | 0 | 0 | 347 | import collections
q = collections.deque()
n = int(input())
for i in range(n):
com = input().split()
if com[0] == 'insert':
q.appendleft(int(com[1]))
elif com[0] == 'delete':
q.remove(int(com[1]))
elif com[0] == 'deleteFirst':
q.popleft()
elif com[0] == 'deleteLast':
q.pop()
print(' '.join(q)) |
s711486812 | p02265 | u811733736 | 1480480251 | Python | Python3 | py | Runtime Error | 0 | 0 | 1123 | from collections import deque
def process_command(dll, commands):
for cmd, num_str in commands:
if cmd == 'insert':
dll.appendleft(int(num_str))
elif cmd == 'delete':
temp = []
result = dll.popleft()
while result != int(num_str):
temp.append(result)
result = dll.popleft()
dll.extendleft(temp)
elif cmd == 'deleteFirst':
dll.popleft()
elif cmd == 'deleteLast':
dll.pop()
if __name__ == '__main__':
# ??????????????\???
commands = []
num = int(input())
for i in range(num):
commands.append([x for x in input().split(' ')])
#commands.append(('insert', '5'))
#commands.append(('insert', '2'))
#commands.append(('insert', '3'))
#commands.append(('insert', '1'))
#commands.append(('delete', '3'))
#commands.append(('insert', '6'))
#commands.append(('delete', '5'))
# ??????
dll = deque()
process_command(dll, commands)
# ???????????????
dll.reverse()
print('{0}'.format(' '.join(map(str, dll)))) |
s137966881 | p02265 | u811733736 | 1480481613 | Python | Python3 | py | Runtime Error | 30 | 8032 | 1319 | from collections import deque
def process_command(dll, commands):
for cmd in commands:
# print(cmd)
if cmd.startswith('insert') or cmd.startswith('delete '):
t = cmd.split(' ')
cmd = t[0]
num_str = t[1]
if cmd == 'insert':
dll.append(int(num_str))
elif cmd == 'delete':
temp = []
result = dll.pop()
while result != int(num_str):
temp.append(result)
result = dll.pop()
temp = temp[::-1]
dll.extend(temp)
elif cmd == 'deleteFirst':
dll.pop()
elif cmd == 'deleteLast':
dll.popleft()
# print(dll)
# print('=' * 64)
if __name__ == '__main__':
# ??????????????\???
commands = []
num = int(input())
for i in range(num):
commands.append(input())
#commands.append(('insert', '5'))
#commands.append(('insert', '2'))
#commands.append(('insert', '3'))
#commands.append(('insert', '1'))
#commands.append(('delete', '3'))
#commands.append(('insert', '6'))
#commands.append(('delete', '5'))
# ??????
dll = deque()
process_command(dll, commands)
# ???????????????
dll.reverse()
print('{0}'.format(' '.join(map(str, dll)))) |
s624113418 | p02265 | u811733736 | 1480482345 | Python | Python3 | py | Runtime Error | 30 | 7944 | 1071 | from collections import deque
def process_command(dll, commands):
for cmd in commands:
# print(cmd)
if cmd.startswith('insert') or cmd.startswith('delete '):
t = cmd.split(' ')
cmd = t[0]
num_str = t[1]
if cmd == 'insert':
dll.appendleft(int(num_str))
elif cmd == 'delete':
temp = []
result = dll.popleft()
while result != int(num_str):
temp.append(result)
result = dll.popleft()
temp = temp[::-1]
dll.extendleft(temp)
elif cmd == 'deleteFirst':
dll.popleft()
elif cmd == 'deleteLast':
dll.pop()
# print(dll)
# print('=' * 64)
if __name__ == '__main__':
# ??????????????\???
commands = []
num = int(input())
for i in range(num):
commands.append(input())
# ??????
dll = deque()
process_command(dll, commands)
# ???????????????
# dll.reverse()
print('{0}'.format(' '.join(map(str, dll)))) |
s605810999 | p02265 | u742013327 | 1480579336 | Python | Python3 | py | Runtime Error | 0 | 0 | 1980 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????
#??¬?????????????????¬????????§????????¨???????????????????????????dummy????????????????????¨??§???????????????????????????????????§??????
def dll_processor(operations):
front = None
for o in operations:
opcode = o[0]
if opcode == "insert":
front = insert(front, { "next":None, "prev":None, "data":o[1] })
elif opcode == "delete":
front = delete(front, o[1])
elif opcode == "deleteFirst":
front = delete_first(front)
elif opcode == "deleteLast":
delete_last(front)
#print(get_list(front))
return get_list(front)
def get_list(front):
l = []
target = front
while True:
l.append(target["data"])
if not target["next"]:
break
target = target["next"]
return l
def insert(front, target):
if front:
front["prev"] = target
target["next"] = front
return target
def delete(front, target):
delete_node = front
while not delete_node["data"] == target:
delete_node = delete_node["next"]
if delete_node["prev"] == None:
delete_node["next"]["prev"] = None
return delete_node["next"]
elif delete_node["next"] == None:
delete_node["prev"]["next"] = None
return front
else:
delete_node["next"]["prev"] = delete_node["prev"]
delete_node["prev"]["next"] = delete_node["next"]
return front
def delete_last(front):
last = front
while front["next"]:
last = last["next"]
last["prev"]["next"] = None
def delete_first(front):
front["next"]["prev"] = None
return front["next"]
def main():
n_list = int(input())
target_list = [input().split() for i in range(n_list)]
print(*dll_processor(target_list))
if __name__ == "__main__":
main() |
s526378743 | p02265 | u742013327 | 1480579525 | Python | Python3 | py | Runtime Error | 30 | 7772 | 2009 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????
#??¬?????????????????¬????????§????????¨???????????????????????????dummy????????????????????¨??§???????????????????????????????????§??????
def dll_processor(operations):
front = None
for o in operations:
opcode = o[0]
if opcode == "insert":
front = insert(front, { "next":None, "prev":None, "data":o[1] })
elif opcode == "delete":
front = delete(front, o[1])
elif opcode == "deleteFirst":
front = delete_first(front)
elif opcode == "deleteLast":
delete_last(front)
#print(front["data"])
#print(get_list(front))
return get_list(front)
def get_list(front):
l = []
target = front
while True:
l.append(target["data"])
if not target["next"]:
break
target = target["next"]
return l
def insert(front, target):
if front:
front["prev"] = target
target["next"] = front
return target
def delete(front, target):
delete_node = front
while not delete_node["data"] == target:
delete_node = delete_node["next"]
if delete_node["prev"] == None:
delete_node["next"]["prev"] = None
return delete_node["next"]
elif delete_node["next"] == None:
delete_node["prev"]["next"] = None
return front
else:
delete_node["next"]["prev"] = delete_node["prev"]
delete_node["prev"]["next"] = delete_node["next"]
return front
def delete_last(front):
last = front
while last["next"]:
last = last["next"]
last["prev"]["next"] = None
def delete_first(front):
front["next"]["prev"] = None
return front["next"]
def main():
n_list = int(input())
target_list = [input().split() for i in range(n_list)]
print(*dll_processor(target_list))
if __name__ == "__main__":
main() |
s531189472 | p02265 | u742013327 | 1480579653 | Python | Python3 | py | Runtime Error | 30 | 7748 | 2066 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????
#??¬?????????????????¬????????§????????¨???????????????????????????dummy????????????????????¨??§???????????????????????????????????§??????
def dll_processor(operations):
front = None
for o in operations:
opcode = o[0]
if opcode == "insert":
front = insert(front, { "next":None, "prev":None, "data":o[1] })
elif opcode == "delete":
front = delete(front, o[1])
elif opcode == "deleteFirst":
front = delete_first(front)
elif opcode == "deleteLast":
delete_last(front)
#print(front["data"])
#print(get_list(front))
return get_list(front)
def get_list(front):
l = []
target = front
while True:
l.append(target["data"])
if not target["next"]:
break
target = target["next"]
return l
def insert(front, target):
if front:
front["prev"] = target
target["next"] = front
return target
def delete(front, target):
delete_node = front
while not delete_node["data"] == target:
delete_node = delete_node["next"]
if delete_node == None:
return front
if delete_node["prev"] == None:
delete_node["next"]["prev"] = None
return delete_node["next"]
elif delete_node["next"] == None:
delete_node["prev"]["next"] = None
return front
else:
delete_node["next"]["prev"] = delete_node["prev"]
delete_node["prev"]["next"] = delete_node["next"]
return front
def delete_last(front):
last = front
while last["next"]:
last = last["next"]
last["prev"]["next"] = None
def delete_first(front):
front["next"]["prev"] = None
return front["next"]
def main():
n_list = int(input())
target_list = [input().split() for i in range(n_list)]
print(*dll_processor(target_list))
if __name__ == "__main__":
main() |
s965807690 | p02265 | u742013327 | 1480580072 | Python | Python3 | py | Runtime Error | 20 | 7856 | 2157 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????
#??¬?????????????????¬????????§????????¨???????????????????????????dummy????????????????????¨??§???????????????????????????????????§??????
def dll_processor(operations):
front = None
for o in operations:
opcode = o[0]
if opcode == "insert":
front = insert(front, { "next":None, "prev":None, "data":o[1] })
elif opcode == "delete":
front = delete(front, o[1])
elif opcode == "deleteFirst":
front = delete_first(front)
elif opcode == "deleteLast":
front = delete_last(front)
#print(get_list(front))
return get_list(front)
def get_list(front):
if not front:
return []
l = []
target = front
while True:
l.append(target["data"])
if not target["next"]:
break
target = target["next"]
return l
def insert(front, target):
if front:
front["prev"] = target
target["next"] = front
return target
def delete(front, target):
delete_node = front
while not delete_node["data"] == target:
delete_node = delete_node["next"]
if delete_node == None:
return front
if delete_node["prev"] == None:
delete_node["next"]["prev"] = None
return delete_node["next"]
elif delete_node["next"] == None:
delete_node["prev"]["next"] = None
return front
else:
delete_node["next"]["prev"] = delete_node["prev"]
delete_node["prev"]["next"] = delete_node["next"]
return front
def delete_last(front):
last = front
while last["next"]:
last = last["next"]
if last == front:
return None
else:
last["prev"]["next"] = None
return front
def delete_first(front):
front["next"]["prev"] = None
return front["next"]
def main():
n_list = int(input())
target_list = [input().split() for i in range(n_list)]
print(*dll_processor(target_list))
if __name__ == "__main__":
main() |
s718482918 | p02265 | u742013327 | 1480588797 | Python | Python3 | py | Runtime Error | 30 | 7904 | 2285 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????
#??¬?????????????????¬????????§????????¨???????????????????????????dummy????????????????????¨??§???????????????????????????????????§??????
import gc
def dll_processor(operations):
front = None
end = None
for o in operations:
if o[0] == "insert":
front, end = insert(front, end,{ "next":None, "prev":None, "data":o[1] })
elif o[0] == "delete":
front, end = delete(front, end, o[1])
elif o[0] == "deleteFirst":
front = delete_first(front)
elif o[0] == "deleteLast":
end = delete_last(end)
gc.collect()
#print(get_list(front))
return get_list(front)
def get_list(front):
if not front:
return []
l = []
target = front
while True:
l.append(target["data"])
if not target["next"]:
break
target = target["next"]
return l
def insert(front, end, target):
if front:
front["prev"] = target
target["next"] = front
return target, end
else:
return target, target
def delete(front, end,target):
delete_node = front
while not delete_node["data"] == target:
delete_node = delete_node["next"]
if delete_node == None:
return front
if delete_node["prev"] == None:
delete_node["next"]["prev"] = None
return delete_node["next"], end
elif delete_node["next"] == None:
delete_node["prev"]["next"] = None
return front, delete_node["prev"]
else:
delete_node["next"]["prev"] = delete_node["prev"]
delete_node["prev"]["next"] = delete_node["next"]
return front, end
def delete_last(end):
if not end["prev"]:
return None
else:
end["prev"]["next"] = None
return end["prev"]
def delete_first(front):
if not front["next"]:
return None
else:
front["next"]["prev"] = None
return front["next"]
def main():
n_list = int(input())
target_list = [input().split() for i in range(n_list)]
print(*dll_processor(target_list))
if __name__ == "__main__":
main() |
s325715284 | p02265 | u742013327 | 1480589426 | Python | Python3 | py | Runtime Error | 20 | 7804 | 2542 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????
#??¬?????????????????¬????????§????????¨???????????????????????????dummy????????????????????¨??§???????????????????????????????????§??????
def dll_processor(operations):
front = None
end = None
for o in operations:
if o[0] == "insert":
front, end = insert(front, end,{ "next":None, "prev":None, "data":o[1] })
elif o[0] == "delete":
front, end = delete(front, end, o[1])
elif o[0] == "deleteFirst":
front, end = delete_first(front, end)
elif o[0] == "deleteLast":
front, end = delete_last(front, end)
#print(get_list(front))
return get_list(front)
def get_list(front):
if not front:
return []
l = []
target = front
while True:
l.append(target["data"])
if not target["next"]:
break
target = target["next"]
return l
def insert(front, end, target):
if front:
front["prev"] = target
target["next"] = front
return target, end
else:
return target, target
def delete(front, end,target):
delete_node = front
while not delete_node["data"] == target:
delete_node = delete_node["next"]
if delete_node == None:
return front, end
if delete_node["prev"] == None:
delete_node["next"]["prev"] = None
tmp = delete_node["next"]
del delte_node
return tmp, end
elif delete_node["next"] == None:
delete_node["prev"]["next"] = None
tmp = delete_node["prev"]
del delete_node
return front, tmp
else:
delete_node["next"]["prev"] = delete_node["prev"]
delete_node["prev"]["next"] = delete_node["next"]
del delete_node
return front, end
def delete_last(front, end):
if not end["prev"]:
del front, end
return None, None
else:
end["prev"]["next"] = None
tmp = end["prev"]
del end
return front, tmp
def delete_first(front, end):
if not front["next"]:
del front, end
return None, None
else:
front["next"]["prev"] = None
tmp = front["next"]
del front
return tmp, end
def main():
n_list = int(input())
target_list = [input().split() for i in range(n_list)]
print(*dll_processor(target_list))
if __name__ == "__main__":
main() |
s042042438 | p02265 | u742013327 | 1480591585 | Python | Python3 | py | Runtime Error | 0 | 0 | 2149 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????
NEXT = 2
DATA = 1
PREV = 0
def dll_processor(operations):
front = None
end = None
for i,o in enumerate(operations):
if o[0] == "insert":
front, end = insert(front, end, tuple(None, int(o[1]), None))
elif o[0] == "delete":
front, end = delete(front, end, int(o[1]))
elif o[0] == "deleteFirst":
front, end = delete_first(front, end)
elif o[0] == "deleteLast":
front, end = delete_last(front, end)
#print(get_list(front))
return get_list(front)
def get_list(front):
if not front:
return []
l = []
target = front
while True:
l.append(target[DATA])
if not target[NEXT]:
break
target = target[NEXT]
return l
def insert(front, end, target):
if front:
front[PREV] = target
target[NEXT] = front
return target, end
else:
return target, target
def delete(front, end,target):
delete_node = front
while not delete_node[DATA] == target:
delete_node = delete_node[NEXT]
if delete_node == None:
return front, end
if delete_node[PREV] == None:
delete_node[NEXT][PREV] = None
return delete_node[NEXT], end
elif delete_node[NEXT] == None:
delete_node[PREV][NEXT] = None
return front, delete_node[PREV]
else:
delete_node[NEXT][PREV] = delete_node[PREV]
delete_node[PREV][NEXT] = delete_node[NEXT]
return front, end
def delete_last(front, end):
if not end[PREV]:
return None, None
else:
end[PREV][NEXT] = None
return front, end[PREV]
def delete_first(front, end):
if not front[NEXT]:
return None, None
else:
front[NEXT][PREV] = None
return front[NEXT], end
def main():
n_list = int(input())
target_list = [input().split() for i in range(n_list)]
print(*dll_processor(target_list))
if __name__ == "__main__":
main() |
s675140345 | p02265 | u742013327 | 1480591628 | Python | Python3 | py | Runtime Error | 0 | 0 | 2151 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#???????????£????????????
NEXT = 2
DATA = 1
PREV = 0
def dll_processor(operations):
front = None
end = None
for i,o in enumerate(operations):
if o[0] == "insert":
front, end = insert(front, end, tuple([None, int(o[1]), None]))
elif o[0] == "delete":
front, end = delete(front, end, int(o[1]))
elif o[0] == "deleteFirst":
front, end = delete_first(front, end)
elif o[0] == "deleteLast":
front, end = delete_last(front, end)
#print(get_list(front))
return get_list(front)
def get_list(front):
if not front:
return []
l = []
target = front
while True:
l.append(target[DATA])
if not target[NEXT]:
break
target = target[NEXT]
return l
def insert(front, end, target):
if front:
front[PREV] = target
target[NEXT] = front
return target, end
else:
return target, target
def delete(front, end,target):
delete_node = front
while not delete_node[DATA] == target:
delete_node = delete_node[NEXT]
if delete_node == None:
return front, end
if delete_node[PREV] == None:
delete_node[NEXT][PREV] = None
return delete_node[NEXT], end
elif delete_node[NEXT] == None:
delete_node[PREV][NEXT] = None
return front, delete_node[PREV]
else:
delete_node[NEXT][PREV] = delete_node[PREV]
delete_node[PREV][NEXT] = delete_node[NEXT]
return front, end
def delete_last(front, end):
if not end[PREV]:
return None, None
else:
end[PREV][NEXT] = None
return front, end[PREV]
def delete_first(front, end):
if not front[NEXT]:
return None, None
else:
front[NEXT][PREV] = None
return front[NEXT], end
def main():
n_list = int(input())
target_list = [input().split() for i in range(n_list)]
print(*dll_processor(target_list))
if __name__ == "__main__":
main() |
s848326428 | p02265 | u611490888 | 1481171274 | Python | Python3 | py | Runtime Error | 30 | 7992 | 1490 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
''' ???????????£???????????? '''
from collections import deque
functions = {"insert": lambda obj, x: obj.insert(x),
"delete": lambda obj, x: obj.delete(x),
"deleteFirst": lambda obj: obj.deleteFirst(),
"deleteLast": lambda obj: obj.deleteLast()}
class DoublyLinkedList(object):
""" Doubly Linked List """
def __init__(self):
# self.list = []
self.list = deque()
def insert(self, x):
""" ???????????????x?????????????´?????????\ """
# self.list = [x] + self.list
self.list.appendleft(x)
def delete(self, x):
""" ??????x??????????????????????´?????????? """
# for i in range(len(self.list)):
# if self.list[i] == x:
# self.list.pop(i)
# break
# if x in self.list:
self.list.remove(x)
def deleteFirst(self):
""" ?????????????????????????´?????????? """
# self.list.pop(0)
self.list.popleft()
def deleteLast(self):
""" ????????????????°????????´?????????? """
self.list.pop()
if __name__ == '__main__':
N = int(input())
dll = DoublyLinkedList()
for i in range(N):
command = input().split()
if len(command) == 1:
functions[command[0]](dll)
elif len(command) == 2:
functions[command[0]](dll, int(command[1]))
print(' '.join(map(str, dll.list))) |
s984912797 | p02265 | u908984540 | 1483191297 | Python | Python3 | py | Runtime Error | 20 | 7660 | 432 | # -*- coding:utf-8 -*-
result = list()
def operation(command):
if command[0] == "insert":
result.insert(0, int(command[1]))
elif command[0] == "delete":
result.remove(int(command[1]))
elif command[0] == "deleteFirst":
result.pop(0)
elif command[0] == "deleteLast":
result.pop()
n = int(input())
for i in range(n):
command = input().split()
operation(command)
print(*result) |
s166600619 | p02265 | u089830331 | 1483658511 | Python | Python3 | py | Runtime Error | 30 | 7740 | 374 | arr = []
for i in range(int(input())):
command_line = input().split(" ")
command = command_line[0]
arg = ""
if len(command_line) > 1: arg = command_line[1]
if command == "insert":
arr.insert(0, arg)
if command == "delete":
arr.remove(arg)
if command == "deleteFirst":
del arr[0]
if command == "deleteLast":
del arr[-1]
print(" ".join(arr)) |
s242681486 | p02265 | u370086573 | 1483943603 | Python | Python3 | py | Runtime Error | 30 | 7980 | 350 | from collections import deque
n = int(input())
Q = deque()
for i in range(n):
comand = input().split()
if comand[0] == "insert":
Q.appendleft(comand[1])
elif comand[0] == "delete":
Q.remove(comand[1])
elif comand[0] == "deleteFirst":
Q.popleft()
elif comand[0] == "deleteLast":
Q.pop()
print(*Q) |
s941841820 | p02265 | u370086573 | 1483943711 | Python | Python3 | py | Runtime Error | 30 | 7856 | 350 | from collections import deque
n = int(input())
Q = deque()
for i in range(n):
comand = input().split()
if comand[0] == "insert":
Q.appendleft(comand[1])
elif comand[0] == "delete":
Q.remove(comand[1])
elif comand[0] == "deleteFirst":
Q.popleft()
elif comand[0] == "deleteLast":
Q.pop()
print(*Q) |
s216534520 | p02265 | u923668099 | 1484094429 | Python | Python3 | py | Runtime Error | 0 | 0 | 445 |
from collections import deque
n = int(input())
linked_list = deque([])
for i in range(n):
line = input().split()
cmd = line[0]
if len(line) == 2:
value = line[1]
if cmd == "insert":
linked_list.insert(0, value)
elif cmd == "delete":
linked_list.remove(value)
elif cmd == "deleteFirst":
linked_list.popleft()
elif cmd == "deleteLast":
linked_list.pop()
print(*linked_list) |
s267264030 | p02265 | u923668099 | 1484095038 | Python | Python3 | py | Runtime Error | 30 | 7988 | 446 |
from collections import deque
n = int(input())
linked_list = deque([])
for i in range(n):
line = input().split()
cmd = line[0]
if len(line) == 2:
value = line[1]
if cmd == "insert":
linked_list.appendleft(value)
elif cmd == "delete":
linked_list.remove(value)
elif cmd == "deleteFirst":
linked_list.popleft()
elif cmd == "deleteLast":
linked_list.pop()
print(*linked_list) |
s639483164 | p02265 | u941958472 | 1484197148 | Python | Python3 | py | Runtime Error | 20 | 7728 | 504 | # f = open('input.txt')
n = int(input())
# n = int(f.readline())
doubly_linked_list = []
for i in range(n):
cmd = input()
# cmd = f.readline().strip()
if cmd == 'deleteFirst':
doubly_linked_list.pop(0)
elif cmd == 'deleteLast':
doubly_linked_list.pop(-1)
else:
cmd, x = cmd.split()
if cmd == 'insert':
doubly_linked_list.append(x)
elif cmd == 'delete':
doubly_linked_list.remove(x)
print(' '.join(doubly_linked_list)) |
s744228456 | p02265 | u941958472 | 1484197777 | Python | Python3 | py | Runtime Error | 20 | 7648 | 507 | # f = open('input.txt')
n = int(input())
# n = int(f.readline())
doubly_linked_list = []
for i in range(n):
cmd = input()
# cmd = f.readline().strip()
if cmd == 'deleteFirst':
doubly_linked_list.pop(0)
elif cmd == 'deleteLast':
doubly_linked_list.pop(-1)
else:
cmd, x = cmd.split()
if cmd == 'insert':
doubly_linked_list.insert(0, x)
elif cmd == 'delete':
doubly_linked_list.remove(x)
print(' '.join(doubly_linked_list)) |
s924989832 | p02265 | u436587708 | 1484441979 | Python | Python3 | py | Runtime Error | 20 | 7740 | 364 | n = int(input())
l = []
for _ in range(n):
command = input().split()
if command[0] == "insert":
l.append(command[1])
elif command[0] == "delete":
ind = l.index(command[1])
l.pop(ind)
elif command[0] == "deleteFirst":
l.pop(0)
elif command[0] == "deleteLast":
l.pop(-1)
print (" ".join(l[::-1])) |
s231936140 | p02265 | u303093818 | 1484470852 | Python | Python3 | py | Runtime Error | 30 | 7672 | 426 | def show(A):
for i in range(len(A) - 1):
print(A[i], end=" ")
print(A[len(A) - 1])
list = []
n = int(input())
for i in range(n):
line = input().split()
if line[0] == 'insert':
list.insert(0, int(line[1]))
if line[0] == 'delete':
list.remove(int(line[1]))
if line[0] == 'deleteFirst':
list.remove(list[0])
if line[0] == 'deleteLast':
list.pop()
show(list) |
s003534056 | p02265 | u918276501 | 1485056235 | Python | Python3 | py | Runtime Error | 0 | 0 | 279 | l = []
n = int(input())
for _ in range(n):
c, *i = input().split()
if c == 'insert':
l = [*i, *l]
elif c == 'delete':
l.remove(*i)
elif c == 'deleteFirst':
del l[0]
elif c == 'deleteLast':
del l[len(l)-1]
else:
pass |
s573229968 | p02265 | u918276501 | 1485056322 | Python | Python3 | py | Runtime Error | 0 | 0 | 289 | l = []
n = int(input())
for _ in range(n):
c, *i = input().split()
if c == 'insert':
l = [*i, *l]
elif c == 'delete':
l.remove(*i)
elif c == 'deleteFirst':
del l[0]
elif c == 'deleteLast':
del l[len(l)-1]
else:
pass
print(*l) |
s437974432 | p02265 | u918276501 | 1485056600 | Python | Python3 | py | Runtime Error | 0 | 0 | 289 | l = []
n = int(input())
for _ in range(n):
c, *i = input().split()
if c == 'insert':
l = [*i, *l]
elif c == 'delete':
l.remove(*i)
elif c == 'deleteFirst':
del l[0]
elif c == 'deleteLast':
del l[len(l)-1]
else:
pass
print(*l) |
s815107630 | p02265 | u918276501 | 1485066512 | Python | Python3 | py | Runtime Error | 30 | 7944 | 307 | import sys
from collections import deque
n = int(sys.stdin.readline())
q = deque()
for i in range(n):
c = sys.stdin.readline()[:-1]
if c[0] == 'i':
q.appendleft(c[7:])
elif c[6] == ' ':
q.remove(c[7:])
elif c[6] == 'F':
q.popleft()
else:
q.pop()
print(*q) |
s668836259 | p02265 | u600065151 | 1485578979 | Python | Python3 | py | Runtime Error | 30 | 7988 | 380 | from collections import deque
order = int(input())
llist = [input().split() for _ in range(order)]
ans = deque([])
for lst in llist:
if lst[0] == 'insert':
ans.appendleft(lst[1])
elif lst[0] == 'delete':
ans.remove(lst[1])
elif lst[0] == 'deleteFirst':
ans.popleft()
elif lst[0] == 'deleteLast':
ans.pop()
print(*ans) |
s159233673 | p02265 | u711765449 | 1486224430 | Python | Python3 | py | Runtime Error | 30 | 7768 | 605 | n = int(input())
arr = []
for i in range(n):
c = input()
try:
tmp = c.split()
com = str(tmp[0])
num = int(tmp[1])
except:
com = str(c)
num = -1
if num != -1:
if com == 'insert':
arr.insert(0,num)
if com == 'delete':
ind = arr.index(num)
arr.pop(ind)
else:
if com == 'deleteFirst':
arr.pop(0)
if com == 'deleteLast':
arr.pop()
if len(arr) != 1:
for i in range(len(arr)-1):
print(arr[i], end = ' ')
print(arr[-1])
else:
print(arr[0]) |
s436616794 | p02265 | u917432951 | 1486541071 | Python | Python3 | py | Runtime Error | 20 | 7760 | 390 | n = int(input())
data_input = []
for i in range(n):
data_input.append(input().split())
dlList = []
for x in data_input:
if x[0] == 'insert':
dlList.insert(0,x[1])
elif x[0] == 'delete':
dlList.remove(x[1])
elif x[0] == 'deleteFirst':
dlList.pop(0)
elif x[0] == 'deleteLast':
dlList.pop()
else:
pass
print(' '.join(dlList)) |
s162094367 | p02265 | u831244171 | 1487212691 | Python | Python3 | py | Runtime Error | 0 | 0 | 419 | from collections import deque
n = int(input())
Q = deque()
for i in range(n):
command = input().split()
if command[0] == "insert":
Q.appendleft(command[1])
elif command[0] == "deleteFirst":
Q.popleft()
elif command[0] == "deleteLast":
Q.popright()
elif command[0] == "delete":
try:
Q.remove(command[1])
except:
pass
print(" ".join(Q)) |
s609248396 | p02265 | u656153606 | 1487412604 | Python | Python3 | py | Runtime Error | 0 | 0 | 483 | def operation(command, num, arrey):
if command == 'insert':
arrey.insert(0,num)
return arrey
elif command == 'delete':
if num in arrey:
arrey.remove(num)
elif command == 'deleteFirst':
arrey.pop(0)
elif command == 'deleteLast':
arrey.pop(-1)
n = int(input())
list = []
for i in range(n):
command, num = input().split()
operation(command,num,list)
for i in range(len(list)):
print(list[i]+' ',end='') |
s755748489 | p02265 | u656153606 | 1487413956 | Python | Python3 | py | Runtime Error | 0 | 0 | 578 | from collections import deque
def operation(command, arrey):
if command[0] == 'insert':
arrey.insert(0,command[1])
return arrey
elif command[0] == 'delete':
if command[1] in arrey:
arrey.remove(command[1])
elif command[0] == 'deleteFirst':
arrey.pop(0)
elif command[0] == 'deleteLast':
arrey.pop(-1)
n = int(input())
list = deque()
for i in range(n):
command = input().split()
operation(command,list)
for i in range(len(list)):
print(list[i]) if i == len(list)-1 else print(list[i]+' ',end='') |
s894168560 | p02265 | u656153606 | 1487414102 | Python | Python3 | py | Runtime Error | 0 | 0 | 579 | from collections import deque
def operation(command, arrey):
if command[0] == 'insert':
arrey.insert(0,command[1])
return arrey
elif command[0] == 'delete':
if command[1] in arrey:
arrey.remove(command[1])
elif command[0] == 'deleteFirst':
arrey.popleft()
elif command[0] == 'deleteLast':
arrey.pop()
n = int(input())
list = deque()
for i in range(n):
command = input().split()
operation(command,list)
for i in range(len(list)):
print(list[i]) if i == len(list)-1 else print(list[i]+' ',end='') |
s579679299 | p02265 | u656153606 | 1487414186 | Python | Python3 | py | Runtime Error | 0 | 0 | 535 | from collections import deque
def operation(command, arrey):
if command[0] == 'insert':
arrey.insert(0,command[1])
return arrey
elif command[0] == 'delete':
if command[1] in arrey:
arrey.remove(command[1])
elif command[0] == 'deleteFirst':
arrey.popleft()
elif command[0] == 'deleteLast':
arrey.pop()
n = int(input())
list = deque()
for i in range(n):
command = input().split()
operation(command,list)
for i in range(len(list)):
print(' '.join(list)) |
s908366905 | p02265 | u656153606 | 1487414300 | Python | Python3 | py | Runtime Error | 0 | 0 | 504 | from collections import deque
def operation(command, arrey):
if command[0] == 'insert':
arrey.insert(0,command[1])
return arrey
elif command[0] == 'delete':
if command[1] in arrey:
arrey.remove(command[1])
elif command[0] == 'deleteFirst':
arrey.popleft()
elif command[0] == 'deleteLast':
arrey.pop()
n = int(input())
list = deque()
for i in range(n):
command = input().split()
operation(command,list)
print(' '.join(list)) |
s877518273 | p02265 | u656153606 | 1487414487 | Python | Python3 | py | Runtime Error | 0 | 0 | 504 | from collections import deque
def operation(command, arrey):
if command[0] == 'insert':
arrey.insert(0,command[1])
return arrey
elif command[0] == 'delete':
if command[1] in arrey:
arrey.remove(command[1])
elif command[0] == 'deleteFirst':
arrey.popleft()
elif command[0] == 'deleteLast':
arrey.pop()
n = int(input())
list = deque()
for i in range(n):
command = input().split()
operation(command,list)
print(' '.join(list)) |
s794980370 | p02265 | u656153606 | 1487414770 | Python | Python3 | py | Runtime Error | 0 | 0 | 505 | from collections import deque
def operation(command, arrey):
if command[0] == 'insert':
arrey.insert(0,command[1])
return arrey
elif command[0] == 'delete':
if command[1] in arrey:
arrey.remove(command[1])
elif command[0] == 'deleteFirst':
arrey.popleft()
elif command[0] == 'deleteLast':
arrey.pop()
n = int(input())
list = deque()
for i in range(n):
command = input().split()
operation(command,list)
print(' '.join(list)) |
s867537194 | p02265 | u656153606 | 1487415000 | Python | Python3 | py | Runtime Error | 0 | 0 | 541 | from collections import deque
import sys
def operation(command, arrey):
if command[0] == 'insert':
arrey.insert(0,command[1])
return arrey
elif command[0] == 'delete':
if command[1] in arrey:
arrey.remove(command[1])
elif command[0] == 'deleteFirst':
arrey.popleft()
elif command[0] == 'deleteLast':
arrey.pop()
n = int(sys.stdin.readline())
list = deque()
for i in range(n):
command = sys.stdin.readline().split()
operation(command,list)
print(' '.join(list)) |
s231373003 | p02265 | u895660619 | 1488402492 | Python | Python3 | py | Runtime Error | 0 | 0 | 2317 | class Node:
elm = None
nxt = None
prev = None
def __init__(self, elm=None, prev=None, nxt=None):
self.elm = elm
self.prev = prev
self.nxt = nxt
class MyDLList:
size = 0
head = tail = None
def insert(self, elm):
if self.is_empty():
self.head = self.tail = Node(elm)
else:
x = Node(elm)
x.nxt = self.head
self.head.prev = x
self.head = x
self.size += 1
def list_search(self, x):
cur = self.head
while cur != self.tail and cur.elm != x:
cur = cur.nxt
if cur.elm != x:
cur = None
return cur
def delete(self, x):
cur = self.list_search(x)
if cur:
if cur == self.head:
self.delete_first()
elif cur == self.tail:
self.delete_last()
else:
cur.prev.nxt = cur.nxt
cur.nxt.prev = cur.prev
self.size -= 1
return cur.elm
def delete_first(self):
cur = self.head
if not self.is_empty():
if self.head != self.tail:
self.head.nxt.prev = None
self.head = self.head.nxt
else:
self.head = self.tail = None
self.size -= 1
return cur.elm
def delete_last(self):
cur = self.tail
if not self.is_empty():
if self.head != self.tail:
self.tail.prev.nxt = None
self.tail = self.tail.prev
else:
self.tail = self.head = None
self.size -= 1
return cur.elm
def is_empty(self):
return self.size == 0
def __str__(self):
cur = self.head
output = ""
while cur.nxt:
output += int(cur.elm), " "
cur = cur.nxt
output += int(cur.elm)
return output
n = int(input())
V = [list(map(str, input().split())) for _ in range(n)]
dl = MyDLList()
for i in V:
if i[0] == "insert":
dl.insert(int(i[1]))
elif i[0] == "delete":
dl.delete(int(i[1]))
elif i[0] == "deleteFirst":
dl.delete_first()
elif i[0] == "deleteLast":
dl.delete_last()
print(dl) |
s154631250 | p02265 | u895660619 | 1488402532 | Python | Python3 | py | Runtime Error | 30 | 7800 | 2309 | class Node:
elm = None
nxt = None
prev = None
def __init__(self, elm=None, prev=None, nxt=None):
self.elm = elm
self.prev = prev
self.nxt = nxt
class MyDLList:
size = 0
head = tail = None
def insert(self, elm):
if self.is_empty():
self.head = self.tail = Node(elm)
else:
x = Node(elm)
x.nxt = self.head
self.head.prev = x
self.head = x
self.size += 1
def list_search(self, x):
cur = self.head
while cur != self.tail and cur.elm != x:
cur = cur.nxt
if cur.elm != x:
cur = None
return cur
def delete(self, x):
cur = self.list_search(x)
if cur:
if cur == self.head:
self.delete_first()
elif cur == self.tail:
self.delete_last()
else:
cur.prev.nxt = cur.nxt
cur.nxt.prev = cur.prev
self.size -= 1
return cur.elm
def delete_first(self):
cur = self.head
if not self.is_empty():
if self.head != self.tail:
self.head.nxt.prev = None
self.head = self.head.nxt
else:
self.head = self.tail = None
self.size -= 1
return cur.elm
def delete_last(self):
cur = self.tail
if not self.is_empty():
if self.head != self.tail:
self.tail.prev.nxt = None
self.tail = self.tail.prev
else:
self.tail = self.head = None
self.size -= 1
return cur.elm
def is_empty(self):
return self.size == 0
def __str__(self):
cur = self.head
output = ""
while cur.nxt:
output += str(cur.elm), " "
cur = cur.nxt
output += str(cur.elm)
return output
n = int(input())
V = [list(map(str, input().split())) for _ in range(n)]
dl = MyDLList()
for i in V:
if i[0] == "insert":
dl.insert(int(i[1]))
elif i[0] == "delete":
dl.delete(int(i[1]))
elif i[0] == "deleteFirst":
dl.delete_first()
elif i[0] == "deleteLast":
dl.delete_last()
print(dl) |
s940339760 | p02265 | u895660619 | 1488404263 | Python | Python3 | py | Runtime Error | 0 | 0 | 2240 | class Node:
elm = None
nxt = None
prev = None
def __init__(self, elm=None, prev=None, nxt=None):
self.elm = elm
self.prev = prev
self.nxt = nxt
class MyDLList:
size = 0
head = tail = None
def insert(self, elm):
if self.is_empty():
self.head = self.tail = Node(elm)
else:
x = Node(elm)
x.nxt = self.head
self.head.prev = x
self.head = x
self.size += 1
def list_search(self, x):
cur = self.head
if cur != self.tail:
i = 0
while i < self.size and cur.elm != x:
cur = cur.nxt
i += 1
if cur.elm != x:
cur = None
return cur
def delete(self, x):
cur = self.list_search(x)
if cur:
if cur == self.head:
self.delete_first()
elif cur == self.tail:
self.delete_last()
else:
cur.prev.nxt = cur.nxt
cur.nxt.prev = cur.prev
self.size -= 1
return cur.elm
def delete_first(self):
cur = self.head
if self.size != 1:
self.head.nxt.prev = None
self.head = self.head.nxt
else:
self.head = self.tail = None
self.size -= 1
return cur.elm
def delete_last(self):
cur = self.tail
if self.size != 1:
self.tail.prev.nxt = None
self.tail = self.tail.prev
else:
self.tail = self.head = None
self.size -= 1
return cur.elm
def is_empty(self):
return self.size == 0
def __str__(self):
cur = self.head
output = ""
while cur.nxt:
output += str(cur.elm) + " "
cur = cur.nxt
output += str(cur.elm)
return output
n = int(input())
dl = MyDLList()
for i in range(n):
x = list(map(str, input().split()))
if x[0] == "insert":
dl.insert(int(x[1]))
elif x[0] == "delete":
dl.delete(int(x[1]))
elif x[0] == "deleteFirst":
dl.delete_first()
elif x[0] == "deleteLast":
dl.delete_last()
print(dl) |
s423262320 | p02265 | u895660619 | 1488412985 | Python | Python3 | py | Runtime Error | 20 | 7896 | 2778 | class Node:
elm = None
nxt = None
prev = None
def __init__(self, elm=None, prev=None, nxt=None):
self.elm = elm
self.prev = prev
self.nxt = nxt
class MyDLList:
size = 0
head = tail = None
dic = dict()
def insert(self, elm):
if self.is_empty():
self.dic[elm] = Node(elm)
self.head = self.tail = self.dic[elm]
else:
self.dic[elm] = Node(elm)
self.dic[elm].nxt = self.head
self.head.prev = self.dic[elm]
self.head = self.dic[elm]
self.size += 1
def list_search(self, x):
# cur = self.head
# if cur != self.tail:
# i = 1
# while i < self.size and cur.elm != x:
# cur = cur.nxt
# i += 1
# if cur.elm != x:
# cur = None
return self.dic.get(x)
def delete(self, x):
cur = self.list_search(x)
if cur:
if cur == self.head:
self.delete_first()
elif cur == self.tail:
self.delete_last()
else:
self.dic.pop(x)
cur.prev.nxt = cur.nxt
cur.nxt.prev = cur.prev
self.size -= 1
return cur.elm
def delete_first(self):
# ????§???§?????°????????¨??????????????????????´???????????????¨???????????????
cur = self.head
if self.size != 1:
self.dic.pop(self.head.elm)
self.head.nxt.prev = None
self.head = self.head.nxt
else:
self.dic.clear()
self.head = self.tail = None
self.size -= 1
return cur.elm
def delete_last(self):
# ????§???§?????°????????¨??????????????????????´???????????????¨???????????????
cur = self.tail
if self.size != 1:
self.dic.pop(self.tail.elm)
self.tail.prev.nxt = None
self.tail = self.tail.prev
else:
self.dic.clear()
self.tail = self.head = None
self.size -= 1
return cur.elm
def is_empty(self):
return self.size == 0
def __str__(self):
cur = self.head
output = ""
i = 1
while i < self.size:
output += str(cur.elm) + " "
cur = cur.nxt
i += 1
output += str(cur.elm)
return output
n = int(input())
dl = MyDLList()
for i in range(n):
x = list(map(str, input().split()))
if x[0] == "insert":
dl.insert(int(x[1]))
elif x[0] == "delete":
dl.delete(int(x[1]))
elif x[0] == "deleteFirst":
dl.delete_first()
elif x[0] == "deleteLast":
dl.delete_last()
print(dl) |
s122222615 | p02265 | u895660619 | 1488426944 | Python | Python3 | py | Runtime Error | 0 | 0 | 395 | from collections import deque
n = int(input())
q = deque()
for i in range(n):
x = list(map(str, input().split()))
if x[0] == "insert":
q.appendleft(int(x[1]))
elif x[0] == "delete":
try:
q.remove(int(x[1]))
except ValueError:
pass
elif x[0] == "deleteFirst":
q.popleft()
elif x[0] == "deleteLast":
q.popright() |
s198615946 | p02265 | u895660619 | 1488427620 | Python | Python3 | py | Runtime Error | 0 | 0 | 360 | from collections import deque
import sys
n = int(input())
q = deque()
for i in range(n):
s = sys.stdin.readlines()
if s[0] == "i":
q.appendleft(s[7])
elif s[6] == "F":
q.popleft()
elif s[6] == "L":
q.pop()
else:
try:
q.remove(s[7])
except ValueError:
pass
print(" ".join(q)) |
s095159765 | p02265 | u970269944 | 1488439429 | Python | Python | py | Runtime Error | 10 | 6372 | 1753 | class Node:
elm = None
next = None
prev = None
class MyQueue:
head = tail = None
def enq(self, x):
n = Node()
n.elm = x
if self.head == None:
self.head = self.tail = n
else:
self.tail.next = n
n.prev = self.tail
self.tail = n
def deq(self):
if self.head == None:
return None
x = self.head.elm
self.head = self.head.next
if self.head: self.head.prev = None
return x
def pop(self):
if self.tail == None:
return None
x = self.tail.elm
self.tail = self.tail.prev
if self.tail: self.tail.next = None
return x
class MyList:
head = tail = None
lookup = {}
def insert(self, x):
n = Node()
n.elm = x
if self.head == None:
self.head = self.tail = n
else:
n.next = self.head
self.head.prev = n
self.head = n
if not x in self.lookup:
self.lookup[x] = MyQueue()
self.lookup[x].enq(n)
def delete(self, x):
n = self.lookup[x].deq()
self.__delete_node(n)
def deleteFirst(self):
self.lookup[self.head.elm].deq()
self.__delete_node(self.head)
def deleteLast(self):
self.lookup[self.tail.elm].pop()
self.__delete_node(self.tail)
def __delete_node(self, n):
if n == None:
return
if n == self.head:
self.head = n.next
if n == self.tail:
self.tail = n.prev
if n.prev:
n.prev.next = n.next
if n.next:
n.next.prev = n.prev
def __traverse(self):
n = self.head
while n:
yield n.elm
n = n.next
def __str__(self):
return " ".join([str(s) for s in self.__traverse()])
myList = MyList()
n = int(raw_input())
for _ in xrange(n):
line = raw_input()
if line[0]=='i':
myList.insert(int(line[7:]))
elif line[6]=='F':
myList.deleteFirst()
elif line[6]=='L':
myList.deleteLast()
else:
myList.delete(int(line[7:]))
print myList |
s037917697 | p02265 | u970269944 | 1488439472 | Python | Python | py | Runtime Error | 10 | 6316 | 1753 | class Node:
elm = None
next = None
prev = None
class MyQueue:
head = tail = None
def enq(self, x):
n = Node()
n.elm = x
if self.head == None:
self.head = self.tail = n
else:
self.tail.next = n
n.prev = self.tail
self.tail = n
def deq(self):
if self.head == None:
return None
x = self.head.elm
self.head = self.head.next
if self.head: self.head.prev = None
return x
def pop(self):
if self.tail == None:
return None
x = self.tail.elm
self.tail = self.tail.prev
if self.tail: self.tail.next = None
return x
class MyList:
head = tail = None
lookup = {}
def insert(self, x):
n = Node()
n.elm = x
if self.head == None:
self.head = self.tail = n
else:
n.next = self.head
self.head.prev = n
self.head = n
if not x in self.lookup:
self.lookup[x] = MyQueue()
self.lookup[x].enq(n)
def delete(self, x):
n = self.lookup[x].deq()
self.__delete_node(n)
def deleteFirst(self):
self.lookup[self.head.elm].deq()
self.__delete_node(self.head)
def deleteLast(self):
self.lookup[self.tail.elm].pop()
self.__delete_node(self.tail)
def __delete_node(self, n):
if n == None:
return
if n == self.head:
self.head = n.next
if n == self.tail:
self.tail = n.prev
if n.prev:
n.prev.next = n.next
if n.next:
n.next.prev = n.prev
def __traverse(self):
n = self.head
while n:
yield n.elm
n = n.next
def __str__(self):
return " ".join([str(s) for s in self.__traverse()])
myList = MyList()
n = int(raw_input())
for _ in xrange(n):
line = raw_input()
if line[0]=='i':
myList.insert(int(line[7:]))
elif line[6]=='F':
myList.deleteFirst()
elif line[6]=='L':
myList.deleteLast()
else:
myList.delete(int(line[7:]))
print myList |
s356941033 | p02265 | u895660619 | 1488493988 | Python | Python3 | py | Runtime Error | 30 | 7816 | 1929 | class MyDLList:
head = tail = None
size = 0
def append_left(self, elm):
if self.is_empty():
self.head = self.tail = [elm, None, None]
# elm, prev, next
else:
cur = [elm, None, self.head]
self.head[1] = cur
self.head = cur
self.size += 1
def is_empty(self):
return self.size == 0
def list_search(self, elm):
cur = self.head
i = 1
while i < self.size and cur[0] != elm:
cur = cur[2]
i += 1
if cur[0] != elm:
cur = None
return cur
def delete(self, elm):
cur = self.list_search(elm)
if cur:
if cur == self.head:
deleted = self.delete_first()
elif cur == self.tail:
deleted = self.delete_last()
else:
deleted = cur[0]
cur[1][2] = cur[2]
cur[2][1] = cur[1]
self.size -= 1
else:
deleted = None
return deleted
def delete_first(self):
cur = self.head
self.head[2][1] = None
self.head = self.head[2]
self.size -= 1
return cur[0]
def delete_last(self):
cur = self.tail
self.tail[1][2] = None
self.tail = self.tail[1]
self.size -= 1
return cur[0]
def __str__(self):
cur = self.head
result = ""
while cur != self.tail:
result += cur[0] + " "
cur = cur[2]
result += cur[0]
return result
n = int(input())
dl = MyDLList()
for i in range(n):
x = list(map(str, input().split()))
if x[0] == "insert":
dl.append_left(x[1])
elif x[0] == "delete":
dl.delete(x[1])
elif x[0] == "deleteFirst":
dl.delete_first()
elif x[0] == "deleteLast":
dl.delete_last()
print(dl) |
s793887821 | p02265 | u370086573 | 1488723377 | Python | Python3 | py | Runtime Error | 30 | 7928 | 401 | from collections import deque
if __name__ == '__main__':
n = int(input())
L = deque()
for i in range(n):
cmd = input().split()
if cmd[0] == 'insert':
L.appendleft(cmd[1])
if cmd[0] == 'delete':
L.remove(cmd[1])
if cmd[0] == 'deleteFirst':
L.popleft()
if cmd[0] == 'deleteLast':
L.pop()
print(*L) |
s126539683 | p02265 | u370086573 | 1488723425 | Python | Python3 | py | Runtime Error | 30 | 7856 | 407 | from collections import deque
if __name__ == '__main__':
n = int(input())
L = deque()
for i in range(n):
cmd = input().split()
if cmd[0] == 'insert':
L.appendleft(cmd[1])
elif cmd[0] == 'delete':
L.remove(cmd[1])
elif cmd[0] == 'deleteFirst':
L.popleft()
elif cmd[0] == 'deleteLast':
L.pop()
print(*L) |
s581214740 | p02265 | u370086573 | 1488723486 | Python | Python3 | py | Runtime Error | 30 | 7924 | 368 | from collections import deque
if __name__ == '__main__':
n = int(input())
L = deque()
for i in range(n):
cmdline = input().split()
if cmdline[0] == "insert":
L.appendleft(cmdline[1])
elif cmdline[0] == "delete":
L.remove(cmdline[1])
elif cmdline[0] == "deleteFirst":
L.popleft()
elif cmdline[0] == "deleteLast":
L.pop()
print(" ".join(L)) |
s678414377 | p02265 | u370086573 | 1488724394 | Python | Python3 | py | Runtime Error | 0 | 0 | 404 | def linearSearch(A, key):
i = 0
A.append(key)
while A[i] != key:
i += 1
if i == n:
return False
return i
if __name__ == '__main__':
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))
cnt = 0
for key in T:
if linearSearch(S,key) is not False:
cnt += 1
print(cnt) |
s273931326 | p02265 | u548155360 | 1489043873 | Python | Python3 | py | Runtime Error | 0 | 0 | 298 | N = int(input())
A = []
for i in xrange(N):
b= input()
if (" " in b):
b, c = b.split()
c = int(c)
if b == "insert":
A.insert(0, c)
elif b == "delete":
if (c in A):
A.remove(c)
elif b == "deleteFirst":
A.pop(0)
elif b == "deleteLast":
A.pop()
print(" ".join(map(str, A)))
|
s927411722 | p02265 | u548155360 | 1489044030 | Python | Python3 | py | Runtime Error | 0 | 0 | 351 | N = int(input())
A = []
pop = A.pop
remove = A.remove
insert = A.insert
split = b.split
for i in range(N):
b= input()
if (" " in b):
b, c = split()
c = int(c)
if b == "insert":
insert(0, c)
elif b == "delete":
if (c in A):
remove(c)
elif b == "deleteFirst":
pop(0)
elif b == "deleteLast":
pop()
print(" ".join(map(str, A)))
|
s751999814 | p02265 | u548155360 | 1489044862 | Python | Python3 | py | Runtime Error | 0 | 0 | 327 | from collections in deque
N = int(input())
A = deque()
for i in range(N):
b= input()
if b == "deleteFirst":
A.popleft()
elif b == "deleteLast":
A.pop()
else:
b, c = b.split()
c = int(c)
if b == "insert":
A.appendleft(c)
elif b == "delete":
if (c in A):
A.remove(c)
print(" ".join(map(str, A)))
|
s903032029 | p02265 | u130834228 | 1490466826 | Python | Python3 | py | Runtime Error | 30 | 7748 | 490 | n = int(input())
dll =[]
for i in range(n):
command = input().split()
if command[0] == 'insert':
dll.insert(0, command[1])
elif command[0] == 'delete':
# for i in range(len(dll)):
#if dll[i] == command[1]:
#dll.pop(i)
#break
indexes = [i for i, x in enumerate(dll) if x == command[1]]
dll.pop(indexes[0])
elif command[0] == 'deleteFirst':
dll.pop(0)
else:
dll.pop()
print(*dll) |
s331105657 | p02265 | u130834228 | 1490467589 | Python | Python3 | py | Runtime Error | 30 | 7668 | 425 | n = int(input())
dll =[]
for i in range(n):
command = input().split()
if command[0] == 'insert':
dll.insert(0, command[1])
elif command[0] == 'delete':
# for i in range(len(dll)):
#if dll[i] == command[1]:
#dll.pop(i)
#break
dll.remove(command[1])
elif command[0] == 'deleteFirst':
dll.pop(0)
else:
dll.pop()
print(*dll) |
s208852078 | p02265 | u130834228 | 1490504558 | Python | Python3 | py | Runtime Error | 0 | 0 | 377 | n = int(input())
dll =[]
for i in range(n):
command = input().split()
if command[0] == 'insert':
dll.insert(0, command[1])
elif command[0] == 'delete':
try:
dll.remove(command[1])
except:
pass
elif command[0] == 'deleteFirst':
dll.pop(0)
else:
dll.pop()
print(dll[i], sep=" ")
#print(*dll) |
s251460590 | p02265 | u462831976 | 1491287945 | Python | Python3 | py | Runtime Error | 30 | 7940 | 444 | # -*- coding: utf-8 -*-
import sys
import os
from collections import deque
N = int(input())
q = deque()
for i in range(N):
lst = input().split()
command = lst[0]
if command == 'insert':
v = int(lst[1])
q.appendleft(v)
elif command == 'delete':
v = int(lst[1])
q.remove(v)
elif command == 'deleteFirst':
q.popleft()
elif command == 'deleteLast':
q.pop()
print(*list(q)) |
s071113413 | p02265 | u144068724 | 1492102110 | Python | Python3 | py | Runtime Error | 0 | 0 | 457 | # coding: utf-8
# Here your code !
import sys
n = int(input())
output = []
for i in range(n):
order,data =input().split()
if order == "insert":
output.append(int(data))
elif order == "deleteFirst":
output.pop()
elif order == "deleteLast":
output.popleft()
elif order == "delete":
try:
output.remove(int(data))
except:
pass
output.reverse()
print(" ".join(map(str,output))) |
s804379484 | p02265 | u144068724 | 1492102137 | Python | Python3 | py | Runtime Error | 0 | 0 | 446 | # coding: utf-8
# Here your code !
n = int(input())
output = []
for i in range(n):
order,data =input().split()
if order == "insert":
output.append(int(data))
elif order == "deleteFirst":
output.pop()
elif order == "deleteLast":
output.popleft()
elif order == "delete":
try:
output.remove(int(data))
except:
pass
output.reverse()
print(" ".join(map(str,output))) |
s674027700 | p02265 | u144068724 | 1492102239 | Python | Python3 | py | Runtime Error | 0 | 0 | 457 | # coding: utf-8
# Here your code !
import sys
n = int(input())
output = []
for i in range(n):
order,data =input().split()
if order == "insert":
output.append(int(data))
elif order == "deleteFirst":
output.pop()
elif order == "deleteLast":
output.popleft()
elif order == "delete":
try:
output.remove(int(data))
except:
pass
output.reverse()
print(" ".join(map(str,output))) |
s839812881 | p02265 | u144068724 | 1492102304 | Python | Python3 | py | Runtime Error | 0 | 0 | 488 | # coding: utf-8
# Here your code !
import sys
from collections import deque
n = int(input())
output = []
for i in range(n):
order,data =input().split()
if order == "insert":
output.append(int(data))
elif order == "deleteFirst":
output.pop()
elif order == "deleteLast":
output.popleft()
elif order == "delete":
try:
output.remove(int(data))
except:
pass
output.reverse()
print(" ".join(map(str,output))) |
s225399900 | p02265 | u144068724 | 1492102374 | Python | Python3 | py | Runtime Error | 0 | 0 | 487 | # coding: utf-8
# Here your code !
import sys
from collections import deque
n = int(input())
output = []
for i in range(n):
order,data =input().split()
if order == "insert":
output.append(int(data))
elif order == "deleteFirst":
output.pop()
elif order == "deleteLast":
output.popleft()
elif order == "delete":
try:
output.remove(int(data))
except:
pass
output.reverse()
print(" ".join(map(str,output))) |
s708509715 | p02265 | u144068724 | 1492102475 | Python | Python3 | py | Runtime Error | 0 | 0 | 512 | # coding: utf-8
# Here your code !
import sys
from collections import deque
n = int(input())
output = []
for i in range(n):
order,data =input().split()
if order == "insert":
output.append(int(data))
elif order == "deleteFirst":
output.pop()
elif order == "deleteLast":
output.popleft()
elif order == "delete":
try:
output.remove(int(data))
except:
pass
output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output))) |
s358779140 | p02265 | u144068724 | 1492102606 | Python | Python3 | py | Runtime Error | 0 | 0 | 513 | # coding: utf-8
# Here your code !
import sys
from collections import deque
n = int(input())
output = []
for i in range(n):
order,data =input().split()
if order == "insert":
output.append(int(data))
elif order == "deleteFirst":
output.pop()
elif order == "deleteLast":
output.popleft()
elif order == "delete":
try:
output.remove(int(data))
except:
pass
#output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output))) |
s971965190 | p02265 | u144068724 | 1492102622 | Python | Python3 | py | Runtime Error | 0 | 0 | 513 | # coding: utf-8
# Here your code !
import sys
from collections import deque
n = int(input())
output = []
for i in range(n):
order,data =input().split()
if order == "insert":
output.append(int(data))
elif order == "deleteFirst":
output.pop()
elif order == "deleteLast":
# output.popleft()
elif order == "delete":
try:
output.remove(int(data))
except:
pass
output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output))) |
s646670532 | p02265 | u144068724 | 1492102666 | Python | Python3 | py | Runtime Error | 0 | 0 | 534 | # coding: utf-8
# Here your code !
import sys
from collections import deque
n = int(input())
output = []
for i in range(n):
order,data =input().split()
if order == "insert":
output.append(int(data))
elif order == "deleteFirst":
output.pop()
elif order == "deleteLast":
# output.popleft()
output.pop()
elif order == "delete":
try:
output.remove(int(data))
except:
pass
output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output))) |
s736715318 | p02265 | u144068724 | 1492102689 | Python | Python3 | py | Runtime Error | 0 | 0 | 514 | # coding: utf-8
# Here your code !
import sys
from collections import deque
n = int(input())
output = []
for i in range(n):
order,data =input().split()
if order == "insert":
output.append(int(data))
elif order == "deleteFirst":
output.pop()
elif order == "deleteLast":
output.popleft()
elif order == "delete":
try:
# output.remove(int(data))
except:
pass
output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output))) |
s614116948 | p02265 | u144068724 | 1492102704 | Python | Python3 | py | Runtime Error | 0 | 0 | 472 | # coding: utf-8
# Here your code !
n = int(input())
output = []
for i in range(n):
order,data =input().split()
if order == "insert":
output.append(int(data))
elif order == "deleteFirst":
output.pop()
elif order == "deleteLast":
output.popleft()
elif order == "delete":
try:
output.remove(int(data))
except:
pass
output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output))) |
s543013202 | p02265 | u144068724 | 1492102743 | Python | Python3 | py | Runtime Error | 0 | 0 | 480 | # coding: utf-8
# Here your code !
n = int(input())
output = []
for i in range(n):
order,data =input().split()
if order == "insert":
output.append(int(data))
# elif order == "deleteFirst":
# output.pop()
# elif order == "deleteLast":
# output.popleft()
# elif order == "delete":
# try:
# output.remove(int(data))
# except:
# pass
output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output))) |
s274737608 | p02265 | u144068724 | 1492102773 | Python | Python3 | py | Runtime Error | 0 | 0 | 482 | # coding: utf-8
# Here your code !
n = int(input())
output = []
for i in range(n):
order,data =input().split()
# if order == "insert":
# output.append(int(data))
# elif order == "deleteFirst":
# output.pop()
# elif order == "deleteLast":
# output.popleft()
# elif order == "delete":
# try:
# output.remove(int(data))
# except:
# pass
output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output))) |
s543601012 | p02265 | u144068724 | 1492102792 | Python | Python3 | py | Runtime Error | 0 | 0 | 483 | # coding: utf-8
# Here your code !
n = int(input())
output = []
for i in range(n):
order,data =input().split()
# if order == "insert":
# output.append(int(data))
# elif order == "deleteFirst":
# output.pop()
# elif order == "deleteLast":
# output.popleft()
# elif order == "delete":
# try:
# output.remove(int(data))
# except:
# pass
#output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output))) |
s106392346 | p02265 | u144068724 | 1492102807 | Python | Python3 | py | Runtime Error | 0 | 0 | 449 |
n = int(input())
output = []
for i in range(n):
order,data =input().split()
# if order == "insert":
# output.append(int(data))
# elif order == "deleteFirst":
# output.pop()
# elif order == "deleteLast":
# output.popleft()
# elif order == "delete":
# try:
# output.remove(int(data))
# except:
# pass
#output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output))) |
s622495562 | p02265 | u144068724 | 1492102849 | Python | Python3 | py | Runtime Error | 0 | 0 | 449 |
n = int(input())
output = []
for i in range(n):
order,data =input().split()
# if order == "insert":
# output.append(int(data))
# elif order == "deleteFirst":
# output.pop()
# elif order == "deleteLast":
# output.popleft()
# elif order == "delete":
# try:
# output.remove(int(data))
# except:
# pass
#output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output))) |
s084661113 | p02265 | u144068724 | 1492102867 | Python | Python3 | py | Runtime Error | 0 | 0 | 450 |
n = int(input())
output = []
for i in range(n):
order,data = input().split()
# if order == "insert":
# output.append(int(data))
# elif order == "deleteFirst":
# output.pop()
# elif order == "deleteLast":
# output.popleft()
# elif order == "delete":
# try:
# output.remove(int(data))
# except:
# pass
#output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output))) |
s232675921 | p02265 | u144068724 | 1492102926 | Python | Python3 | py | Runtime Error | 0 | 0 | 459 |
n = int(input())
output = []
for i in range(n):
order,data = map(str,input().split() )
# if order == "insert":
# output.append(int(data))
# elif order == "deleteFirst":
# output.pop()
# elif order == "deleteLast":
# output.popleft()
# elif order == "delete":
# try:
# output.remove(int(data))
# except:
# pass
#output.reverse()
print(" ".join(output))
#print(" ".join(map(str,output))) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.