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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s256085065 | p00036 | u350508326 | 1373503432 | Python | Python | py | Runtime Error | 0 | 0 | 1560 | while True:
try:
a = [[0 for j in range(8)]for i in range(8)]
for i in range(8):
a[i] = list(map(int,raw_input()))
f = 0
for i in range(8):
if f == 1:
f = 0
break
for j in range(8):
if a[i][j] =... |
s417957742 | p00036 | u350508326 | 1373503678 | Python | Python | py | Runtime Error | 0 | 0 | 1923 | while True:
try:
a = [[0 for j in range(8)]for i in range(8)]
for i in range(8):
a[i] = list(map(int,raw_input()))
f = 0
i = 0
j = 0 ... |
s813506232 | p00036 | u350508326 | 1373503703 | Python | Python | py | Runtime Error | 0 | 0 | 1902 | while True:
try:
a = [[0 for j in range(8)]for i in range(8)]
for i in range(8):
a[i] = list(map(int,raw_input()))
f = 0
i = 0
j = 0 ... |
s161170414 | p00036 | u350508326 | 1373504036 | Python | Python | py | Runtime Error | 0 | 0 | 2015 | while True:
try:
a = [[0 for j in range(8)]for i in range(8)]
for i in range(8):
a[i] = list(map(int,raw_input()))
f = 0
for i in range(8): ... |
s949269055 | p00036 | u350508326 | 1373504121 | Python | Python | py | Runtime Error | 0 | 0 | 2055 | while True:
try:
a = [[0 for k in range(8)]for m in range(8)]
for i in range(8): ... |
s347239599 | p00036 | u523886269 | 1384105263 | Python | Python | py | Runtime Error | 0 | 0 | 1635 | # -*- coding: utf8 -*-
import sys
types = ['A', 'B', 'C', 'D', 'E', 'F', 'G']
def main():
while True:
try:
data = []
for i in xrange(8):
data.append(raw_input())
check_figure(data)
# 空行
raw_input()
except EOFError:
... |
s455139244 | p00036 | u633068244 | 1393579207 | Python | Python | py | Runtime Error | 0 | 0 | 489 | while True:
try:
h = 0
for i in range(10):
tmp = raw_input()
if sum(int(tmp)) != 0:
a[h] = tmp
h += 1
if h == 4:
print "B"
elif h == 1:
print "C"
elif h == 2:
c = int(a[0])/int(a[1])
if c == 1:
print "A"
elif c ... |
s387990267 | p00036 | u633068244 | 1393579288 | Python | Python | py | Runtime Error | 0 | 0 | 483 | while True:
try:
h = 0
for i in range(8):
tmp = raw_input()
if int(tmp) != 0:
a[h] = tmp
h += 1
if h == 4:
print "B"
elif h == 1:
print "C"
elif h == 2:
c = int(a[0])/int(a[1])
if c == 1:
print "A"
elif c == 10:... |
s113291386 | p00036 | u633068244 | 1393580127 | Python | Python | py | Runtime Error | 0 | 0 | 598 | while True:
try:
h = 0
for i in range(8):
tmp = raw_input()
if tmp.count(1) = 0:
a[h] = tmp
h += 1
if h == 1:
print "C"
elif h == 2:
c = a[0].index(1) - a[1].index(1)
if c == 0:
... |
s453207064 | p00036 | u633068244 | 1393580168 | Python | Python | py | Runtime Error | 0 | 0 | 594 | while True:
try:
h = 0
for i in range(8):
tmp = raw_input()
if int(tmp) = 0:
a[h] = tmp
h += 1
if h == 1:
print "C"
elif h == 2:
c = a[0].index(1) - a[1].index(1)
if c == 0:
pr... |
s358855845 | p00036 | u633068244 | 1393580203 | Python | Python | py | Runtime Error | 0 | 0 | 602 | while True:
try:
h = 0
for i in range(8):
tmp = raw_input()
if int(tmp) = 0:
a[h] = tmp
h += 1
if h == 1:
print "C"
elif h == 2:
c = a[0].index("1") - a[1].index("1")
if c == 0:
... |
s181362311 | p00036 | u633068244 | 1393581690 | Python | Python | py | Runtime Error | 0 | 0 | 625 | while True:
try:
h = 0
a=["","","",""]
for i in range(8):
tmp = raw_input()
if int(tmp) != 0:
a[h] = tmp
h += 1
if h == 1:
print "C"
elif h == 2:
c = a[0].index("1") - a[1].index("1")
if c == 0:
... |
s051159019 | p00036 | u912237403 | 1394326659 | Python | Python | py | Runtime Error | 0 | 0 | 338 | import sys
N = 8
ptn = [18,48,6,30,20,34,16]
def f(D):
i = 0
s = 0
D = D[D.index("1"):]
for c in D:
if c=="1": s += i
i += 1
p = "ABCDEF"[ptn.index(s)]
return p
i=0
D=""
for s in sys.stdin:
if i<8:
D+=s[1:]
i+=1
else:
print f(D)
D=""
... |
s211112690 | p00036 | u912237403 | 1394326724 | Python | Python | py | Runtime Error | 0 | 0 | 339 | import sys
N = 8
ptn = [18,48,6,30,20,34,16]
def f(D):
i = 0
s = 0
D = D[D.index("1"):]
for c in D:
if c=="1": s += i
i += 1
p = "ABCDEF"[ptn.index(s)]
return p
i=0
D=""
for s in sys.stdin:
if i<8:
D+=s[:-1]
i+=1
else:
print f(D)
i=0
... |
s842358150 | p00036 | u912237403 | 1394326938 | Python | Python | py | Runtime Error | 0 | 0 | 349 | import sys
N = 8
ptn = [18,48,6,30,20,34,16]
def f(D):
i = 0
s = 0
D = D[D.index("1"):]
for c in D:
if c=="1": s += i
i += 1
p = "ABCDEF"[ptn.index(s)]
return p
i=0
D=""
for s in sys.stdin:
if i<8:
D+=s[:-1]
i+=1
else:
print f(D)
i=0
... |
s518350197 | p00036 | u912237403 | 1394339068 | Python | Python | py | Runtime Error | 0 | 0 | 306 | import sys
ptn = [18,48,6,30,20,34,16]
def f(D):
i = 0
s = 0
D = D[D.index("1"):]
for c in D:
if c=="1": s += i
i += 1
p = "ABCDEF"[ptn.index(s)]
return p
i=0
D=""
for s in sys.stdin:
i+=1
D+=s[:-1]
if i==8:
print f(D)
i=0
D="" |
s533967410 | p00036 | u912237403 | 1394339580 | Python | Python | py | Runtime Error | 0 | 0 | 294 | def f(D):
i = 0
s = 0
D = D[D.index("1"):]
for c in D:
if c=="1": s += i
i += 1
p = "ABCDEF"[ptn.index(s)]
return p
i=0
D=""
for s in sys.stdin:
if i<8:
i+=1
D+=s[:-1]
else:
print f(D)
i=0
D=""
print f(D) |
s988470077 | p00036 | u912237403 | 1394340532 | Python | Python | py | Runtime Error | 0 | 0 | 295 | def f(D):
i = 0
s = 0
D = D[D.index("1"):]
for c in D:
if c=="1": s += i
i += 1
p = "ABCDEFG"[ptn.index(s)]
return p
i=0
D=""
for s in sys.stdin:
if i<8:
i+=1
D+=s[:-1]
else:
print f(D)
i=0
D=""
print f(D) |
s807652175 | p00037 | u873482706 | 1434774812 | Python | Python | py | Runtime Error | 0 | 0 | 2874 | import sys
def xxx(position, direction):
if direction == 'R' or direction == 'L':
if not (0 <= position[tate] <= 8 and 0 <= position[yoko] <= 3):
return
elif direction == 'U' or direction == 'D':
if not (1 <= position[tate] <= 7 and 0 <= position[yoko] <= 4):
return
... |
s999878550 | p00037 | u873482706 | 1434777537 | Python | Python | py | Runtime Error | 0 | 0 | 3470 | import sys
def xxx(position, direction):
if direction == 'R' or direction == 'L':
if not (0 <= position[tate] <= 8 and 0 <= position[yoko] <= 3):
return
elif direction == 'U' or direction == 'D':
if not (1 <= position[tate] <= 7 and 0 <= position[yoko] <= 4):
return
... |
s350714342 | p00037 | u873482706 | 1435293327 | Python | Python | py | Runtime Error | 0 | 0 | 3800 | def xxx(position, direction):
if direction == 'R' or direction == 'L':
if not (0 <= position[tate] <= 8 and 0 <= position[yoko] <= 3):
return
elif direction == 'U' or direction == 'D':
if not (1 <= position[tate] <= 7 and 0 <= position[yoko] <= 4):
return
if (positio... |
s308970999 | p00037 | u419407022 | 1362161694 | Python | Python | py | Runtime Error | 0 | 0 | 762 | dist = ['R','D','L','U']
dict = [(1,0),(0,1),(-1,0),(0,-1)]
result = ''
sell = [[False]*13]*2
for i in xrange(9):
l = [False,False]
s = raw_input()
if len(s) == 4:
for j in s:
l.append(False)
l.append(bool(int(j)))
l += [False] * 3
else:
for j in s:
... |
s846098170 | p00037 | u542421762 | 1368332660 | Python | Python | py | Runtime Error | 0 | 0 | 4450 |
import sys
class Grid:
def __init__(self, lines):
lines = map((lambda line: list(line)), lines)
l = []
for i in range(len(lines)):
if i % 2 == 0:
l.append(intersperse2(lines[i], '+'))
else:
l.append(intersperse(lines[i], 'x'))
... |
s379496821 | p00038 | u379956761 | 1443343090 | Python | Python3 | py | Runtime Error | 0 | 0 | 1299 | import sys
def is_onepair(x):
for i in range(4):
if x.count(x[i]) == 2:
return True
return False
def is_twopair(x):
count = 0
for e in x:
for e2 in x:
if e == e2:
count += 1
if count == 2:
return True
return Fals... |
s299062267 | p00038 | u300946041 | 1469324474 | Python | Python3 | py | Runtime Error | 0 | 0 | 1069 | # -*- coding: utf-8 -*-
def is_four_card(d):
return 4 in d.values()
def is_full_house(d):
return 3 in d.values() and 2 in d.values()
def is_straight(d):
flag = [False, 0]
for i in d.values():
if flag[0] == True and flag[1] == 5:
return True
if i == 1:
flag[... |
s333543319 | p00038 | u150984829 | 1518109953 | Python | Python3 | py | Runtime Error | 0 | 0 | 220 | import sys
for e in sys.stdin:
e=sorted(map(int,e.split(',')))
print([['null','straight'][e[4]-e[0]==4 or e[0]*10==e[1]],'one pair','two pair','three card','full house',0,'four card'][(sum(e.count(s)for s in e)//2-2])
|
s691871498 | p00038 | u633068244 | 1393482727 | Python | Python | py | Runtime Error | 0 | 0 | 776 | while True:
try:
hand = sorted(map(int, raw_input().split(",")))
kind = len(set(hand))
ma = max([hand.count(i) for i in hand])
if kind == 4:
print "one pair"
elif kind == 3:
if ma == 2:
print "t... |
s222485071 | p00039 | u873482706 | 1435044834 | Python | Python | py | Runtime Error | 0 | 0 | 1010 | def brain(l):
c = l[1] - l[0]
if 0 < c:
result.append(c)
del lis[0]
del lis[0]
else:
lis.append(l[0])
del lis[0]
def cisco(l):
for i in range(len(l)):
if l[i] == 'I':
l[i] = 1
elif l[i] == 'V':
l[i] = 5
elif... |
s569736704 | p00039 | u379956761 | 1443357528 | Python | Python3 | py | Runtime Error | 0 | 0 | 1060 | import sys
def dec_num(x):
for i in range(len(x)):
if x[i] == 2:
x[i] = 5
elif x[i] == 3:
x[i] = 10
elif x[i] == 4:
x[i] = 50
elif x[i] == 5:
x[i] = 100
elif x[i] == 6:
x[i] = 500
elif x[i] == 7:
... |
s089445379 | p00039 | u148101999 | 1460005555 | Python | Python | py | Runtime Error | 0 | 0 | 1532 | #encoding=utf-8
import sys
def inp():
for line in sys.stdin:
word = line.split()
je(word[0])
def je(word):
ans, i = 0, 0
while True:
print word[i], ans
if word[i] == "M":
ans += 1000
elif word[i] == "D":
ans += 500
elif word[i] == "C"... |
s882159880 | p00039 | u148101999 | 1460005815 | Python | Python | py | Runtime Error | 0 | 0 | 1489 | import sys
def inp():
for line in sys.stdin:
word = line.split()
je(word[0])
def je(word):
ans, i = 0, 0
while True:
if word[i] == "M":
ans += 1000
elif word[i] == "D":
ans += 500
elif word[i] == "C":
ans += 100
try:
... |
s056456436 | p00039 | u661290476 | 1482918560 | Python | Python3 | py | Runtime Error | 0 | 0 | 309 | nums={"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}
while True:
try:
s=input()
except:
break
ans=nums[s[0]]
for i in range(len(s)):
if num[s[i-1]]<num[s[i]]:
ans+=num[s[i]]-2*num[s[i-1]]
else:
ans+=num[s[i]]
print(ans)
|
s062840968 | p00039 | u661290476 | 1482918592 | Python | Python3 | py | Runtime Error | 0 | 0 | 311 | nums={"I":1,"V":5,"X":10,"L":50,"C":100,"D":500,"M":1000}
while True:
try:
s=input()
except:
break
ans=nums[s[0]]
for i in range(1,len(s)):
if num[s[i-1]]<num[s[i]]:
ans+=num[s[i]]-2*num[s[i-1]]
else:
ans+=num[s[i]]
print(ans)
|
s655399782 | p00039 | u633068244 | 1393417348 | Python | Python | py | Runtime Error | 0 | 0 | 457 | dict = {"I":1, "V":5, "X":10, "L":50, "C":100, "D":500, "M":1000}
while True:
try:
roman = raw_input()
sum = 0
value = 1000
for i in range(len(roman)):
if value >= dict[roman[i]]:
value = dict[roman[i]]
sum += value
elif:
... |
s500265614 | p00039 | u436634575 | 1401187238 | Python | Python3 | py | Runtime Error | 0 | 0 | 315 | import sys
C = [ 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
N = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
def checkio(data, i = 0):
return C[i]*(data // N[i]) + checkio(data % N[i], i + 1) if data else ''
for line in sys.stdin:
n = int(line)
print(checkio(n)) |
s487629725 | p00040 | u567380442 | 1423296374 | Python | Python3 | py | Runtime Error | 0 | 0 | 1208 | import sys
f = sys.stdin
import string
OFFSET = ord('a')
def to_gamma(c):
return ord(c) - OFFSET
def from_gamma(gamma, alpha, beta):
return chr((alpha * gamma + beta) % 26 + OFFSET)
def affine(c, alpha, beta):
return from_gamma(to_gamma(c), alpha, beta)
# g[0]==g[3]である前提
def search_that(w):
b =... |
s047334270 | p00040 | u879226672 | 1429803556 | Python | Python | py | Runtime Error | 0 | 0 | 1207 | def affine_cipher(word,alpha,beta):
newword = ''
for c in word:
newword += w[(alpha*dic[c]+beta)%26]
return newword
def find_quad_word(sentence):
r = []
for word in sentence:
if len(word)==4:
r.append(word)
return r
def get_alpha_and_beta(quad_word):
'''retur... |
s147883287 | p00040 | u901080241 | 1491712141 | Python | Python3 | py | Runtime Error | 0 | 0 | 577 | from math import gcd
def unzip(strlist,a,b):
ret = []
for word in strlist:
tmp = ""
for i in range(len(word)):
tmp += chr(((ord(word[i])-97)*a+b)%26+97)
ret.append(tmp)
return ret
n = int(input())
for _ in range(n):
instr = input().split()
for a in range(1,26):
... |
s169719439 | p00040 | u282635979 | 1363844680 | Python | Python | py | Runtime Error | 0 | 0 | 2104 | list_a = [0,1,3,5,7,9,11,13,15,17,19,21,23]
num_al = {0:'a',1:'b',2:'c',3:'d',4:'e',5:'f',6:'g',7:'h',8:'i',9:'j',10:'k',11:'l',12:'m',13:'n',14:'o',15:'p',16:'q',17:'r',18:'s',19:'t',20:'u',21:'v',22:'w',23:'x',24:'y',25:'z'}
n = input() + 1
for val in range(1,n):
num_a = 0
num_b = 0
sentence = raw_input()
words =... |
s012105230 | p00040 | u282635979 | 1363845387 | Python | Python | py | Runtime Error | 0 | 0 | 2101 | list_a = [0,1,3,5,7,9,11,13,15,17,19,21,23]
num_al = {0:'a',1:'b',2:'c',3:'d',4:'e',5:'f',6:'g',7:'h',8:'i',9:'j',10:'k',11:'l',12:'m',13:'n',14:'o',15:'p',16:'q',17:'r',18:'s',19:'t',20:'u',21:'v',22:'w',23:'x',24:'y',25:'z'}
n = input() + 1
for val in range(1,n):
num_a = 0
num_b = 0
sentence = raw_input()
words =... |
s772791615 | p00040 | u282635979 | 1363846241 | Python | Python | py | Runtime Error | 0 | 0 | 2101 | list_a = [0,1,3,5,7,9,11,13,15,17,19,21,23]
num_al = {0:'a',1:'b',2:'c',3:'d',4:'e',5:'f',6:'g',7:'h',8:'i',9:'j',10:'k',11:'l',12:'m',13:'n',14:'o',15:'p',16:'q',17:'r',18:'s',19:'t',20:'u',21:'v',22:'w',23:'x',24:'y',25:'z'}
n = input() + 1
for val in range(1,n):
num_a = 0
num_b = 0
sentence = raw_input()
words =... |
s556325882 | p00040 | u282635979 | 1363847578 | Python | Python | py | Runtime Error | 0 | 0 | 2101 | list_a = [0,1,3,5,7,9,11,13,15,17,19,21,23]
num_al = {0:'a',1:'b',2:'c',3:'d',4:'e',5:'f',6:'g',7:'h',8:'i',9:'j',10:'k',11:'l',12:'m',13:'n',14:'o',15:'p',16:'q',17:'r',18:'s',19:'t',20:'u',21:'v',22:'w',23:'x',24:'y',25:'z'}
n = input() + 1
for val in range(1,n):
num_a = 0
num_b = 0
sentence = raw_input()
words =... |
s856868510 | p00040 | u282635979 | 1363848178 | Python | Python | py | Runtime Error | 0 | 0 | 2103 | list_a = [0,1,3,5,7,9,11,13,15,17,19,21,23]
num_al = {0:'a',1:'b',2:'c',3:'d',4:'e',5:'f',6:'g',7:'h',8:'i',9:'j',10:'k',11:'l',12:'m',13:'n',14:'o',15:'p',16:'q',17:'r',18:'s',19:'t',20:'u',21:'v',22:'w',23:'x',24:'y',25:'z'}
n = input() + 1
for val in range(1,n):
num_a = 0
num_b = 0
sentence = raw_input()
words =... |
s467529826 | p00040 | u782850731 | 1375514702 | Python | Python | py | Runtime Error | 0 | 0 | 1121 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
unicode_literals)
from sys import stdin
from string import ascii_lowercase
from itertools import count
def gcd(m, n):
m, n = sorted([m, n])
while n:
m, n = n, m % n
... |
s516363661 | p00040 | u912237403 | 1387579507 | Python | Python | py | Runtime Error | 0 | 0 | 799 | A2Z="abcdefghijklmnopqrstuvwxyz"
def decode(L1,L2,msg):
x=[]
for c in msg:
if 'a'<=c<='z':
c = L2[L1.index(c)]
x.append(c)
return "".join(x)
def affine(msg, key):
a,b = key
L = [A2Z[(i*a+b)%26] for i in range(26)]
L = "".join(L)
return decode(A2Z,L,msg)
... |
s426287584 | p00040 | u912237403 | 1387579575 | Python | Python | py | Runtime Error | 0 | 0 | 813 | A2Z="abcdefghijklmnopqrstuvwxyz"
def decode(L1,L2,msg):
x=[]
for c in msg:
if 'a'<=c<='z':
c = L2[L1.index(c)]
x.append(c)
return "".join(x)
def affine(msg, key):
a,b = key
L = [A2Z[(i*a+b)%26] for i in range(26)]
L = "".join(L)
return decode(A2Z,L,msg)
... |
s196103674 | p00040 | u633068244 | 1393662328 | Python | Python | py | Runtime Error | 0 | 0 | 884 | dict = ["a","b","c","d","e","f","g","h","i","j","k","l","m",\
"n","o","p","q","r","s","t","u","v","w","x","y","z"]
lsalpha = [1,3,5,7,9,11,15,17,19,21,23,25]
def deaffine(alpha, beta, code):
decode = ""
for chara in code:
if chara != " ":
f = dict.index(chara)
for i in r... |
s621346679 | p00041 | u329400409 | 1453031113 | Python | Python3 | py | Runtime Error | 0 | 0 | 710 | import itertools
def calc(n):
for op in itertools.product(operators, repeat=3):
for form in forms:
formula = form.format(op[0], op[1], op[2], n[0], n[1], n[2], n[3])
if eval(formula) == 10:
print(formula)
return True
return False
operators = ("+"... |
s375801768 | p00041 | u329400409 | 1453031318 | Python | Python3 | py | Runtime Error | 0 | 0 | 710 | import itertools
def calc(n):
for op in itertools.product(operators, repeat=3):
for form in forms:
formula = form.format(op[0], op[1], op[2], n[0], n[1], n[2], n[3])
if eval(formula) == 10:
print(formula)
return True
return False
operators = ("+"... |
s742968238 | p00041 | u150984829 | 1518720835 | Python | Python3 | py | Runtime Error | 0 | 0 | 386 | import itertools
def f(a):
if len(a)<2:yield(a[0],a[0])
for i in range(1,len(a)):
for p,s in f(a[:i]):
for q,t in f(a[i:]):
yield(p+q,f'({s}+{t})')
yield(p-q,f'({s}-{t})')
yield(p*q,f'({s}*{t})')
def s(a):
for p in itertools.permutations(a):
for n,s in f(p):
if n==10:print(s);return 1
while 1:
... |
s423825963 | p00041 | u150984829 | 1518721842 | Python | Python3 | py | Runtime Error | 0 | 0 | 402 | import itertools,sys
def f(a):
if len(a)<2:yield[a[0]]*2
for i in range(1,len(a)):
for p,s in f(a[:i]):
for q,t in f(a[i:]):
yield(p+q,f'({s} + {t})')
yield(p-q,f'({s} - {t})')
yield(p*q,f'({s} * {t})')
def s(a):
for p in itertools.permutations(a):
for n,s in f(p):
if n==10:print(s);return 1
fo... |
s955181896 | p00041 | u150984829 | 1518724665 | Python | Python3 | py | Runtime Error | 0 | 0 | 412 | from itertools import *
def f(s):
for t in[f"({a} {x} {b}) {y} ({c} {z} {d})",f"(({a} {x} {b}) {y} {c}) {z} {d}",f"{a} {x} ({b} {y} ({c} {z} {d}))",f"({a} {x} ({b} {y} {c})) {z} {d}",f"{a} {x} (({b} {y} {c}) {z} {d})"]:
for a,b,c,d in permutations(s):
for x,y,z in product('+-*',repeat=3):
if eval(t)==10:retur... |
s541356293 | p00041 | u150984829 | 1518725349 | Python | Python3 | py | Runtime Error | 0 | 0 | 436 | from itertools import *
def f(s):
for t in["({a} {x} {b}) {y} ({c} {z} {d})","(({a} {x} {b}) {y} {c}) {z} {d}","{a} {x} ({b} {y} ({c} {z} {d}))","({a} {x} ({b} {y} {c})) {z} {d}","{a} {x} (({b} {y} {c}) {z} {d})"]:
for a,b,c,d in permutations(s):
for x,y,z in product('+-*',repeat=3):
t='f"'+t+'"'
if eval(... |
s622880502 | p00041 | u749355444 | 1381421508 | Python | Python | py | Runtime Error | 0 | 0 | 402 | from itertools import *
def find(X):
for a,b,c,d in permutations(X):
for x,y,z in product("+-*",repeat=3):
for f in ("(((%s%s%s)%s%s)%s%s)","(%s%s%s)%s(%s%s%s)"):
t = f%(a,x,b,y,c,z,d)
if eval(t)==10:
return t
return 0
while True:
X =... |
s561914327 | p00041 | u912237403 | 1387688999 | Python | Python | py | Runtime Error | 0 | 0 | 1356 | def op(x,y,i):
if i==0:
return x+y
elif i==1:
return x-y
elif i==2:
return x*y
def check(x, n):
a1,a2,a3,a4 = x[0],x[1],x[2],x[3]
s='+-*'
for i1 in range(3):
a1 = op(x[0],x[1],i1)
for i2 in range(3):
a2 = op(a1,x[2],i2)
for i3 in r... |
s545869569 | p00041 | u633068244 | 1394277906 | Python | Python | py | Runtime Error | 0 | 0 | 668 | ex = ["+", "-", "*"]
while True:
a, b, c, d = map(int, raw_input().split())
if a == 0 and c == 0:
break
for i in ex:
for j in ex:
for k in ex:
if eval( (((a k b) j c) i d)) == 10:
print "(((",a,k,b,")",j,c,")",i,d,")"
flag =... |
s157799306 | p00041 | u633068244 | 1394278884 | Python | Python | py | Runtime Error | 0 | 0 | 634 | ex = ["+", "-", "*"]
while True:
a, b, c, d = map(str, raw_input().split())
if a == 0 and c == 0:
break
for i in ex:
for j in ex:
for k in ex:
if eval( "((("+a+k+b+")"+j+c+")"+i+d+")") == 10:
print "(((",a,k,b,")",j,c,")",i,d,")"
... |
s726647185 | p00041 | u633068244 | 1394278922 | Python | Python | py | Runtime Error | 0 | 0 | 692 | ex = ["+", "-", "*"]
while True:
a, b, c, d = map(str, raw_input().split())
if a == 0 and c == 0:
break
for i in ex:
for j in ex:
for k in ex:
if eval( "((("+a+k+b+")"+j+c+")"+i+d+")") == 10:
print "(((",a,k,b,")",j,c,")",i,d,")"
... |
s664061780 | p00041 | u633068244 | 1394278956 | Python | Python | py | Runtime Error | 0 | 0 | 692 | ex = ["+", "-", "*"]
while True:
a, b, c, d = map(str, raw_input().split())
if a == 0 and c == 0:
break
for i in ex:
for j in ex:
for k in ex:
if eval( "((("+a+k+b+")"+j+c+")"+i+d+")") == 10:
print "(((",a,k,b,")",j,c,")",i,d,")"
... |
s752245597 | p00041 | u633068244 | 1394291913 | Python | Python | py | Runtime Error | 0 | 0 | 1598 | op = ["+", "-", "*"]
while True:
a, b, c, d = map(str, raw_input().split())
if a == 0 and c == 0:
break
n = [0,1,2,3]
q = [str(a),str(b),str(c),str(d)]
flag = 0
for i in op:
for j in op:
for k in op:
for ii in n:
m = [0,1,2,3]
... |
s587427804 | p00041 | u633068244 | 1394291935 | Python | Python | py | Runtime Error | 0 | 0 | 1598 | op = ["+", "-", "*"]
while True:
a, b, c, d = map(str, raw_input().split())
if a == 0 and c == 0:
break
n = [0,1,2,3]
q = [str(a),str(b),str(c),str(d)]
flag = 0
for i in op:
for j in op:
for k in op:
for ii in n:
m = [0,1,2,3]
... |
s719266638 | p00041 | u633068244 | 1394291988 | Python | Python | py | Runtime Error | 0 | 0 | 1598 | op = ["+", "-", "*"]
while True:
a, b, c, d = map(str, raw_input().split())
if a == 0 and c == 0:
break
n = [0,1,2,3]
q = [str(a),str(b),str(c),str(d)]
flag = 0
for i in op:
for j in op:
for k in op:
for ii in n:
m = [0,1,2,3]
... |
s073622564 | p00041 | u633068244 | 1394292021 | Python | Python | py | Runtime Error | 0 | 0 | 1598 | op = ["+", "-", "*"]
while True:
a, b, c, d = map(str, raw_input().split())
if a == 0 and c == 0:
break
n = [0,1,2,3]
q = [str(a),str(b),str(c),str(d)]
flag = 0
for i in op:
for j in op:
for k in op:
for ii in n:
m = [0,1,2,3]
... |
s081157157 | p00041 | u633068244 | 1394292072 | Python | Python | py | Runtime Error | 0 | 0 | 1598 | op = ["+", "-", "*"]
while True:
a, b, c, d = map(str, raw_input().split())
if a == 0 and c == 0:
break
n = [0,1,2,3]
q = [str(a),str(b),str(c),str(d)]
flag = 0
for i in op:
for j in op:
for k in op:
for ii in n:
m = [0,1,2,3]
... |
s180452399 | p00041 | u633068244 | 1394293079 | Python | Python | py | Runtime Error | 0 | 0 | 1521 | op = ["+", "-", "*"]
x = int(raw_input())
while True:
a, b, c, d = map(str, raw_input().split())
if a == 0 and c == 0:
break
n = [0,1,2,3]
q = [str(a),str(b),str(c),str(d)]
flag = 0
m = [0,1,2,3]
m.remove(ii)
for jj in m:
l = [0,1,2,3]
l.remove(ii);l.remove(jj)
... |
s247173275 | p00041 | u633068244 | 1394293165 | Python | Python | py | Runtime Error | 0 | 0 | 1537 | op = ["+", "-", "*"]
x = int(raw_input())
while True:
a, b, c, d = map(str, raw_input().split())
if a == 0 and c == 0:
break
n = [0,1,2,3]
q = [str(a),str(b),str(c),str(d)]
flag = 0
m = [0,1,2,3]
m.remove(ii)
for ii in n:
for jj in m:
l = [0,1,2,3]
... |
s176157853 | p00041 | u633068244 | 1394293198 | Python | Python | py | Runtime Error | 0 | 0 | 1521 | op = ["+", "-", "*"]
x = int(raw_input())
while True:
a, b, c, d = map(str, raw_input().split())
if a == "0" and c == "0":
break
n = [0,1,2,3]
q = [a,b,c,d]
flag = 0
m = [0,1,2,3]
m.remove(ii)
for ii in n:
for jj in m:
l = [0,1,2,3]
l.remove(ii);l.... |
s562102812 | p00042 | u198477543 | 1535190442 | Python | Python3 | py | Runtime Error | 0 | 0 | 667 | count = 0
while True:
count += 1
W = int(input())
if W == 0:
break
N = int(input())
value = []
weight = []
for i in range(N):
a, b = map(int, input().split())
value.append(a)
weight.append(b)
dp = [[-float("inf") for i in range(W+1)] for j in range(N+1)]
... |
s581468718 | p00042 | u540744789 | 1426832129 | Python | Python | py | Runtime Error | 0 | 0 | 795 | while True:
# try:
case=0
while True:
case+=1
weight=input()
if weight==0:
break
N=input()
data=[[0 for i in range(2)] for j in range(N)]
for i in range(N):
data[i][0],data[i][1]=map(int,raw_input().split(","))
table=[[-1 for i ... |
s119841462 | p00042 | u489809100 | 1447687529 | Python | Python | py | Runtime Error | 0 | 0 | 617 | import itertools
count = 0
while True:
w = int(raw_input())
if w == 0:
break
m = int(raw_input())
n = [0 for _ in xrange(m)]
h = [0 for _ in xrange(m)]
count += 1
for i in xrange(m):
n[i],h[i] = map(int,raw_input().split(","))
js= []
for i in xrange(m):
lis = list(itertools.combinations(n, m - i))
... |
s755133983 | p00042 | u489809100 | 1447687696 | Python | Python | py | Runtime Error | 0 | 0 | 594 | import itertools
count = 0
while True:
w = int(raw_input())
if w == 0:
break
m = int(raw_input())
n = [0 for _ in xrange(m)]
h = [0 for _ in xrange(m)]
count += 1
for i in xrange(m):
n[i],h[i] = map(int,raw_input().split(","))
js= []
jk = []
for i in xrange(m):
lis = list(itertools.combinations(h, ... |
s477125888 | p00042 | u489809100 | 1447687985 | Python | Python | py | Runtime Error | 0 | 0 | 595 | import itertools
count = 0
while True:
w = int(raw_input())
if w == 0:
break
m = int(raw_input())
n = [0 for _ in xrange(m)]
h = [0 for _ in xrange(m)]
count += 1
for i in xrange(m):
n[i],h[i] = map(int,raw_input().split(","))
tr = []
ty = []
for i in xrange(m):
lis = list(itertools.combinations(h,... |
s819002453 | p00042 | u489809100 | 1447688180 | Python | Python | py | Runtime Error | 0 | 0 | 647 | import itertools
count = 0
if __name__ == "__main__":
while True:
w = int(raw_input())
if w == 0:
break
m = int(raw_input())
n = [0 for _ in xrange(m)]
h = [0 for _ in xrange(m)]
count += 1
for i in xrange(m):
n[i],h[i] = map(int,raw_input().split(","))
tr = []
ty = []
for i in xrange(m)... |
s759286285 | p00042 | u896025703 | 1469782069 | Python | Python3 | py | Runtime Error | 1200 | 72480 | 686 |
def rec(i, j):
if dp[i][j] != -1:
return dp[i][j]
if i == N:
ans = 0, W - j
elif j < wl[i]:
ans = rec(i + 1, j)
else:
v1, w1 = rec(i + 1, j)
v2, w2 = rec(i + 1, j - wl[i])
v2 += vl[i]
if v1 > v2:
ans = v1, w1
elif v1 < v2:
ans = v2, w2
elif v1 == v2:
if w1 < w2:
ans = v1, w1
else... |
s815694651 | p00042 | u896025703 | 1469782249 | Python | Python3 | py | Runtime Error | 420 | 27088 | 686 |
def rec(i, j):
if dp[i][j] != -1:
return dp[i][j]
if i == N:
ans = 0, W - j
elif j < wl[i]:
ans = rec(i + 1, j)
else:
v1, w1 = rec(i + 1, j)
v2, w2 = rec(i + 1, j - wl[i])
v2 += vl[i]
if v1 > v2:
ans = v1, w1
elif v1 < v2:
ans = v2, w2
elif v1 == v2:
if w1 < w2:
ans = v1, w1
else... |
s048310023 | p00042 | u896025703 | 1469782451 | Python | Python3 | py | Runtime Error | 1870 | 110788 | 685 |
def rec(i, j):
if dp[i][j] != -1:
return dp[i][j]
if i == N:
ans = 0, W - j
elif j < wl[i]:
ans = rec(i + 1, j)
else:
v1, w1 = rec(i + 1, j)
v2, w2 = rec(i + 1, j - wl[i])
v2 += vl[i]
if v1 > v2:
ans = v1, w1
elif v1 < v2:
ans = v2, w2
elif v1 == v2:
if w1 < w2:
ans = v1, w1
else... |
s966402467 | p00042 | u896025703 | 1469782523 | Python | Python3 | py | Runtime Error | 1870 | 110656 | 701 |
def rec(i, j):
if dp[i][j] != -1:
return dp[i][j]
if i == N:
ans = (0, W - j)
elif j < wl[i]:
ans = rec(i + 1, j)
else:
(v1, w1) = rec(i + 1, j)
(v2, w2) = rec(i + 1, j - wl[i])
v2 += vl[i]
if v1 > v2:
ans = (v1, w1)
elif v1 < v2:
ans = (v2, w2)
elif v1 == v2:
if w1 < w2:
ans = (v1,... |
s961308360 | p00042 | u896025703 | 1469782753 | Python | Python3 | py | Runtime Error | 1860 | 110692 | 758 |
def rec(i, j):
if 3000 < i or 3000 < j:
while True:
print("aaa")
if dp[i][j] != -1:
return dp[i][j]
if i == N:
ans = (0, W - j)
elif j < wl[i]:
ans = rec(i + 1, j)
else:
(v1, w1) = rec(i + 1, j)
(v2, w2) = rec(i + 1, j - wl[i])
v2 += vl[i]
if v1 > v2:
ans = (v1, w1)
elif v1 < v2:
ans ... |
s883618968 | p00042 | u896025703 | 1469783450 | Python | Python3 | py | Runtime Error | 20 | 7800 | 911 |
def rec(i, j):
#print("rec({}, {}) called".format(i, j))
"""
if dp[i][j] != -1:
return dp[i][j]
"""
if i in dphash and j in dphash[i]:
return dphash[i][j]
if i == N:
ans = (0, W - j)
elif j < wl[i]:
ans = rec(i + 1, j)
else:
(v1, w1) = rec(i + 1, j)
(v2, w2) = rec(i + 1, j - wl[i])
v2 += vl[i]
... |
s281336939 | p00042 | u896025703 | 1469783579 | Python | Python3 | py | Runtime Error | 20 | 7668 | 911 |
def rec(i, j):
#print("rec({}, {}) called".format(i, j))
"""
if dp[i][j] != -1:
return dp[i][j]
"""
if i in dphash and j in dphash[i]:
return dphash[i][j]
if i == N:
ans = (0, W - j)
elif j < wl[i]:
ans = rec(i + 1, j)
else:
(v1, w1) = rec(i + 1, j)
(v2, w2) = rec(i + 1, j - wl[i])
v2 += vl[i]
... |
s680688302 | p00042 | u896025703 | 1469783622 | Python | Python3 | py | Runtime Error | 20 | 7688 | 863 |
def rec(i, j):
#print("rec({}, {}) called".format(i, j))
if i in dphash and j in dphash[i]:
return dphash[i][j]
if i == N:
ans = (0, W - j)
elif j < wl[i]:
ans = rec(i + 1, j)
else:
(v1, w1) = rec(i + 1, j)
(v2, w2) = rec(i + 1, j - wl[i])
v2 += vl[i]
if v1 > v2:
ans = (v1, w1)
elif v1 < v2:
... |
s494253673 | p00042 | u896025703 | 1469783849 | Python | Python3 | py | Runtime Error | 20 | 7696 | 866 |
def rec(i, j):
#print("rec({}, {}) called".format(i, j))
if i in dphash and j in dphash[i]:
return dphash[i][j]
if i == N:
ans = (0, W - j)
elif j < wl[i]:
ans = rec(i + 1, j)
else:
(v1, w1) = rec(i + 1, j)
(v2, w2) = rec(i + 1, j - wl[i])
v2 += vl[i]
if v1 > v2:
ans = (v1, w1)
elif v1 < v2:
... |
s851735541 | p00042 | u896025703 | 1469936504 | Python | Python3 | py | Runtime Error | 0 | 0 | 704 | case = 1
while True:
W = int(input())
if W == 0: break
N = int(input())
vl = []
wl = []
for _ in range(N):
v, w = map(int, input().split(','))
vl.append(v)
wl.append(w)
dp = [[[0, 0] for j in range(W + 1)] for i in range(N + 1)]
for i in range(N - 1, -1, -1):
for j in range(0, W + 1):
if j < wl[i]:
... |
s795849336 | p00042 | u812047151 | 1469941947 | Python | Python3 | py | Runtime Error | 30 | 7752 | 863 |
def rec(i, j):
#print("rec({}, {}) called".format(i, j))
if i in dphash and j in dphash[i]:
return dphash[i][j]
if i == N:
ans = (0, W - j)
elif j < wl[i]:
ans = rec(i + 1, j)
else:
(v1, w1) = rec(i + 1, j)
(v2, w2) = rec(i + 1, j - wl[i])
v2 += vl[i]
if v1 > v2:
ans = (v1, w1)
elif v1 < v2:
... |
s774923613 | p00042 | u661290476 | 1482134694 | Python | Python3 | py | Runtime Error | 0 | 0 | 583 | times=0
while True:
times+=1
W=int(input())
n=int(input())
if W==0:
break
w=[0]*n
v=[0]*n
for i in range(n):
v[i],w[i]=map(int,input().split(","))
dp=[[0]*(W+1) for i in range(n+1)]
for i in range(n):
for j in range(W+1):
if j<w[i]:
... |
s761508934 | p00042 | u252368621 | 1482161628 | Python | Python3 | py | Runtime Error | 20 | 7736 | 908 | def dfs_dp(w, v, N, W, index, dp):
if (dp[index][W][0] != -1):
return dp[index][W]
if index==N: return [0,0]
if W<w[index]: return dfs_dp(w, v, N, W, index + 1, dp)
temp1=dfs_dp(w, v, N, W, index + 1, dp)
temp=dfs_dp(w, v, N, W - w[index], index + 1, dp)
temp2=[v[index] + temp[0],w[inde... |
s133473839 | p00042 | u227162786 | 1490176514 | Python | Python3 | py | Runtime Error | 20 | 7636 | 902 | # i????????\??????????????§??????j??§??????(?????§??????, ??????????????????)
def ns(vs, ws, i, j, dp):
if dp[i][j][0] != -1:
return dp[i][j]
if i == len(vs):
return [0, 0]
else:
if ws[i] > j:
dp[i][j] = ns(vs, ws, i+1, j, dp)
return dp[i][j]
else:
... |
s428893666 | p00042 | u227162786 | 1490176972 | Python | Python3 | py | Runtime Error | 30 | 7752 | 913 | # i????????\??????????????§??????j??§??????(?????§??????, -??????????????????)
def ns(vs, ws, i, j, dp):
if dp[i][j][0] != -1:
return dp[i][j]
if i == len(vs):
return [0, 0]
else:
if ws[i] > j:
dp[i][j] = ns(vs, ws, i+1, j, dp)
return dp[i][j]
else:
... |
s323617671 | p00042 | u227162786 | 1490177069 | Python | Python3 | py | Runtime Error | 30 | 7692 | 831 | def ns(vs, ws, i, j, dp):
if dp[i][j][0] != -1:
return dp[i][j]
if i == len(vs):
return [0, 0]
else:
if ws[i] > j:
dp[i][j] = ns(vs, ws, i+1, j, dp)
return dp[i][j]
else:
tmp = ns(vs, ws, i+1, j-ws[i], dp)
dp[i][j] = max(ns(vs,... |
s397182723 | p00042 | u144068724 | 1494954030 | Python | Python3 | py | Runtime Error | 0 | 0 | 31 | # coding: utf-8
count += 1 |
s619283595 | p00042 | u144068724 | 1494954048 | Python | Python3 | py | Runtime Error | 0 | 0 | 30 | # coding: utf-8
count = 1 |
s361318135 | p00042 | u144068724 | 1494954435 | Python | Python3 | py | Runtime Error | 0 | 0 | 470 | def get():
p,w = map(int, raw_input().split(","))
for i in range(W-w,-1,-1):
if bag[i] > 0 and bag[i]+p > bag[i+w]:
bag[i+w] = bag[i]+p
else:
if p > bag[w]: bag[w] = p
return
c = 1
while True:
W = int(raw_input())
if W == 0: break
bag = [0]*(W+1)
N = int(raw... |
s213256570 | p00042 | u868716420 | 1496190409 | Python | Python3 | py | Runtime Error | 0 | 0 | 966 | from itertools import combinations
case = 0
while True :
limit = int(input())
if limit == 0 : break
case += 1
number = int(input())
value, weight = [], []
for _ in range(number) :
a, b = input().split(',')
value.append(int(a))
weight.append(int(b))
temp1, te... |
s802438537 | p00042 | u009961299 | 1504775562 | Python | Python3 | py | Runtime Error | 20 | 7756 | 704 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import itertools
def solve():
cache = dict()
def loop(i, w):
if (i, w) in cache:
return cache[i, w]
if i == N:
return (0, 0)
cache[i, w] = loop(i + 1, w)
if v[i][1] <= w:
t = loop(i + 1, w - v[i][... |
s573891222 | p00042 | u009961299 | 1504775668 | Python | Python3 | py | Runtime Error | 30 | 7696 | 653 | import itertools
def solve():
cache = {}
def loop(i, w):
if (i, w) in cache:
return cache[i, w]
if i == N:
return (0, 0)
cache[i, w] = loop(i + 1, w)
if v[i][1] <= w:
t = loop(i + 1, w - v[i][1])
cache[i, w] = max(cache[i, w], (t[0... |
s892533809 | p00042 | u009961299 | 1504775859 | Python | Python3 | py | Runtime Error | 30 | 7796 | 667 | import itertools
def solve(W, N, v):
cache = {}
def loop(i, w):
if (i, w) in cache:
return cache[i, w]
if i == N:
return (0, 0)
cache[i, w] = loop(i + 1, w)
if v[i][1] <= w:
t = loop(i + 1, w - v[i][1])
cache[i, w] = max(cache[i, w... |
s953407805 | p00042 | u009961299 | 1504776121 | Python | Python3 | py | Runtime Error | 30 | 7716 | 768 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import itertools
def solve(W, N, v):
cache = [[None for _ in range(W + 1)] for _ in range(N)]
def loop(i, w):
if i == N:
return (0, 0)
if cache[i][w] is not None:
return cache[i][w]
cache[i][w] = loop(i + 1, w)
... |
s709644587 | p00042 | u009961299 | 1504776682 | Python | Python3 | py | Runtime Error | 20 | 7804 | 788 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import itertools
def solve(W, N, v):
cache = {}
def loop(i, w):
if i == N:
return (0, 0)
if (i, w) in cache:
return cache[i, w]
cache[i, w] = loop(i + 1, w)
if v[i][1] <= w:
t = loop(i + 1, w - v[... |
s630073206 | p00042 | u150984829 | 1525016228 | Python | Python3 | py | Runtime Error | 0 | 0 | 267 | c=0
for W in iter(input,'0\n'):
c+=1
W=int(W)
dp=[0]*-~W
for _ in[0]*int(input()):
v,w=map(int,input().split(','))
for i in range(W,w-1,-1):
if dp[i]<dp[i-w]+v:dp[i]=dp[i-w]+v
for i in range(W+1):
if dp[W]==dp[i]:print(f'Case {c}:\n{dp[W]}\n{i}');break
|
s197093521 | p00042 | u019169314 | 1527996745 | Python | Python3 | py | Runtime Error | 30 | 5616 | 1109 | case = 0
while True:
W = int(input())
if W == 0:
break
N = int(input())
case += 1
# a list of [itemValue, itemWeight]
items = [list(map(int,input().split(','))) for i in range(N)]
dp = {}
def bestVW(item, capa):
if (item,capa) in dp:
return dp[(item,capa)]
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.