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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s571415269 | p02265 | u477717106 | 1524817794 | Python | Python3 | py | Runtime Error | 0 | 0 | 300 | n, q = map(int, input().split())
l = []
for i in range(n):
t = []
for j in input().split():
t += [j]
t[1] = int(t[1])
l += [t]
c = 0
while len(l) > 0:
if l[0][1] > q:
l[0][1] -= q
l += [l[0]]
l.pop(0)
c += q
else:
c += l[0][1]
print(l[0][0], c)
l.pop(0)
|
s390736816 | p02265 | u724548524 | 1524976346 | Python | Python3 | py | Runtime Error | 20 | 5600 | 321 | n = int(input())
a = []
for i in range(n):
c = input()
if c == "deleteFirst":
a.pop(0)
elif c == "deleteLast":
a.pop()
else:
c, v = c.split()
v = int(v)
if c == "insert":
a.insert(0, v)
else:
a.remove(v)
print(" ".join(map(str, a)))
|
s036219723 | p02265 | u255317651 | 1524994916 | Python | Python3 | py | Runtime Error | 0 | 0 | 426 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 18:31:35 2018
ALDS1-3c simple implementation owing to the feature of python.
@author: maezawa
"""
a = []
n = int(input())
for i in range(n):
com, key = input().split()
if com == 'insert':
a.insert(0, key)
elif com == 'delete':
a.remove(key)
elif com == 'deleteFirst':
a.pop(0)
elif com == 'deleteLast':
a.pop(-1)
print(a)
|
s823429782 | p02265 | u255317651 | 1524995319 | Python | Python3 | py | Runtime Error | 20 | 5612 | 631 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 18:31:35 2018
ALDS1-3c simple implementation owing to the feature of python.
@author: maezawa
"""
def print_array(g):
ans = str(g[0])
if len(g) > 1:
for i in range(1,len(g)):
ans += ' '+str(g[i])
print(ans)
a = []
n = int(input())
for i in range(n):
s = input().split()
if len(s) == 2:
key = s[1]
com = s[0]
if com == 'insert':
a.insert(0, key)
elif com == 'delete':
a.remove(key)
elif com == 'deleteFirst':
a.pop(0)
elif com == 'deleteLast':
a.pop(-1)
print_array(a)
|
s663598011 | p02265 | u255317651 | 1525003182 | Python | Python3 | py | Runtime Error | 0 | 0 | 767 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 18:31:35 2018
ALDS1-3c simple implementation owing to the feature of python.
@author: maezawa
"""
from sys import stdin
def print_array(g):
ans = str(g[0])
if len(g) > 1:
for i in range(1,len(g)):
ans += ' '+str(g[i])
print(ans)
a = []
n = int(input())
sin = stdin.readlines()
for i in range(n):
s = sin[i].plit()
#s = input().split()
if len(s) == 2:
key = int(s[1])
com = s[0]
if com == 'insert':
a.insert(0, key)
elif com == 'deleteFirst':
a.pop(0)
elif com == 'deleteLast':
a.pop(-1)
elif com == 'delete':
try:
a.remove(key)
except ValueError:
pass
print_array(a)
|
s873296504 | p02265 | u255317651 | 1525003827 | Python | Python3 | py | Runtime Error | 0 | 0 | 822 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 18:31:35 2018
ALDS1-3c simple implementation owing to the feature of python.
@author: maezawa
"""
from sys
def print_array(g):
ans = str(g[0])
if len(g) > 1:
for i in range(1,len(g)):
ans += ' '+str(g[i])
sys.stdout.write(ans)
a = []
n = int(input())
s_in = sys.stdin.readlines()
for i in range(n):
s = s_in[i].split()
#s = input().split()
#if len(s) == 2:
# key = int(s[1])
com = s[0]
if com == 'insert':
key = int(s[1])
a.insert(0, key)
elif com == 'deleteFirst':
a.pop(0)
elif com == 'deleteLast':
a.pop(-1)
elif com == 'delete':
key = int(s[1])
try:
a.remove(key)
except ValueError:
pass
print_array(a)
|
s982014175 | p02265 | u255317651 | 1525004715 | Python | Python3 | py | Runtime Error | 0 | 0 | 841 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 18:31:35 2018
ALDS1-3c simple implementation owing to the feature of python.
@author: maezawa
"""
import sys
def print_array(g):
sys.stdout.write(g[0])
if len(g) > 1:
for i in range(1,len(g)):
sys.stdout.write(' '+str(g[i]))
sys.stdout.write(\n)
a = []
n = int(input())
s_in = sys.stdin.readlines()
for i in range(n):
s = s_in[i].split()
#s = input().split()
#if len(s) == 2:
# key = int(s[1])
com = s[0]
if com == 'insert':
key = int(s[1])
a.insert(0, key)
elif com == 'deleteFirst':
a.pop(0)
elif com == 'deleteLast':
a.pop(-1)
elif com == 'delete':
key = int(s[1])
try:
a.remove(key)
except ValueError:
pass
print_array(a)
|
s583437929 | p02265 | u255317651 | 1525004743 | Python | Python3 | py | Runtime Error | 0 | 0 | 843 | # -*- coding: utf-8 -*-
"""
Created on Sun Apr 29 18:31:35 2018
ALDS1-3c simple implementation owing to the feature of python.
@author: maezawa
"""
import sys
def print_array(g):
sys.stdout.write(g[0])
if len(g) > 1:
for i in range(1,len(g)):
sys.stdout.write(' '+str(g[i]))
sys.stdout.write('\n')
a = []
n = int(input())
s_in = sys.stdin.readlines()
for i in range(n):
s = s_in[i].split()
#s = input().split()
#if len(s) == 2:
# key = int(s[1])
com = s[0]
if com == 'insert':
key = int(s[1])
a.insert(0, key)
elif com == 'deleteFirst':
a.pop(0)
elif com == 'deleteLast':
a.pop(-1)
elif com == 'delete':
key = int(s[1])
try:
a.remove(key)
except ValueError:
pass
print_array(a)
|
s593482261 | p02265 | u064320529 | 1525042681 | Python | Python3 | py | Runtime Error | 20 | 5604 | 440 | n=int(input())
dll=[]
for i in range(n):
line=input()
d=line.split(" ")
if d[0]=="insert":
dll=[int(d[1])]+dll
elif d[0]=="delete":
ind=dll.index(int(d[1]))
dll.pop(ind)
elif d[0]=="deleteFirst":
dll.pop(0)
elif d[0]=="deleteLast":
dll.pop()
for i in range(len(dll)):
print(dll[i],end="")
if i==len(dll)-1:
print()
else:
print(" ",end="")
|
s688642496 | p02265 | u064320529 | 1525043438 | Python | Python3 | py | Runtime Error | 20 | 5600 | 435 | n=int(input())
dll=[]
for i in range(n):
line=input()
d=line.split(" ")
if d[0]=="insert":
dll=[int(d[1])]+dll
elif d[0]=="delete":
ind=dll.index(int(d[1]))
dll.pop(ind)
elif d[0]=="deleteFirst":
dll.pop(0)
elif d[0]=="deleteLast":
dll.pop()
for i in range(len(dll)):
print(dll[i],end="")
if i==len(dll)-1:
print()
else:
print(" ",end="")
|
s672867430 | p02265 | u126478680 | 1525063134 | Python | Python3 | py | Runtime Error | 20 | 5604 | 438 | #! python3
# doubly_linked_list.py
keys = []
n = int(input())
for i in range(n):
command = input()
if command == 'deleteFirst':
keys.pop(0)
elif command == 'deleteLast':
keys.pop(-1)
else:
command, x = command.split(' ')
if command == 'insert':
keys.insert(0, int(x))
elif command == 'delete':
keys.remove(int(x))
print(' '.join([str(k) for k in keys]))
|
s964701569 | p02265 | u896240461 | 1525081599 | Python | Python3 | py | Runtime Error | 20 | 5604 | 441 | def pr(a):
for i in range(len(a)):
print(a[i],end="")
if i == len(a)-1:
print("")
else :
print(" ",end="")
n = int(input())
a = []
for i in range(n):
x = input().split()
if x[0] == "insert":
a.insert(0,int(x[1]))
elif x[0] == "delete":
a.remove(int(x[1]))
elif x[0] == "deleteFirst":
a.pop(0)
elif x[0] == "deleteLast":
a.pop()
pr(a)
|
s326902163 | p02265 | u017435045 | 1525246181 | Python | Python3 | py | Runtime Error | 0 | 0 | 320 | from collections import deque
d = deque()
n = int(input())
for i in range(n):
s = input().split()
if s[0] == 'insert': d.appendleft(int(s[1])
elif s[0] =='delete':
if s[1] in d:
d.remove(s[1])
else: pass
elif s[0] =='deleteFirst': d.popleft()
else: d.pop()
print(*d)
|
s746843309 | p02265 | u017435045 | 1525246213 | Python | Python3 | py | Runtime Error | 0 | 0 | 320 | from collections import deque
d = deque()
n = int(input())
for i in range(n):
s = input().split()
if s[0] == 'insert': d.appendleft(int(s[1])
elif s[0] =='delete':
if s[1] in d:
d.remove(s[1])
else: pass
elif s[0] =='deleteFirst': d.popleft()
else: d.pop()
print(*d)
|
s367763107 | p02265 | u017435045 | 1525246753 | Python | Python3 | py | Runtime Error | 0 | 0 | 344 | from collections import deque
d = deque()
n = int(input())
for i in range(n):
s = input().split()
if str(s[0][6]) =='F': d.popleft()
elif: str(s[0][6]) =='L':d.pop()
elif str(s[0][0]) == 'i': d.appendleft(int(s[1]))
else :
if int(s[1]) in d:
d.remove(int(s[1]))
else: pass
print(*d)
|
s033658447 | p02265 | u017435045 | 1525246765 | Python | Python3 | py | Runtime Error | 0 | 0 | 344 | from collections import deque
d = deque()
n = int(input())
for i in range(n):
s = input().split()
if str(s[0][6]) =='F': d.popleft()
elif: str(s[0][6]) =='L':d.pop()
elif str(s[0][0]) == 'i': d.appendleft(int(s[1]))
else :
if int(s[1]) in d:
d.remove(int(s[1]))
else: pass
print(*d)
|
s468900130 | p02265 | u017435045 | 1525246801 | Python | Python3 | py | Runtime Error | 0 | 0 | 333 | from collections import deque
d = deque()
n = int(input())
for i in range(n):
s = input().split()
if str(s[0][6]) =='F': d.popleft()
elif: str(s[0][6]) =='L':d.pop()
elif str(s[0][0]) == 'i': d.appendleft(int(s[1]))
else :
if int(s[1]) in d:
d.remove(int(s[1]))
else: pass
print(*d)
|
s164717692 | p02265 | u017435045 | 1525246828 | Python | Python3 | py | Runtime Error | 0 | 0 | 333 | from collections import deque
d = deque()
n = int(input())
for i in range(n):
s = input().split()
if str(s[0][6]) =='F': d.popleft()
elif: str(s[0][6]) =='L':d.pop()
elif str(s[0][0]) == 'i': d.appendleft(int(s[1]))
else :
if int(s[1]) in d:
d.remove(int(s[1]))
else: pass
print(*d)
|
s108355350 | p02265 | u017435045 | 1525246843 | Python | Python3 | py | Runtime Error | 0 | 0 | 333 | from collections import deque
d = deque()
n = int(input())
for i in range(n):
s = input().split()
if str(s[0][6]) =='F': d.popleft()
elif: str(s[0][6]) =='L':d.pop()
elif str(s[0][0]) == 'i': d.appendleft(int(s[1]))
else :
if int(s[1]) in d:
d.remove(int(s[1]))
else: pass
print(*d)
|
s079489713 | p02265 | u772417059 | 1525288910 | Python | Python | py | Runtime Error | 0 | 0 | 298 | n=int(input())
array=[]
for i in range(n):
a=input()
if a=="deleteFirst":
array.pop(0)
elif a=="deleteLast":
array.pop()
else:
command,x=a.split()
if command=="insert":
array.insert(0,x)
elif command=="delete":
if (x in array):
array.remove(x)
print(" ".join(array))
|
s458449517 | p02265 | u564105430 | 1525674293 | Python | Python3 | py | Runtime Error | 20 | 6004 | 494 | #ALDS_3_C 16D8103010K Ko Okasaki
from collections import deque
def pr(A,n):
for i in range(n):
if i!=n-1:
print(A[i],end=" ")
else:
print(A[i])
n=int(input())
que_r=deque()
for i in range(n):
s=input().split()
if s[0]=="insert":
que_r.appendleft(int(s[1]))
elif s[0]=="delete":
que_r.remove(int(s[1]))
elif s[0]=="deleteFirst":
gav=que_r.popleft()
else:
gav=que_r.pop()
pr(que_r,len(que_r))
|
s435665600 | p02265 | u564105430 | 1525674503 | Python | Python3 | py | Runtime Error | 30 | 6004 | 460 | from collections import deque
def pr(A,n):
for i in range(n):
if i!=n-1:
print(A[i],end=" ")
else:
print(A[i])
n=int(input())
que_r=deque()
for i in range(n):
s=input().split()
if s[0]=="insert":
que_r.appendleft(int(s[1]))
elif s[0]=="delete":
que_r.remove(int(s[1]))
elif s[0]=="deleteFirst":
gav=que_r.popleft()
else:
gav=que_r.pop()
pr(que_r,len(que_r))
|
s209052793 | p02265 | u564105430 | 1525674819 | Python | Python3 | py | Runtime Error | 0 | 0 | 493 | from collections import deque
def pr(A,n):
for i in range(n):
if i!=n-1:
print(A[i],end=" ")
else:
print(A[i])
n=int(input())
que_r=deque()
c=0
for i in range(n):
s=input().split()
if s[0]=="insert":
que_r.appendleft(int(s[1]))
elif s[0]=="delete" and que_r.count(int(s[1]))==0:
que_r.remove(int(s[1]))
elif s[0]=="deleteFirst":
gav=que_r.popleft()
else:
gav=que_r.pop()
pr(que_r,len(que_r))
|
s870939396 | p02265 | u564105430 | 1525675613 | Python | Python3 | py | Runtime Error | 0 | 0 | 477 | def pr(A,n):
for i in range(n):
if i!=n-1:
print(A[i],end=" ")
else:
print(A[i])
n=int(input())
que_r=deque()
for i in range(n):
s=input().split()
if s[0]=="insert":
que_r.appendleft(int(s[1]))
elif s[0]=="delete" and que_r.count(int(s[1]))>=1:
que_r.remove(int(s[1]))
elif s[0]=="deleteFirst":
gav=que_r.popleft()
elif s[0]=="deleteLast":
gav=que_r.pop()
pr(que_r,len(que_r))
|
s895598601 | p02265 | u896240461 | 1525678349 | Python | Python3 | py | Runtime Error | 0 | 0 | 2001 | def pr(data,next,head,tail):
i = head
while(1):
if i == -1:
print("")
break
print(data[i],end = "")
i = next[i]
if i != -1 :
print(" ",end="")
def ins_f(data,next,prev,x,head,tail):
size = len(data)
if head != -1 :
data.append(x)
size += 1
next.append(head)
prev.append(-1)
prev[head] = size -1
head = size -1
else :
data.append(x)
size += 1
next.append(-1)
prev.append(-1)
tail = size-1
head = size-1
return head,tail
def dl(data,next,prev,x,head,tail):
i = head
while(1):
if data[i] == x:
if i == head:
head = dl_f(next,prev,head)
break
elif i == tail:
tail = dl_l(next,prev,tail)
break
else :
prev[next[i]] = prev[i]
next[prev[i]] = next[i]
break
elif i == tail:
break
i = next[i]
return head,tail
def dl_f(next,prev,head,tail):
if head == -1:
return head
elif next[head] == -1:
head = -1
tail = -1
else:
prev[next[head]] = -1
head = next[head]
return head,tail
def dl_l(next,prev,head,tail):
if tail == -1:
return tail
elif prev[tail] == -1:
head = -1
tail = -1
else:
next[prev[tail]] = -1
tail = prev[tail]
return head,tail
n = int(input())
data = []
next = []
prev = []
head = -1
tail = -1
size = len(data)
for i in range(n):
x = input().split()
if x[0] == "insert":
head,tail = ins_f(data,next,prev,x[1],head,tail)
elif x[0] == "delete":
head,tail = dl(data,next,prev,x[1],head,tail)
elif x[0] == "deleteFirst":
head,tail = dl_f(next,prev,head,tail)
elif x[0] == "deleteLast":
head,tail = dl_l(next,prev,head,tail)
pr(data,next,head,tail)
|
s360032973 | p02265 | u896240461 | 1525678406 | Python | Python3 | py | Runtime Error | 0 | 0 | 2028 | def pr(data,next,head,tail):
i = head
while(1):
if i == -1:
print("")
break
print(data[i],end = "")
i = next[i]
if i != -1 :
print(" ",end="")
def ins_f(data,next,prev,x,head,tail):
size = len(data)
if head != -1 :
data.append(x)
size += 1
next.append(head)
prev.append(-1)
prev[head] = size -1
head = size -1
else :
data.append(x)
size += 1
next.append(-1)
prev.append(-1)
tail = size-1
head = size-1
return head,tail
def dl(data,next,prev,x,head,tail):
i = head
while(1):
if data[i] == x:
if i == head:
head = dl_f(next,prev,head)
break
elif i == tail:
tail = dl_l(next,prev,tail)
break
else :
prev[next[i]] = prev[i]
next[prev[i]] = next[i]
break
elif i == tail:
break
i = next[i]
return head,tail
def dl_f(next,prev,head,tail):
if head == -1:
return head
elif next[head] == -1:
head = -1
tail = -1
else:
prev[next[head]] = -1
head = next[head]
return head,tail
def dl_l(next,prev,head,tail):
if tail == -1:
return tail
elif prev[tail] == -1:
head = -1
tail = -1
else:
next[prev[tail]] = -1
tail = prev[tail]
return head,tail
n = int(input())
data = []
next = []
prev = []
head = -1
tail = -1
size = len(data)
for i in range(n):
x = input().split()
if x[0] == "insert":
head,tail = ins_f(data,next,prev,x[1],head,tail)
elif x[0] == "delete":
head,tail = dl(data,next,prev,x[1],head,tail)
elif x[0] == "deleteFirst":
head,tail = dl_f(next,prev,head,tail)
elif x[0] == "deleteLast":
head,tail = dl_l(next,prev,head,tail)
# print(data,head,tail)
pr(data,next,head,tail)
|
s148793343 | p02265 | u564105430 | 1525679868 | Python | Python3 | py | Runtime Error | 0 | 0 | 341 | from collections import deque
n=int(input())
que_r=deque()
data=deque()
for i in range(n):
s=input()
l=len(s)
if s[0]=="i":
que_r.appendleft(s[7:])
elif s[6]==" ":
try:
que_r.remove(s[7:])
except: pass
elif l>10:
que_r.popleft()
elif l>6:
que_r.pop()
pr(*que_r)
|
s054565295 | p02265 | u408444038 | 1525759852 | Python | Python3 | py | Runtime Error | 0 | 0 | 403 | n = int(input())
c = [0]*n
s = []
a = []
for i in range(n):
c[i] = list(input().split())
if c[i][0]=='insert':
s.append(c[i][1])
elif c[i][0]=='delete':
s.remove(c[i][1])
elif c[i][0]=='deleteFirst':
del s[len(s)-1]
elif c[i][0]=='deleteLast':
del s[0]
else
continue
for i in range(len(s),0,-1):
a.append(s[i-1])
print(*a)
|
s785686304 | p02265 | u848218390 | 1525793261 | Python | Python3 | py | Runtime Error | 0 | 0 | 2178 | class DLL:
class Node:
def __init__(self, x, y, z):
self.v = x
self.prv = y
self.nxt = z
def __init__(self):
init = DLL.Node(None, None, None)
init.prv = init
init.nxt = init
self.size = 0
self.init = init
def insert(self, x):
i = self.init
j = i.nxt
k = DLL.Node(x, i, j)
i.nxt = k
j.prv = k
self.size += 1
def deleteFirst(self):
#if self.size != 0:
i = self.init
k = i.nxt
j = k.nxt
i.nxt = j
j.prv = i
self.size -= 1
def deleteLast(self):
#if self.size != 0:
i = self.init
k = i.prv
j = k.prv
i.prv = j
j.nxt = i
self.size -= 1
def delete(self, x):
#if self.size != 0:
i = self.init
k = i.nxt
while 1:
if k.v == x:
i = k.prv
j = k.nxt
i.nxt = j
j.prv = i
self.size -= 1
break
else:
if k.nxt == i:
break
else:
k = k.nxt
def getlist(self):
f = self.init
s = f.nxt
l = f.prv
lt = []
while 1:
if s != l:
lt.append(s.v)
s = s.nxt
else:
lt.append(l)
break
return ' '.join(lt)
n = int(input())
L = DLL()
for i in range(n):
"""
com = input()
if com[0] == "deleteFirst":
L.deleteFirst()
elif com == "deleteLast":
L.deleteLast()
else:
C = com.split()
if C[0] == "insert":
L.insert(int(C[1]))
elif C[0] == "delete":
L.delete(int(C[1]))
#L.prt()
"""
com = input()
if com[0] == "i":
C = com.split()
L.insert(int(C[1]))
else:
if com[6] == "F":
L.deleteFirst()
elif com[6] == "L":
L.deleteLast()
else:
C = com.split()
L.delete(int(C[1]))
print(L.getlist())
|
s833276802 | p02265 | u848218390 | 1525793353 | Python | Python3 | py | Runtime Error | 0 | 0 | 2183 | class DLL:
class Node:
def __init__(self, x, y, z):
self.v = x
self.prv = y
self.nxt = z
def __init__(self):
init = DLL.Node(None, None, None)
init.prv = init
init.nxt = init
self.size = 0
self.init = init
def insert(self, x):
i = self.init
j = i.nxt
k = DLL.Node(x, i, j)
i.nxt = k
j.prv = k
self.size += 1
def deleteFirst(self):
#if self.size != 0:
i = self.init
k = i.nxt
j = k.nxt
i.nxt = j
j.prv = i
self.size -= 1
def deleteLast(self):
#if self.size != 0:
i = self.init
k = i.prv
j = k.prv
i.prv = j
j.nxt = i
self.size -= 1
def delete(self, x):
#if self.size != 0:
i = self.init
k = i.nxt
while 1:
if k.v == x:
i = k.prv
j = k.nxt
i.nxt = j
j.prv = i
self.size -= 1
break
else:
if k.nxt == i:
break
else:
k = k.nxt
def getlist(self):
f = self.init
s = f.nxt
l = f.prv
lt = []
while 1:
if s != l:
lt.append(s.v)
s = s.nxt
else:
lt.append(l.v)
break
return ' '.join(lt)
n = int(input())
L = DLL()
for i in range(n):
"""
com = input()
if com[0] == "deleteFirst":
L.deleteFirst()
elif com == "deleteLast":
L.deleteLast()
else:
C = com.split()
if C[0] == "insert":
L.insert(int(C[1]))
elif C[0] == "delete":
L.delete(int(C[1]))
#L.prt()
"""
com = input()
if com[0] == "i":
C = com.split()
L.insert(int(C[1]))
else:
if com[6] == "F":
L.deleteFirst()
elif com[6] == "L":
L.deleteLast()
else:
C = com.split()
L.delete(int(C[1]))
print(L.getlist())
|
s983627272 | p02265 | u481175672 | 1525807952 | Python | Python | py | Runtime Error | 0 | 0 | 487 | n = int(input())
list = []
check = 0
for i in range(n):
l = input().split()
if l[0] == "insert":
list.insert(0,int(l[1]))
elif l[0] == "delete":
for j in range(len(list)):
if list[j] == int(l[1]):
check = 1
if check == 1:
list.remove(int(l[1]))
elif l[0] == "deleteFirst":
del list[0]
elif l[0] == "deleteLast":
del list[len(list)-1]
check = 0
for k in range(len(list)):
if k<len(list)-1:
print(list[k],end=' ')
else:
print(list[k],end='')
|
s273764381 | p02265 | u728137020 | 1525826088 | Python | Python3 | py | Runtime Error | 20 | 5600 | 316 | a=int(input())
list=[]
for i in range(a):
order=input().split()
if order[0]=="insert":
list.append(order[1])
elif order[0]=="delete":
list.remove(order[1])
elif order[0]=="deleteFirst":
list.pop(0)
elif order[0]=="deleteLast":
list.pop(len(list)-1)
print(*list)
|
s017998748 | p02265 | u728137020 | 1525826853 | Python | Python3 | py | Runtime Error | 0 | 0 | 353 | a=int(input())
list=[]
for i in range(a):
order=input().split()
if order[0]=="insert":
list.appendleft(order[1])
elif order[0]=="delete":
if order[1] in list:
list.remove(order[1])
elif order[0]=="deleteFirst":
list.pop(0)
elif order[0]=="deleteLast":
list.pop(len(list)-1)
print(*list)
|
s592431532 | p02265 | u728137020 | 1525827271 | Python | Python3 | py | Runtime Error | 0 | 0 | 390 | from collections import deque
a=int(input())
list=deque([])
for i in range(a):
order=input().split()
if order[0]=="insert":
list.appendleft(order[1])
elif order[0]=="delete":
if order[1] in list:
list.remove(order[1])
elif order[0]=="deleteFirst":
list.pop(0)
elif order[0]=="deleteLast":
list.pop(len(list)-1)
print(*list)
|
s917490836 | p02265 | u728137020 | 1525827384 | Python | Python | py | Runtime Error | 0 | 0 | 378 | from collections import deque
a=int(input())
list=deque([])
for i in range(a):
order=input().split()
if order[0]=="insert":
list.appendleft(order[1])
elif order[0]=="delete":
if order[1] in list:
list.remove(order[1])
elif order[0]=="deleteFirst":
list.pop()
elif order[0]=="deleteLast":
list.pop()
print(*list)
|
s828912441 | p02265 | u728137020 | 1525827751 | Python | Python | py | Runtime Error | 0 | 0 | 382 | from collections import deque
a=int(input())
list=deque([])
for i in range(a):
order=input().split()
if order[0]=="insert":
list.appendleft(order[1])
elif order[0]=="delete":
if order[1] in list:
list.remove(order[1])
elif order[0]=="deleteFirst":
list.popleft()
elif order[0]=="deleteLast":
list.pop()
print(*list)
|
s512609615 | p02265 | u252641015 | 1525847488 | Python | Python3 | py | Runtime Error | 0 | 0 | 1546 | #include <list>
#include <string>
using namespace std;
#define ll long long
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
string com;
int key;
list<ll> lst;
list<ll>::iterator it,i=lst.end();
while(n--){
cin>>com;
if(com=="insert"){
cin>>key;
lst.push_front(key);
}
else if(com=="delete"){
cin>>key;
for(it=lst.begin();it!=i;it++){
if(*it==key){
lst.erase(it);
break;
}
}
}
else if(com=="deleteFirst") lst.pop_front();
else lst.pop_back();
}
i--;
for(it=lst.begin();it!=i;it++) cout<<*it<<" ";
cout<<*i<<"\n";
return 0;
}
Compile Error Logs:
ステータス
Judge: 10/10
C++
CPU: 00:32 sec
Memory: 32472 KB
Length: 637 B
2015-03-23 23:30
テストケースの判定結果
Case #
Verdict
CPU Time
Memory
In
Out
Case Name
Case #1
: Accepted
00:00
1216
88
2
01.in
Case #2
: Accepted
00:00
1216
203
10
02.in
Case #3
: Accepted
00:00
1216
375
10
03.in
Case #4
: Accepted
00:00
1216
105
23
04.in
Case #5
: Accepted
00:00
1212
643
58
05.in
Case #6
: Accepted
00:00
1216
52
2
06.in
Case #7
: Accepted
00:00
1216
1058
110
07.in
Case #8
: Accepted
00:00
1216
1031
116
08.in
Case #9
: Accepted
00:28
1220
22392494
5
09.in
Case #10
: Accepted
00:32
32472
25527813
1288799
10.in
< prev |
/
| next >
Judge Input # ( | )
Judge Output # ( | )
|
s608678151 | p02265 | u252641015 | 1525847505 | Python | Python3 | py | Runtime Error | 0 | 0 | 823 | #include <list>
#include <string>
using namespace std;
#define ll long long
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
string com;
int key;
list<ll> lst;
list<ll>::iterator it,i=lst.end();
while(n--){
cin>>com;
if(com=="insert"){
cin>>key;
lst.push_front(key);
}
else if(com=="delete"){
cin>>key;
for(it=lst.begin();it!=i;it++){
if(*it==key){
lst.erase(it);
break;
}
}
}
else if(com=="deleteFirst") lst.pop_front();
else lst.pop_back();
}
i--;
for(it=lst.begin();it!=i;it++) cout<<*it<<" ";
cout<<*i<<"\n";
return 0;
}
|
s142371014 | p02265 | u252641015 | 1525847594 | Python | Python | py | Runtime Error | 0 | 0 | 826 |
#include <list>
#include <string>
using namespace std;
#define ll long long
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
string com;
int key;
list<ll> lst;
list<ll>::iterator it,i=lst.end();
while(n--){
cin>>com;
if(com=="insert"){
cin>>key;
lst.push_front(key);
}
else if(com=="delete"){
cin>>key;
for(it=lst.begin();it!=i;it++){
if(*it==key){
lst.erase(it);
break;
}
}
}
else if(com=="deleteFirst") lst.pop_front();
else lst.pop_back();
}
i--;
for(it=lst.begin();it!=i;it++) cout<<*it<<" ";
cout<<*i<<"\n";
return 0;
}
|
s672655258 | p02265 | u252641015 | 1525847604 | Python | Python3 | py | Runtime Error | 0 | 0 | 826 |
#include <list>
#include <string>
using namespace std;
#define ll long long
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
string com;
int key;
list<ll> lst;
list<ll>::iterator it,i=lst.end();
while(n--){
cin>>com;
if(com=="insert"){
cin>>key;
lst.push_front(key);
}
else if(com=="delete"){
cin>>key;
for(it=lst.begin();it!=i;it++){
if(*it==key){
lst.erase(it);
break;
}
}
}
else if(com=="deleteFirst") lst.pop_front();
else lst.pop_back();
}
i--;
for(it=lst.begin();it!=i;it++) cout<<*it<<" ";
cout<<*i<<"\n";
return 0;
}
|
s109654156 | p02265 | u252641015 | 1525847844 | Python | Python3 | py | Runtime Error | 0 | 0 | 480 |
import sys
A=[]
fp =0
bp =0
n=int(raw_input())
while n:
s = raw_input()
if s[0] == 'i':
A.append(int(s[7:]))
fp += 1
elif s[6] == ' ':
try:
i = A[::-1].index(int(s[7:]))
if i!=-1:
del A[-i-1]
fp -=1
except:
pass
elif s[6] == 'F':
A.pop()
fp -=1
elif s[6] == 'L':
bp +=1
n -=1
for e in A[bp:fp+1][::-1]:
print int(e),
|
s324404657 | p02265 | u898049910 | 1527077913 | Python | Python3 | py | Runtime Error | 20 | 5596 | 425 | n = int(input())
linked_list = []
for _ in range(n):
command = input()
if "insert" in command:
x = command.split()[-1]
linked_list.insert(0, x)
elif command == "deleteFirst":
del linked_list[0]
elif command == "deleteLast":
del linked_list[-1]
elif "delete" in command:
x = command.split()[-1]
del linked_list[linked_list.index(x)]
print(*linked_list)
|
s305440884 | p02265 | u898049910 | 1527077929 | Python | Python3 | py | Runtime Error | 20 | 5600 | 425 | n = int(input())
linked_list = []
for _ in range(n):
command = input()
if "insert" in command:
x = command.split()[-1]
linked_list.insert(0, x)
elif command == "deleteFirst":
del linked_list[0]
elif command == "deleteLast":
del linked_list[-1]
elif "delete" in command:
x = command.split()[-1]
del linked_list[linked_list.index(x)]
print(*linked_list)
|
s392325339 | p02265 | u938045879 | 1527226079 | Python | Python3 | py | Runtime Error | 20 | 5604 | 372 | n = int(input())
output = []
for i in range(n):
li = input().split(' ')
if(li[0] == 'insert'):
output.insert(0, int(li[1]))
elif(li[0] == 'delete'):
output.remove(int(li[1]))
elif(li[0] == 'deleteFirst'):
del output[0]
elif(li[0] == 'deleteLast'):
del output[-1]
str_l = [str(o) for o in output]
print(' '.join(str_l))
|
s276497611 | p02265 | u957840591 | 1527385308 | Python | Python3 | py | Runtime Error | 0 | 0 | 1532 | import sys
class Node():
def __init__(self, key=None, prev=None, next=None):
self.key = key
self.prev = prev
self.next = next
class DoublyLinkedList():
def __init__(self):
self.head = Node()
self.head.next = self.head
self.head.prev = self.head
def insert(self, x):
node = Node(key=x, prev=self.head, next=self.head.next)
self.head.next.prev = node
self.head.next = node
def search(self, x):
node = self.head.next
while node is not self.head and node.key != x:
node = node.next
return node
def delete_key(self, x):
if node is self.head:
return None
node = self.search(x)
self._delete(node)
def _delete(self, node):
node.prev.next = node.next
node.next.prev = node.prev
def deleteFirst(self):
self._delete(self.head.next)
def deleteLast(self):
self._delete(self.head.prev)
def getKeys(self):
node = self.head.next
keys = []
while node is not self.head:
keys.append(node.key)
node = node.next
return " ".join(keys)
L = DoublyLinkedList()
n = int(input())
for i in sys.stdin:
if 'insert' in i:
x = i[7:-1]
L.insert(x)
elif 'deleteFirst' in i:
L.deleteFirst()
elif 'deleteLast' in i:
L.deleteLast()
elif 'delete' in i:
x = i[7:-1]
L.delete_key(x)
else:
pass
print(L.getKeys())
|
s630977384 | p02265 | u986478725 | 1527479402 | Python | Python3 | py | Runtime Error | 20 | 5596 | 585 | # ALDS1_3_C.
def show(a):
# 配列の中身を出力する。
_str = ""
for i in range(len(a) - 1):
_str += str(a[i]) + " "
_str += str(a[len(a) - 1])
print(_str)
def main():
n = int(input())
list = []
for i in range(n):
command = input().split()
if len(command) > 1:
if command[0][0] == 'i': list.append(int(command[1]))
else: list.remove(int(command[1]))
else:
if command[0][6] == 'F': del list[0]
else: list.pop()
show(list)
if __name__ == "__main__":
main()
|
s314702895 | p02265 | u684241248 | 1527503462 | Python | Python3 | py | Runtime Error | 0 | 0 | 715 | from collections import deque
n = int(input())
ops = [tuple(input().split()) for i in range(n)]
ary = deque([])
def insert(ary, x):
ary.appendleft(x)
def delete(ary, x):
if x in ary:
ind = ary.index(x)
ary = ary[:ind] + ary[ind + 1:]
def delete_first(ary):
ary.popleft()
def delete_last(ary):
ary.pop()
def operate(ary, op):
cmd = op[0]
if cmd == 'insert':
x = int(op[1])
insert(ary, x)
elif cmd == 'delete':
x = int(op[1])
delete(ary, x)
elif cmd == 'deleteFirst':
delete_first(ary)
elif cmd == 'deleteLast':
delete_last(ary)
[operate(ary, op) for op in ops]
print(' '.join([str(_) for _ in ary]))
|
s565821544 | p02265 | u404682284 | 1527863592 | Python | Python3 | py | Runtime Error | 0 | 0 | 496 | def assign(linked_list, commmand, x):
if command == 'insert':
linked_list.insert(0, int(x))
if command == 'delete':
linked_list.remove(int(x))
if command == 'deleteFirst':
linked_list.deleteFirst(int(x))
if command == 'deleteLast':
linked_list.deleteLast(int(x))
n = int(input())
linked_list = []
for i in range(n):
command, x = input().split()
assign(linked_list, command, x)
# print(linked_list)
print(' '.join(map(str, linked_list)))
|
s494056479 | p02265 | u404682284 | 1527863629 | Python | Python3 | py | Runtime Error | 0 | 0 | 496 | def assign(linked_list, commmand, x):
if command == 'insert':
linked_list.insert(0, int(x))
if command == 'delete':
linked_list.remove(int(x))
if command == 'deleteFirst':
linked_list.deleteFirst(int(x))
if command == 'deleteLast':
linked_list.deleteLast(int(x))
n = int(input())
linked_list = []
for i in range(n):
command, x = input().split()
assign(linked_list, command, x)
# print(linked_list)
print(' '.join(map(str, linked_list)))
|
s707402001 | p02265 | u404682284 | 1527863712 | Python | Python3 | py | Runtime Error | 0 | 0 | 470 | def assign(linked_list, commmand, x):
if command == 'insert':
linked_list.insert(0, int(x))
if command == 'delete':
linked_list.remove(int(x))
if command == 'deleteFirst':
linked_list.pop(0)
if command == 'deleteLast':
linked_list.pop()
n = int(input())
linked_list = []
for i in range(n):
command, x = input().split()
assign(linked_list, command, x)
# print(linked_list)
print(' '.join(map(str, linked_list)))
|
s261539146 | p02265 | u404682284 | 1527864122 | Python | Python3 | py | Runtime Error | 20 | 5600 | 557 | def assign(linked_list, commmand, x):
if command == 'insert':
linked_list.insert(0, int(x))
if command == 'delete':
linked_list.remove(int(x))
if command == 'deleteFirst':
linked_list.pop(0)
if command == 'deleteLast':
linked_list.pop()
n = int(input())
linked_list = []
for i in range(n):
input_line = input().split()
if len(input_line) == 2:
command, x = input_line
else:
command, x = input_line[0], -1
assign(linked_list, command, x)
print(' '.join(map(str, linked_list)))
|
s360013802 | p02265 | u990900604 | 1527928034 | Python | Python | py | Runtime Error | 0 | 0 | 1611 | #!/usr/bin/env python
#-*- coding: utf-8 -*-
class Node:
def __init__(self, val):
self.val = val
self.prev = None
self.next = None
class LinkedList:
def __init__(self):
self.head = Node(None)
self.head.prev = self.head
self.head.next = self.head
def insertNode(self, p):
p.prev = self.head
p.next = self.head.next
self.head.next.prev = p
self.head.next = p
def searchNode(self, val):
p = self.head.next
while p != self.head and p.val != val:
p = p.next
return p
def deleteNode(self, p):
if p == self.head:
return
p.prev.next = p.next
p.next.prev = p.prev
def insert(self, val):
self.insertNode(Node(val))
def delete(self, val):
p = self.searchNode(val)
self.deleteNode(p)
def deleteFirst(self):
self.eleteNode(self.head.next)
def deleteLast(self):
self.deleteNode(self.head.prev)
def show(self):
p = self.head.next
while p != self.head:
print p.val,
p = p.next
print
if __name__ == '__main__':
n = int(raw_input())
i = 0
link = LinkedList()
while i != n:
line = raw_input().split()
if line[0] == 'insert':
link.insert(int(line[1]))
elif line[0] == 'delete':
link.delete(int(line[1]))
elif line[0] == 'deleteFirst':
link.deleteFirst()
elif line[0] == 'deleteLast':
link.deleteLast()
i += 1
link.show()
|
s594697244 | p02265 | u990900604 | 1527928076 | Python | Python | py | Runtime Error | 0 | 0 | 1611 | #!/usr/bin/env python
#-*- coding: utf-8 -*-
class Node:
def __init__(self, val):
self.val = val
self.prev = None
self.next = None
class LinkedList:
def __init__(self):
self.head = Node(None)
self.head.prev = self.head
self.head.next = self.head
def insertNode(self, p):
p.prev = self.head
p.next = self.head.next
self.head.next.prev = p
self.head.next = p
def searchNode(self, val):
p = self.head.next
while p != self.head and p.val != val:
p = p.next
return p
def deleteNode(self, p):
if p == self.head:
return
p.prev.next = p.next
p.next.prev = p.prev
def insert(self, val):
self.insertNode(Node(val))
def delete(self, val):
p = self.searchNode(val)
self.deleteNode(p)
def deleteFirst(self):
self.eleteNode(self.head.next)
def deleteLast(self):
self.deleteNode(self.head.prev)
def show(self):
p = self.head.next
while p != self.head:
print p.val,
p = p.next
print
if __name__ == '__main__':
n = int(raw_input())
i = 0
link = LinkedList()
while i != n:
line = raw_input().split()
if line[0] == 'insert':
link.insert(int(line[1]))
elif line[0] == 'delete':
link.delete(int(line[1]))
elif line[0] == 'deleteFirst':
link.deleteFirst()
elif line[0] == 'deleteLast':
link.deleteLast()
i += 1
link.show()
|
s644911093 | p02265 | u990900604 | 1527929318 | Python | Python | py | Runtime Error | 0 | 0 | 394 | # -*- coding: utf-8 -*-
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))
|
s386972007 | p02265 | u990900604 | 1527929332 | Python | Python3 | py | Runtime Error | 30 | 6004 | 394 | # -*- coding: utf-8 -*-
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))
|
s842220847 | p02265 | u990900604 | 1527929360 | Python | Python3 | py | Runtime Error | 20 | 6000 | 394 | # -*- coding: utf-8 -*-
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))
|
s472838435 | p02265 | u990900604 | 1527933858 | Python | Python | py | Runtime Error | 0 | 0 | 946 | #!/usr/bin/env python
#-*- coding: utf-8 -*-
import sys
class LinkedList:
def __init__(self):
self.l = []
def insert(self, val):
self.l.append(val)
def delete(self, val):
i = len(self.l) - 1
while i >= 0 and l[i] != val:
i -= 1
del self.l[i]
def deleteFirst(self):
self.l.pop()
def deleteLast(self):
del self.l[0]
def show(self):
for i in range(len(l) - 1, 0 - 1, -1):
print self.l[i],
print
if __name__ == '__main__':
n = int(raw_input())
link = LinkedList()
i = 0
for i in range(n):
t = raw_input().split()
if t[0] == 'insert':
link.insert(t[1])
elif t[0] == 'delete':
link.delete(t[1])
elif t[0] == 'deleteFirst':
link.deleteFirst()
elif t[0] == 'deleteLast':
link.deleteLast()
i += 1
link.show()
|
s901594011 | p02265 | u007270338 | 1527971301 | Python | Python3 | py | Runtime Error | 30 | 6000 | 403 | #coding:utf-8
from collections import deque
n = int(input())
day = deque()
for i in range(n):
order = list(input().split())
if order[0] == "insert":
day.appendleft(order[1])
if order[0] == "delete":
day.remove(order[1])
if order[0] == "deleteFirst":
day.popleft()
if order[0] == "deleteLast":
day.pop()
day = " ".join(day)
print(day)
|
s761152074 | p02265 | u007270338 | 1527973708 | Python | Python3 | py | Runtime Error | 0 | 0 | 447 | %%cython
import numpy as np
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
def solve(i, num):
if num == 0:
global sw
sw = 1
return 0
if i >= n or num < 0:
return 0
return solve(i+1, num), solve(i+1, num-A[i])
for num in m:
i = 0
sw = 0
solve(i,num)
if sw == 0:
print("no")
if sw == 1:
print("yes")
|
s203383419 | p02265 | u007270338 | 1527973894 | Python | Python3 | py | Runtime Error | 0 | 0 | 470 | %load_ext Cython
#coding:utf-8
import numpy as np
n = int(input())
A = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
def solve(i, num):
if num == 0:
global sw
sw = 1
return 0
if i >= n or num < 0:
return 0
return solve(i+1, num), solve(i+1, num-A[i])
for num in m:
i = 0
sw = 0
solve(i,num)
if sw == 0:
print("no")
if sw == 1:
print("yes")
|
s114981430 | p02265 | u007270338 | 1527974205 | Python | Python3 | py | Runtime Error | 0 | 0 | 523 | #coding:utf-8
from collections import deque
from numba import jit
n = int(input())
@jit
def ord(order):
if order[0] == "insert":
day.appendleft(order[1])
elif order[0] == "delete":
try:
day.remove(order[1])
except:
continue
elif order[0] == "deleteFirst":
day.popleft()
elif order[0] == "deleteLast":
day.pop()
day = deque()
for i in range(n):
order = list(input().split())
ord(order)
day = " ".join(day)
print(day)
|
s297446537 | p02265 | u007270338 | 1527974257 | Python | Python3 | py | Runtime Error | 0 | 0 | 519 | #coding:utf-8
from collections import deque
from numba import jit
n = int(input())
@jit
def ord(order):
if order[0] == "insert":
day.appendleft(order[1])
elif order[0] == "delete":
try:
day.remove(order[1])
except:
pass
elif order[0] == "deleteFirst":
day.popleft()
elif order[0] == "deleteLast":
day.pop()
day = deque()
for i in range(n):
order = list(input().split())
ord(order)
day = " ".join(day)
print(day)
|
s813938169 | p02265 | u318430977 | 1528039724 | Python | Python3 | py | Runtime Error | 20 | 5604 | 870 | class DoublyLinkedList:
def __init__(self):
self.data = []
def insert(self, x):
self.data.insert(0, x)
def delete(self, x):
self.data.remove(x)
def deleteFirst(self):
self.data.pop(0)
def deleteLast(self):
self.data.pop(len(self.data) - 1)
def print_list_split_whitespace(a):
for x in a[:-1]:
print(x, end=' ')
print(a[-1])
dll = DoublyLinkedList()
n = int(input())
for _ in range(n):
command = input().split()
if command[0] == "insert":
dll.insert(int(command[1]))
elif command[0] == "delete":
dll.delete(int(command[1]))
elif command[0] == "deleteFirst":
dll.deleteFirst()
elif command[0] == "deleteLast":
dll.deleteLast()
else:
raise ValueError("No Command such as", command[0])
print_list_split_whitespace(dll.data)
|
s614422740 | p02265 | u971076135 | 1528196763 | Python | Python3 | py | Runtime Error | 20 | 5596 | 469 | if __name__ == '__main__':
store = list()
for i in range(int(input())):
parts = input().split()
cmd = parts[0]
if cmd == 'insert':
store.insert(0, int(parts[1]))
elif cmd == 'delete':
num = int(parts[1])
store.remove(num)
elif cmd == 'deleteFirst':
store.remove(store[0])
elif cmd =='deleteLast':
store = store[:-1]
print(' '.join(map(str, store)))
|
s139368218 | p02265 | u971076135 | 1528201287 | Python | Python3 | py | Runtime Error | 20 | 5608 | 1625 |
class LinkedList(object):
class Node(object):
def __init__(self, value, next=None, prev=None):
self.value = value
self.next = next
self.prev = prev
def __init__(self, dtype):
self.dtype = dtype
self.dummy = LinkedList.Node(dtype())
self.dummy.next = self.dummy
self.dummy.prev = self.dummy
self.dict = dict()
def insert(self, x):
node = LinkedList.Node(x, self.dummy.next, self.dummy)
self.dummy.next.prev = node
self.dummy.next = node
self.dict[x] = node
def delete(self, x):
if x in self.dict:
node = self.dict[x]
self.__remove_node(node)
def deleteLast(self):
node = self.dummy.prev
if node != self.dummy:
self.__remove_node(node)
def deleteFirst(self):
node = self.dummy.next
if node != self.dummy:
self.__remove_node(node)
def __remove_node(self, node):
node.prev.next = node.next
node.next.prev = node.prev
self.dict.pop(node.value)
def items(self):
node = self.dummy.next
while node != self.dummy:
yield node.value
node = node.next
store = LinkedList(str)
for i in range(int(input())):
parts = input().split()
cmd = parts[0]
if cmd == 'insert':
store.insert(parts[1])
elif cmd == 'delete':
store.delete(parts[1])
elif cmd == 'deleteFirst':
store.deleteFirst()
elif cmd =='deleteLast':
store.deleteLast()
print(' '.join(store.items()))
|
s197768299 | p02265 | u657361950 | 1529889507 | Python | Python3 | py | Runtime Error | 0 | 0 | 985 | import java.util.Iterator;
import java.util.Scanner;
import java.util.LinkedList;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
LinkedList<Integer> list = new LinkedList<Integer>();
for (int i = 0; i < n; i++) {
String command = sc.next();
if (command.equals("insert") || command.equals("delete")) {
Integer value = sc.nextInt();
if (command.equals("insert")) {
list.addFirst(value);
} else {
list.remove(value);
}
} else if (command.equals("deleteFirst")) {
list.removeFirst();
} else if (command.equals("deleteLast")) {
list.removeLast();
} else {
System.out.println("Unknown command:" + command);
}
}
sc.close();
Iterator<Integer> itr = list.iterator();
while (itr.hasNext()) {
Integer value = itr.next();
System.out.print(value);
if (itr.hasNext()) {
System.out.print(" ");
}
}
System.out.println("");
}
}
|
s230786711 | p02265 | u445032255 | 1529903524 | Python | Python3 | py | Runtime Error | 30 | 5996 | 608 | from collections import deque
def main():
N = int(input())
L = deque([])
for _ in range(N):
command_value = input()
if len(command_value.split()) == 2:
command, value = command_value.split()
else:
command = command_value
value = None
if command == "insert":
L.append(value)
elif command == "delete":
L.remove(value)
elif command == "deleteFirst":
L.popleft()
elif command == "deleteLast":
L.pop()
L = list(L)
print(" ".join(L[::-1]))
main()
|
s276210767 | p02265 | u445032255 | 1529903649 | Python | Python3 | py | Runtime Error | 30 | 6004 | 589 | from collections import deque
def main():
N = int(input())
L = deque([])
for _ in range(N):
command_value = input()
if len(command_value.split()) == 2:
command, value = command_value.split()
else:
command = command_value
value = None
if command == "insert":
L.insert(0, value)
elif command == "delete":
L.remove(value)
elif command == "deleteFirst":
L.popleft()
elif command == "deleteLast":
L.pop()
print(" ".join(L))
main()
|
s713237199 | p02265 | u929141425 | 1529981410 | Python | Python3 | py | Runtime Error | 20 | 5600 | 297 | N = int(input())
lis = []
for n in range(N):
com = input().split()
if com[0] == "insert":
lis.insert(0,int(com[1]))
elif com[0] == "delete":
lis.remove(int(com[1]))
elif com[0] == "deleteFirst":
del lis[0]
else:
lis.pop()
print(*lis)
|
s755665758 | p02265 | u207394722 | 1530226085 | Python | Python3 | py | Runtime Error | 30 | 5612 | 1765 | class Node():
key = 0
def __init__( self, key ):
self.key = key
self.next = -1
self.pre = -1
def insert( self, othernode ): # othernodeにはinsert前の先頭のノードを入れる
self.next = othernode
othernode.pre = self
return self
def delete( self, x ): #先頭ノードで実行
if self.key == x:
self.pre.next = self.next
self.next.pre = self.pre
else :
self.next.delete( x )
def printNodes( self ): #先頭ノードで実行
if self.next.next != -1:
print( str( self.key ), end=" " )
self.next.printNodes()
elif self.next != -1:
print( str( self.key ), end="\n" )
def deleteFirst( self ):
self.next.pre = -1
return self.next #新しい先頭ノードを返す
def deleteLast( self ):
if self.next != -1:
self.next.deleteLast()
else :
self.pre.next = -1
def main():
n = int( input() )
commands = []
vals = []
for i in range(n):
tmp = input().split()
tmp.append( 0 )
commands.append( tmp[0] )
vals.append( int(tmp[1]) )
FirstNode = Node( None )
for i in range(n):
if commands[i] == "insert":
TmpNode = Node( vals[i] )
FirstNode = TmpNode.insert( FirstNode )
elif commands[i] == "delete":
FirstNode.delete( vals[i] )
elif commands[i] == "deleteFirst":
FirstNode = FirstNode.deleteFirst()
elif commands[i] == "deleteLast":
FirstNode.deleteLast()
else :
print("command error!")
FirstNode.printNodes()
if __name__ == '__main__':
main()
|
s770864624 | p02265 | u207394722 | 1530226213 | Python | Python3 | py | Runtime Error | 20 | 5612 | 1784 | class Node():
key = 0
def __init__( self, key ):
self.key = key
self.next = -1
self.pre = -1
def insert( self, othernode ): # othernodeにはinsert前の先頭のノードを入れる
self.next = othernode
othernode.pre = self
return self
def delete( self, x ): #先頭ノードで実行
if self.key == x and self.pre != -1:
self.pre.next = self.next
self.next.pre = self.pre
else :
self.next.delete( x )
def printNodes( self ): #先頭ノードで実行
if self.next.next != -1:
print( str( self.key ), end=" " )
self.next.printNodes()
elif self.next != -1:
print( str( self.key ), end="\n" )
def deleteFirst( self ):
self.next.pre = -1
return self.next #新しい先頭ノードを返す
def deleteLast( self ):
if self.next != -1:
self.next.deleteLast()
else :
self.pre.next = -1
def main():
n = int( input() )
commands = []
vals = []
for i in range(n):
tmp = input().split()
tmp.append( 0 )
commands.append( tmp[0] )
vals.append( int(tmp[1]) )
FirstNode = Node( None )
for i in range(n):
if commands[i] == "insert":
TmpNode = Node( vals[i] )
FirstNode = TmpNode.insert( FirstNode )
elif commands[i] == "delete":
FirstNode.delete( vals[i] )
elif commands[i] == "deleteFirst":
FirstNode = FirstNode.deleteFirst()
elif commands[i] == "deleteLast":
FirstNode.deleteLast()
else :
print("command error!")
FirstNode.printNodes()
if __name__ == '__main__':
main()
|
s091756257 | p02265 | u207394722 | 1530226775 | Python | Python3 | py | Runtime Error | 20 | 5612 | 1957 | class Node():
key = 0
def __init__( self, key ):
self.key = key
self.next = -1
self.pre = -1
def insert( self, othernode ): # othernodeにはinsert前の先頭のノードを入れる
self.next = othernode
othernode.pre = self
return self
def delete( self, x ): #先頭ノードで実行
FirstNode = self
if self.key == x:
if self.pre == -1:
self.next.pre = -1
FirstNode = self.next
else :
self.pre.next = self.next
self.next.pre = self.pre
else:
self.next.delete( x )
return FirstNode
def printNodes( self ): #先頭ノードで実行
if self.next.next != -1:
print( str( self.key ), end=" " )
self.next.printNodes()
elif self.next != -1:
print( str( self.key ), end="\n" )
def deleteFirst( self ):
self.next.pre = -1
return self.next #新しい先頭ノードを返す
def deleteLast( self ):
if self.next != -1:
self.next.deleteLast()
else :
self.pre.next = -1
def main():
n = int( input() )
commands = []
vals = []
for i in range(n):
tmp = input().split()
tmp.append( 0 )
commands.append( tmp[0] )
vals.append( int(tmp[1]) )
FirstNode = Node( None )
for i in range(n):
if commands[i] == "insert":
TmpNode = Node( vals[i] )
FirstNode = TmpNode.insert( FirstNode )
elif commands[i] == "delete":
FirstNode = FirstNode.delete( vals[i] )
elif commands[i] == "deleteFirst":
FirstNode = FirstNode.deleteFirst()
elif commands[i] == "deleteLast":
FirstNode.deleteLast()
else :
print("command error!")
FirstNode.printNodes()
if __name__ == '__main__':
main()
|
s373432547 | p02265 | u207394722 | 1530229107 | Python | Python3 | py | Runtime Error | 0 | 0 | 1686 | def main():
n = int( input() )
FirstNode = {"pre":-1, "key":None, "next":-1}
for i in range(n):
tmp = input().split()
if tmp[0] == "insert":
TmpNode = {"pre":FirstNode, "key":tmp[1], "next":-1}
FirstNode[next] = TmpNode
FirstNode = TmpNode
elif tmp[0] == "delete":
TmpNode = FirstNode
while True:
if TmpNode[key] == tmp[1]:
if TmpNode[pre] == -1:
TmpNode[next][pre] = -1
FirstNode = TmpNode[next]
break
else :
TmpNode[pre][next] = TmpNode[next]
TmpNode[next][pre] = TmpNode[pre]
break
else :
if TmpNode[next] != -1:
TmpNode = TmpNode[next]
continue
elif tmp[0] == "deleteFirst":
FirstNode[next][pre] = -1
FirstNode = FirstNode[next]
elif tmp[0] == "deleteLast":
TmpNode = FirstNode
while True:
if TmpNode[next] != -1:
TmpNode = TmpNode[next]
continue
else :
TmpNode[pre][next] = -1
break
else :
print("command error!")
TmpNode = FirstNode
while True:
if FirstNode[next][next] != -1:
print( str( TmpNode[key] ), end=" " )
TmpNode = TmpNode[next]
elif TmpNode[next] != -1:
print( str( TmpNode[key] ), end="\n" )
if __name__ == '__main__':
main()
|
s895620172 | p02265 | u316584871 | 1530252711 | Python | Python3 | py | Runtime Error | 0 | 0 | 884 | n = int(input())
xlist = []
for i in range(n):
command = list(map(str,input().split()))
if (command[0] == 'insert'):
x = command[1]
if (len(xlist) == 0):
xlist.append(int(x))
else:
xlist.append(int(x))
for i in range(1,len(xlist)):
k = len(xlist) - i
j = k-1
xlist[j], xlist[k] = xlist[k], xlist[j]
elif (command[0] == 'delete'):
x = command[1]
if int(x) in xlist :
xlist.remove(int(x))
elif (command[0] == 'deleteFirst'):
if (len(xlist) > 0):
del xlist[0]
elif (command[0] == 'deleteLast'):
if (len(xlist) > 0):
del xlist[-1]
nx = len(xlist)
for i in range(n):
if ( i == n-1):
print('{}'.format(xlist[i]), end = '')
else:
print('{}'.format(xlist[i]), end = ' ')
|
s548954040 | p02265 | u316584871 | 1530256723 | Python | Python3 | py | Runtime Error | 0 | 0 | 567 | from collections import deque ##deque 라는 데이터형 편리한듯. print도그렇고 append,pop속도도 빠르고
n = int(input())
xdeque = deque()
for i in range(n):
command = list(map(str,input().split()))
if (command[0] == 'insert'):
x = command[1]
xdeque.appendleft(int(x))
elif (command[0] == 'delete'):
x = command[1]
try:
d.remove(int(x))
except ValueError:
pass
elif (command[0] == 'deleteFirst'):
xdeque.popleft()
else:
xdeque.pop()
print(*xdeque)
|
s390639438 | p02265 | u316584871 | 1530257110 | Python | Python3 | py | Runtime Error | 0 | 0 | 381 | from collections import deque
n = int(input())
d = deque()
for _ in range(n):
x = input().split()
if (command[0][0] == 'i'):
d.appendleft(int(x[1]))
elif (command[0] == 'delete'):
try:
d.remove(int(x[1]))
except ValueError:
pass
elif (x[0][6] == 'F'):
d.popleft()
else:
d.pop()
print(*xdeque)
|
s170247629 | p02265 | u316584871 | 1530257132 | Python | Python3 | py | Runtime Error | 0 | 0 | 377 | from collections import deque
n = int(input())
d = deque()
for _ in range(n):
x = input().split()
if (command[0][0] == 'i'):
d.appendleft(int(x[1]))
elif (command[0] == 'delete'):
try:
d.remove(int(x[1]))
except ValueError:
pass
elif (x[0][6] == 'F'):
d.popleft()
else:
d.pop()
print(*d)
|
s919445129 | p02265 | u682153677 | 1530425627 | Python | Python3 | py | Runtime Error | 0 | 0 | 481 | # -*- coding: utf-8 -*-
n = int(input())
key = []
for i in range(n):
command, num = list(input().split())
if command == 'insert':
key.append(num)
elif command == 'delete':
key.remove(num)
elif command == 'deleteFirst':
del key[0]
elif command == 'deleteLast':
del key[-1]
for i in range(len(key)):
if i == len(key) - 1:
print('{0}'.format(key[i]))
else:
print('{0}'.format(key[i]), end=' ')
|
s200820783 | p02265 | u682153677 | 1530425723 | Python | Python3 | py | Runtime Error | 20 | 5604 | 494 | # -*- coding: utf-8 -*-
n = int(input())
key = []
for i in range(n):
command = list(input().split())
if command[0] == 'insert':
key.append(command[1])
elif command[0] == 'delete':
key.remove(command[1])
elif command[0] == 'deleteFirst':
del key[0]
elif command[0] == 'deleteLast':
del key[-1]
for i in range(len(key)):
if i == len(key) - 1:
print('{0}'.format(key[i]))
else:
print('{0}'.format(key[i]), end=' ')
|
s554913468 | p02265 | u682153677 | 1530426309 | Python | Python3 | py | Runtime Error | 0 | 0 | 520 | # -*- coding: utf-8 -*-
n = int(input())
key = []
for i in range(n + 1):
command = list(input().split())
if command[0] == 'insert':
key.append(command[1])
elif command[0] == 'delete' and command[1] in key:
key.remove(command[1])
elif command[0] == 'deleteFirst':
del key[0]
elif command[0] == 'deleteLast':
del key[-1]
for i in range(len(key)):
if i == len(key) - 1:
print('{0}'.format(key[i]))
else:
print('{0}'.format(key[i]), end=' ')
|
s794570873 | p02265 | u741801763 | 1530429205 | Python | Python3 | py | Runtime Error | 20 | 5600 | 295 | l = []
n = int(input())
for _ in range (n):
cmd = input().split(' ')
if cmd[0]=='insert':
l.insert(0,int(cmd[1]))
if cmd[0]=='delete':
l.remove(int(cmd[1]))
if cmd[0]=='deleteFirst':
l.pop(0)
if cmd[0]=='deleteLast':
l.pop(len(l)-1)
print(*l)
|
s634962703 | p02265 | u741801763 | 1530429226 | Python | Python3 | py | Runtime Error | 30 | 5600 | 295 | l = []
n = int(input())
for _ in range (n):
cmd = input().split(' ')
if cmd[0]=='insert':
l.insert(0,int(cmd[1]))
if cmd[0]=='delete':
l.remove(int(cmd[1]))
if cmd[0]=='deleteFirst':
l.pop(0)
if cmd[0]=='deleteLast':
l.pop(len(l)-1)
print(*l)
|
s945652166 | p02265 | u995990363 | 1530504473 | Python | Python3 | py | Runtime Error | 30 | 5604 | 863 | class LinkedList(object):
def __init__(self):
self.nodes = []
def insert(self, node):
self.nodes.insert(0, node)
def delete(self, node):
self.nodes.remove(node)
def deleteFirst(self):
self.nodes.pop(0)
def deleteLast(self):
self.nodes.pop()
def run():
n = int(input())
linked_list = LinkedList()
for _ in range(n):
order = [x.strip() for x in input().split()]
if order[0] == 'insert':
linked_list.insert(int(order[1]))
elif order[0] == 'delete':
linked_list.delete(int(order[1]))
elif order[0] == 'deleteFirst':
linked_list.deleteFirst()
elif order[0] == 'deleteLast':
linked_list.deleteLast()
print(' '.join([str(n) for n in linked_list.nodes]))
if __name__ == '__main__':
run()
|
s789226905 | p02265 | u995990363 | 1530505388 | Python | Python3 | py | Runtime Error | 0 | 0 | 535 | def run():
n = int(input())
nodes = []
for _ in range(n):
order = [o.strip() for o in input().split()]
if order[0] == 'insert':
nodes.insert(0, (int(order[1]))
elif order[0] == 'delete':
if int(order[1]) in nodes:
nodes.remove(int(order[1]))
elif order[0] == 'deleteFirst':
nodes.pop(0)
elif order[0] == 'deleteLast':
nodes.pop()
print(' '.join([str(n) for n in nodes]))
if __name__ == '__main__':
run()
|
s815939763 | p02265 | u741801763 | 1530550784 | Python | Python3 | py | Runtime Error | 0 | 0 | 486 | from collections import deque
n = int(input())
l = deque()
count = set([])
for _ in range (n):
cmd = input().split(' ')
print(cmd)
if cmd[0]=='insert':
l.appendleft(int(cmd[1]))
if not int(cmd[1]) in count:
count.add(int(cmd[1]))
if cmd[0]=='delete':
if len(l) !=0 and int(cmd[2]) in count:
l.remove(int(cmd[1]))
if cmd[0]=='deleteFirst':
l.popleft()
if cmd[0]=='deleteLast':
l.pop()
print(*l)
|
s072284686 | p02265 | u741801763 | 1530550825 | Python | Python3 | py | Runtime Error | 0 | 0 | 467 | from collections import deque
n = int(input())
l = deque()
count = set([])
for _ in range (n):
cmd = input().split(' ')
if cmd[0]=='insert':
l.appendleft(int(cmd[1]))
if not int(cmd[1]) in count:
count.add(int(cmd[1]))
if cmd[0]=='delete':
if len(l) !=0 and int(cmd[2]) in count:
l.remove(int(cmd[1]))
if cmd[0]=='deleteFirst':
l.popleft()
if cmd[0]=='deleteLast':
l.pop()
print(*l)
|
s377947618 | p02265 | u741801763 | 1530550914 | Python | Python3 | py | Runtime Error | 20 | 6000 | 467 | from collections import deque
n = int(input())
l = deque()
count = set([])
for _ in range (n):
cmd = input().split(' ')
if cmd[0]=='insert':
l.appendleft(int(cmd[1]))
if not int(cmd[1]) in count:
count.add(int(cmd[1]))
if cmd[0]=='delete':
if len(l) !=0 and int(cmd[1]) in count:
l.remove(int(cmd[1]))
if cmd[0]=='deleteFirst':
l.popleft()
if cmd[0]=='deleteLast':
l.pop()
print(*l)
|
s153464905 | p02265 | u741801763 | 1530551119 | Python | Python3 | py | Runtime Error | 30 | 6000 | 533 | from collections import deque
n = int(input())
l = deque()
count = set([])
for _ in range (n):
cmd = input().split(' ')
if cmd[0]=='insert':
l.appendleft(int(cmd[1]))
if not int(cmd[1]) in count:
count.add(int(cmd[1]))
if cmd[0]=='delete':
if len(l) !=0 and int(cmd[1]) in count:
l.remove(int(cmd[1]))
count.remove(int(cmd[1]))
if cmd[0]=='deleteFirst':
count.remove(l.popleft())
if cmd[0]=='deleteLast':
count.remove(l.pop())
print(*l)
|
s882242281 | p02265 | u912237403 | 1371272679 | Python | Python | py | Runtime Error | 10 | 4232 | 316 | n = int(raw_input())
li = []
for i in range(n):
cmd = raw_input().split()
if cmd[0] == 'insert':
li.insert(0,cmd[1])
elif cmd[0] == 'delete':
li.remove(cmd[1])
elif cmd[0] == 'deleteFirst':
li.pop(0)
elif cmd[0] == 'deleteLast':
li.pop()
for e in li:
print e, |
s380091795 | p02265 | u912237403 | 1371272857 | Python | Python | py | Runtime Error | 0 | 0 | 346 | n = int(raw_input())
li = []
for i in range(n):
cmd = raw_input().split()
if cmd[0] == 'insert':
li.insert(0,cmd[1])
elif cmd[0] == 'delete':
try:
li.remove(cmd[1])
elif cmd[0] == 'deleteFirst':
li.pop(0)
elif cmd[0] == 'deleteLast':
li.pop()
print li
for e in li:
print e, |
s662462121 | p02265 | u912237403 | 1373806274 | Python | Python | py | Runtime Error | 0 | 0 | 1235 | import sys
A=[[0,0,0]]
size = 0
def insert(A,x):
global size
fp=A[0][1]
try:
i=[e[0] for e in A].index(-1)
A[i]=[x,fp,0]
A[fp][2]=i
A[0][1]=i
except:
A.append([x,fp,0])
A[fp][2]=len(A)-1
A[0][1]=len(A)-1
size += 1
def delete(A,x):
global size
p =A[0][1]
while A[p][0]!=x:
p=A[p][1]
if p==0: return
fp=A[p][1]
bp=A[p][2]
A[fp][2]=bp
A[bp][1]=fp
A[p]=[-1,-1,-1]
size -= 1
return
def deletefirst(A):
global size
if size == 0: return
p=A[0][1]
fp=A[p][1]
A[0][1]=fp
A[fp][2]=0
A[p]=[-1,-1,-1]
size -= 1
return 0
def deletelast(A):
global size
if size == 0: return
p=A[0][2]
bp=A[p][2]
A[0][2]=bp
A[bp][1]=0
A[p]=[-1,-1,-1]
size -= 1
return 0
n = int(raw_input())
for i in range(n):
s = (raw_input().split())
if s[0][0] == 'i':#'insert':
insert(A,int(s[1]))
elif len(s[0]) == 6;#'delete':
delete(A,int(s[1]))
elif s[0][7] == 'F':#'deleteFirst':
deletefirst(A)
elif s[0][7] == 'L':#'deleteLast':
deletelast(A)
e = A[0][1]
while e!=0:
print A[e][0],
e = A[e][1] |
s817534440 | p02265 | u912237403 | 1373808625 | Python | Python | py | Runtime Error | 0 | 0 | 1302 | import sys
A=[[0,0,0]]
buf=[]
size = 0
def insert(A,x):
global size,buf
fp=A[0][1]
try:
if buf==[]:
buf = [i for i,e in enumerate(A) if e==-1]
else:
i = buf[-1]
buf = buf[:-1]
A[i]=[x,fp,0]
A[fp][2]=i
A[0][1]=i
except:
A.append([x,fp,0])
A[fp][2]=len(A)-1
A[0][1]=len(A)-1
size += 1
def delete(A,x):
global size
p =A[0][1]
while A[p][0]!=x:
p=A[p][1]
if p==0: return
fp=A[p][1]
bp=A[p][2]
A[fp][2]=bp
A[bp][1]=fp
A[p]=[-1,-1,-1]
size -= 1
return
def deletefirst(A):
global size
if size == 0: return
p=A[0][1]
fp=A[p][1]
A[0][1]=fp
A[fp][2]=0
A[p]=[-1,-1,-1]
size -= 1
return 0
def deletelast(A):
global size
if size == 0: return
p=A[0][2]
bp=A[p][2]
A[0][2]=bp
A[bp][1]=0
A[p]=[-1,-1,-1]
size -= 1
return 0
while int(raw_input())
s = (raw_input().split())
if s[0] == 'insert':
insert(A,s[1])
elif s[0] == 'delete':
delete(A,s[1])
elif s[0] == 'deleteFirst':
deletefirst(A)
elif s[0] == 'deleteLast':
deletelast(A)
n -=1
e = A[0][1]
while e!=0:
print A[e][0],
e = A[e][1] |
s704171887 | p02265 | u912237403 | 1373808653 | Python | Python | py | Runtime Error | 0 | 0 | 1303 | import sys
A=[[0,0,0]]
buf=[]
size = 0
def insert(A,x):
global size,buf
fp=A[0][1]
try:
if buf==[]:
buf = [i for i,e in enumerate(A) if e==-1]
else:
i = buf[-1]
buf = buf[:-1]
A[i]=[x,fp,0]
A[fp][2]=i
A[0][1]=i
except:
A.append([x,fp,0])
A[fp][2]=len(A)-1
A[0][1]=len(A)-1
size += 1
def delete(A,x):
global size
p =A[0][1]
while A[p][0]!=x:
p=A[p][1]
if p==0: return
fp=A[p][1]
bp=A[p][2]
A[fp][2]=bp
A[bp][1]=fp
A[p]=[-1,-1,-1]
size -= 1
return
def deletefirst(A):
global size
if size == 0: return
p=A[0][1]
fp=A[p][1]
A[0][1]=fp
A[fp][2]=0
A[p]=[-1,-1,-1]
size -= 1
return 0
def deletelast(A):
global size
if size == 0: return
p=A[0][2]
bp=A[p][2]
A[0][2]=bp
A[bp][1]=0
A[p]=[-1,-1,-1]
size -= 1
return 0
while int(raw_input()):
s = (raw_input().split())
if s[0] == 'insert':
insert(A,s[1])
elif s[0] == 'delete':
delete(A,s[1])
elif s[0] == 'deleteFirst':
deletefirst(A)
elif s[0] == 'deleteLast':
deletelast(A)
n -=1
e = A[0][1]
while e!=0:
print A[e][0],
e = A[e][1] |
s478078632 | p02265 | u912237403 | 1373835397 | Python | Python | py | Runtime Error | 0 | 0 | 1986 | import sys
class Deque:
# セルの定義
class Cell2:
def __init__(self, x, y = None, z = None):
self.data = x
self.next = y
self.prev = z
# 初期化
def __init__(self):
head = Deque.Cell2(None) # ヘッダ
head.next = head # 循環リスト
head.prev = head
self.size = 0
self.head = head
# 先頭に追加
def push_front(self, x):
h = self.head
q = h.next
p = Deque.Cell2(x, q, h)
h.next = p
q.prev = p
self.size += 1
# 最後尾のデータを取り出す
def pop_back(self):
if self.size == 0: raise IndexError
h = self.head
q = h.prev
p = q.prev
p.next = h
h.prev = p
self.size -= 1
return q.data
# 先頭のデータを取り出す
def pop_front(self):
if self.size == 0: raise IndexError
h = self.head
q = h.next
p = q.next
p.prev = h
h.next = p
self.size -= 1
return q.data
# xをもつセルを削除する
def delete(self,x):
h=self.head.next
while h.data!=x:
h=h.next
if h==self.head: raise IndexError
q=h.next
p=h.prev
q.prev=p
p.next=q
self.size -= 1
return
# 表示
def __str__(self):
if self.size == 0: return
buff = ''
n = self.size
cp = self.head.next
while n > 1:
buff += '%s, ' % cp.data
cp = cp.next
n -= 1
buff += '%s' % cp.data
return buff
A=Deque()
n=int(raw_input())
while n:
s = (raw_input().split())
if s[0] == 'insert':
A.push_front(s[1])
elif s[0] == 'delete':
A.delete(s[1])
elif s[0] == 'deleteFirst':
A.pop_front()
elif s[0] == 'deleteLast':
A.pop_back()
n -=1
print A
print |
s047982149 | p02265 | u912237403 | 1373835651 | Python | Python | py | Runtime Error | 10 | 4332 | 1753 | import sys
class Deque:
class Cell2:
def __init__(self, x, y = None, z = None):
self.data = x
self.next = y
self.prev = z
def __init__(self):
head = Deque.Cell2(None)
head.next = head
head.prev = head
self.size = 0
self.head = head
def push_front(self, x):
h = self.head
q = h.next
p = Deque.Cell2(x, q, h)
h.next = p
q.prev = p
self.size += 1
def pop_back(self):
if self.size == 0: raise IndexError
h = self.head
q = h.prev
p = q.prev
p.next = h
h.prev = p
self.size -= 1
return q.data
def pop_front(self):
if self.size == 0: raise IndexError
h = self.head
q = h.next
p = q.next
p.prev = h
h.next = p
self.size -= 1
return q.data
def delete(self,x):
h=self.head.next
while h.data!=x:
h=h.next
if h==self.head: raise IndexError
q=h.next
p=h.prev
q.prev=p
p.next=q
self.size -= 1
return
def __str__(self):
if self.size == 0: return
buff = ''
n = self.size
cp = self.head.next
while n > 1:
buff += '%s ' % cp.data
cp = cp.next
n -= 1
buff += '%s' % cp.data
return buff
A=Deque()
n=int(raw_input())
while n:
s = (raw_input().split())
if s[0] == 'insert':
A.push_front(s[1])
elif s[0] == 'delete':
A.delete(s[1])
elif s[0] == 'deleteFirst':
A.pop_front()
elif s[0] == 'deleteLast':
A.pop_back()
n -=1
print A |
s518598050 | p02265 | u912237403 | 1373836358 | Python | Python | py | Runtime Error | 0 | 0 | 1845 | import sys
class Deque:
class Cell2:
def __init__(self, x, y = None, z = None):
self.data = x
self.next = y
self.prev = z
def __init__(self):
head = Deque.Cell2(None)
head.next = head
head.prev = head
self.size = 0
self.head = head
def push_front(self, x):
h = self.head
q = h.next
p = Deque.Cell2(x, q, h)
h.next = p
q.prev = p
self.size += 1
def pop_back(self):
if self.size == 0: raise IndexError
h = self.head
q = h.prev
p = q.prev
p.next = h
h.prev = p
self.size -= 1
del gc.garbage[:]
return q.data
def pop_front(self):
if self.size == 0: raise IndexError
h = self.head
q = h.next
p = q.next
p.prev = h
h.next = p
self.size -= 1
del gc.garbage[:]
return q.data
def delete(self,x):
h=self.head.next
while h.data!=x:
h=h.next
if h==self.head: return
q=h.next
p=h.prev
q.prev=p
p.next=q
self.size -= 1
del gc.garbage[:]
return
def __str__(self):
if self.size == 0: return
buff = ''
n = self.size
cp = self.head.next
while n > 1:
buff += '%s ' % cp.data
cp = cp.next
n -= 1
buff += '%s' % cp.data
return buff
A=Deque()
n=int(raw_input())
while n:
s = (raw_input().split())
if s[0] == 'insert':
A.push_front(int(s[1]))
elif s[0] == 'delete':
A.delete(int(s[1]))
elif s[0] == 'deleteFirst':
A.pop_front()
elif s[0] == 'deleteLast':
A.pop_back()
n -=1
print A
print |
s561473204 | p02265 | u912237403 | 1373836756 | Python | Python | py | Runtime Error | 0 | 0 | 1910 | import sys
class Deque:
class Cell2:
def __init__(self, x, y = None, z = None):
self.data = x
self.next = y
self.prev = z
def __init__(self):
head = Deque.Cell2(None)
head.next = head
head.prev = head
self.size = 0
self.head = head
def push_front(self, x):
h = self.head
q = h.next
p = Deque.Cell2(x, q, h)
h.next = p
q.prev = p
self.size += 1
def pop_back(self):
if self.size == 0: raise IndexError
h = self.head
q = h.prev
p = q.prev
p.next = h
h.prev = p
self.size -= 1
return q.data
# 先頭のデータを取り出す
def pop_front(self):
if self.size == 0: raise IndexError
h = self.head
q = h.next
p = q.next
p.prev = h
h.next = p
self.size -= 1
del gc.garbage[:]
return q.data
# xをもつセルを削除する
def delete(self,x):
h=self.head.next
while h.data!=x:
h=h.next
if h==self.head: return
q=h.next
p=h.prev
q.prev=p
p.next=q
self.size -= 1
del gc.garbage[:]
return
# 表示
def __str__(self):
if self.size == 0: return
buff = ''
n = self.size
cp = self.head.next
while n > 1:
buff += '%s ' % cp.data
cp = cp.next
n -= 1
buff += '%s' % cp.data
return buff
A=Deque()
n=int(raw_input())
while n:
s = (raw_input().split())
if s[0] == 'insert':
A.push_front(int(s[1]))
elif s[0] == 'delete':
A.delete(int(s[1]))
elif s[0] == 'deleteFirst':
A.pop_front()
elif s[0] == 'deleteLast':
A.pop_back()
n -=1
print A
print |
s718066575 | p02265 | u912237403 | 1373839244 | Python | Python | py | Runtime Error | 0 | 0 | 335 | import sys,gc
A=[]
n=int(raw_input())
while n:
s = raw_input()
if s[0] == 'i'
A.insert(0,s[7:])
elif s[6] == ' ':
try:
A.remove(s[7:])
except:
pass
elif s[6] == 'F':
A.pop(0)
elif s[6] == 'L':
A.pop()
n -=1
for e in A:
print int(e), |
s629482160 | p02265 | u912237403 | 1373847283 | Python | Python | py | Runtime Error | 0 | 0 | 526 | import sys,gc
A=[]
fp =0
bp =0
n=int(raw_input())
while n:
s = raw_input()
if s[0] == 'i':
A.append(s[7:])
fp += 1
elif s[6] == ' ':
i=-1
try:
while True:
i = A[i+1:].index(s[7:])
finally:
if i!=-1:
del A[i]
fp -=1
elif s[6] == 'F':
A.pop()
fp -=1
elif s[6] == 'L':
A[bp]=-1
bp +=1
n -=1
for e in A[bp:fp+1][::-1]:
if e!=-1:
print int(e), |
s387902347 | p02265 | u572424947 | 1376653203 | Python | Python | py | Runtime Error | 10 | 4244 | 394 | n = int(raw_input())
cmdlist = [raw_input().split() for i in range(n)]
cmddict = {
"insert":"%s.insert(0,%d)",
"delete":"%s.remove(%d)",
"deleteFirst":"%s.pop(0)",
"deleteLast":"%s.pop()",
}
mylist = []
for cmd in cmdlist:
try:
cmd[1] = int(cmd[1])
exec(cmddict[cmd[0]] % ("mylist", cmd[1]))
except IndexError:
exec(cmddict[cmd[0]] % ("mylist"))
for i in mylist:
print i,
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.