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
s755477275
p04001
u340153434
1566160905
Python
Python (3.4.3)
py
Runtime Error
20
3060
296
S = input() n = len(S)-1 total_num = 0 for i in range(2**n): num = '' for j in range(n): if i & 2**j: num += S[j] total_num += int(num) num = '' else: num += S[j] num += S[j+1] total_num += int(num) print(total_num)
s242486012
p04001
u102126195
1566047438
Python
PyPy3 (2.4.0)
py
Runtime Error
199
40496
431
S = input() S_len = len(S) - 1 p = [] for i in range(2 ** S_len): tmp = bin(i)[2::] while len(tmp) < S_len: tmp = "0" + tmp p.append(str(tmp)) sum = 0 for i in p: P = list(i) tmp = int(S[0]) cnt = 1 for j in P: if j == "0": tmp *= 10 tmp += int(S[cnt]...
s012193765
p04001
u412255932
1565962874
Python
Python (3.4.3)
py
Runtime Error
20
3060
240
S = int(input()) def dfs(res, depth, path, S): res.append(path) if depth == len(S) - 1: return for i in range(depth + 1, len(S)): dfs(res, i, int(S[depth:i+1]), S) res = [] dfs(res, -1, [], S) print(sum(res))
s572497347
p04001
u548684908
1565812017
Python
Python (3.4.3)
py
Runtime Error
18
3060
291
s = list(input()) def sum_list(S,stock): if len(S) == 2: return int(S[0]) + int(S[1]) + int(S[0]+S[1]) + stock * 2 else: return sum_list(S[1:],int(S[0])+stock) + sum_list([S[0]+S[1]]+S[2:],stock) print(sum_list(s,0))
s374680520
p04001
u537782349
1564588858
Python
Python (3.4.3)
py
Runtime Error
19
3064
476
def clc(a, b, c, p, t): if c == 0: b = a[0] return clc(a, b, c + 1, True, t) + clc(a, b, c + 1, False, t) elif c == len(a)-1: if p: return t + int(b) + int(a[c]) else: return t + int(b + a[c]) else: if p: t += int(b) b =...
s986933215
p04001
u708255304
1564185701
Python
Python (3.4.3)
py
Runtime Error
17
2940
238
S = str(input()) ans = "" for mask in range(1 << (len(S)-1)): for i in range(len(S)): if ((mask >> i) & 1): ans += f"{S[i]}+" else: ans += f"{S[i]}" ans += "+" print(int(eval(ans[:-1])))
s136257407
p04001
u708255304
1564185452
Python
Python (3.4.3)
py
Runtime Error
18
3188
235
S = str(input()) ans = "" for mask in range(1 << (len(S)-1)): for i in range(len(S)): if (mask >> i) & 1: ans += f"{S[i]}+" else: ans += f"{S[i]}" ans += "+" print(int(eval(ans[:-1])))
s771509884
p04001
u708255304
1564185368
Python
Python (3.4.3)
py
Runtime Error
17
2940
230
S = str(input()) ans = "" for mask in range(1 << (len(S)-1)): for i in range(len(S)): if (mask >> i) & 1: ans += f"{S[i]}+" else: ans += f"{S[i]}" ans += "+" print(eval(ans[:-1]))
s978627464
p04001
u537782349
1563669323
Python
Python (3.4.3)
py
Runtime Error
17
3064
461
def f(a, b, le, tf): b[le] = tf if le == len(b)-1: t = "" s1 = 0 for i in range(len(b)): t += a[i] if b[i] == 1: s1 += int(t) t = "" t += a[len(b)] s1 += int(t) return s1 else: return f(a, b, le+1...
s472929045
p04001
u537782349
1563669256
Python
Python (3.4.3)
py
Runtime Error
21
3316
423
def f(a, b, le, tf): b[le] = tf if le == len(b)-1: t = "" s1 = 0 for i in range(len(b)): t += a[i] if b[i] == 1: s1 += int(t) t = "" t += a[len(b)] s1 += int(t) return s1 else: return f(a, b, le+1...
s086095887
p04001
u836939578
1563564614
Python
Python (3.4.3)
py
Runtime Error
17
3060
298
s = input() op_n = len(s) - 1 ans = 0 for i in range(1 << op_n): sign = [""] * op_n for j in range(op_n): if ((i>>j)&1): sign[j] = "+" formula = "" for k in range(op_n): formula += s[k] + sign[k] formula += s[op-n] ans += eval(formula) print(ans)
s260196335
p04001
u836939578
1563564327
Python
Python (3.4.3)
py
Runtime Error
17
3060
295
s=input() op_n=len(s) - 1 ans=0 for i in range(1 << op_n): sign = [""] * op_n for j in range(op_n): if ((i>>j)&1)==1: sign[j] = "+" formula = "" for k in range(op_n): formula += s[k] + sign[k] formula += s[op-n] ans += eval(formula) print(ans)
s584974429
p04001
u836939578
1563564274
Python
Python (3.4.3)
py
Runtime Error
17
3060
297
s=input() op_n=len(s) - 1 ans=0 for i in range(1 << len(s)): sign = [""] * op_n for j in range(op_n): if ((i>>j)&1)==1: sign[j] = "+" formula = "" for k in range(op_n): formula += s[k] + sign[k] formula += s[op-n] ans += eval(formula) print(ans)
s050608083
p04001
u836939578
1563564191
Python
Python (3.4.3)
py
Runtime Error
18
3064
301
s=input() op_n=len(s) - 1 ans=0 for i in range(1 << len(s)): sign = [""] * op_n for j in range(op_n): if ((i>>j) and 1)==1: sign[j] = "+" formula = "" for k in range(op_n): formula += s[k] + sign[k] formula += s[op-n] ans += eval(formula) print(ans)
s039193208
p04001
u836939578
1563564156
Python
Python (3.4.3)
py
Runtime Error
18
3060
295
s=input() op_n=len(s) - 1 ans=0 for i in range(1 << len(s)): sign = [""] * op_n for j in range(op_n): if ((i>>j)==1): sign[j] = "+" formula = "" for k in range(op_n): formula += s[k] + sign[k] formula += s[op-n] ans += eval(formula) print(ans)
s605514735
p04001
u836939578
1563563736
Python
Python (3.4.3)
py
Runtime Error
17
3060
294
s=input() op_n=len(s) - 1 ans=0 for i in range(1 << len(s)): sign = [""] * op_n for j in range(op_n): if ((i>>j)==1): sign[j] = "+" formula = "" for k in range(op_n): formula += s[k] + sign[k] formula += s[op-n] ans = eval(formula) print(ans)
s968869675
p04001
u135847648
1563048442
Python
Python (3.4.3)
py
Runtime Error
38
3316
369
S = input() print(S[0],S[1]) cnt = len(S) - 1 #数字の間の数 ans = 0 for i in range(2 ** cnt): sign = [""] * cnt for j in range(cnt): if ((i>>j)&1): sign[j] = "+" formula = "" for k in range(cnt): formula += S[k] + sign[k] print(sign) formula += S[cnt] print(formula,i) ...
s301729557
p04001
u102461423
1562864681
Python
Python (3.4.3)
py
Runtime Error
238
16976
922
import sys input = sys.stdin.readline from scipy.sparse import csr_matrix from scipy.sparse.csgraph import dijkstra """ (駅、会社)を頂点にグラフを持つ。頂点数O(M)。 そのまま辺を貼ると辺が多くなりすぎる。 (駅、会社) -> (駅、無属性) -> (駅、会社) """ N,M = map(int,input().split()) PQC = [[int(x) for x in input().split()] for _ in range(M)] U = 10 ** 6 V = set(range(1...
s972042868
p04001
u374051158
1561557634
Python
Python (3.4.3)
py
Runtime Error
17
2940
168
S = input() ans = 0 for p in itertools.product(['', '+'], repeat = len(S) - 1): cmd = ''.join([s + t for s, t in zip(S, p)]) + S[-1] ans += eval(cmd) print(ans)
s400862312
p04001
u914992391
1560642147
Python
Python (3.4.3)
py
Runtime Error
19
3064
438
from sys import stdin def main(): S=input() andbit = 2**10 -1 ans = 0 length = 2**(len(S) -1) for i in range (length): bitup = andbit & i bitcheck = 1 tmp=0 for j in range(1,len(S),1): if bitup & bitcheck > 0: ans += int(S[tmp:j]) tmp = j ...
s043319306
p04001
u914992391
1560641123
Python
Python (3.4.3)
py
Runtime Error
19
3064
438
from sys import stdin def main(): S=input() andbit = 2**10 -1 ans = 0 length = 2**(len(S) -1) for i in range (length): bitup = andbit & i bitcheck = 1 tmp=0 for j in range(1,len(S),1): if bitup & bitcheck > 0: ans += int(S[tmp:j]) tmp = j ...
s272707119
p04001
u914992391
1560641018
Python
Python (3.4.3)
py
Runtime Error
19
3064
699
from sys import stdin def main(): S=input() andbit = 2**10 -1 ans = 0 length = 2**(len(S) -1) # print("length:{}".format(length)) for i in range (length): bitup = andbit & i # print("bin(bitup):{}".format(bin(bitup))) bitcheck = 1 tmp=0 for j in range(1,len(S)...
s400893401
p04001
u825842302
1560464425
Python
Python (3.4.3)
py
Runtime Error
17
2940
287
s = input() n = (len(s) - 1) ans_lst = [] for i in range(2**n): op = ["+"] * n for j in range(n): if ((i >> j) & 1): op[n-j-1] = "" for num,opp in zip(s, op + [""]): formula += (num + opp) ans_lst = ans_lst + [eval(formula)] print(sum(ans_lst))
s015412630
p04001
u977193988
1559941434
Python
Python (3.4.3)
py
Runtime Error
17
2940
185
S=input() n=len(S) ans=0 for i in range(1<<(n-1)): for j in range(n): if 1&(i>>j): ans+=int(S[k:j+1]) k=j+1 ans+=int(S[k:]) print(ans)
s557512350
p04001
u566264434
1559779392
Python
Python (3.4.3)
py
Runtime Error
17
2940
226
S=input() c=0 op_cnt=len(S)-1 for i in range(2**op_cnt): T="" for j in range(2**op_cnt): T += S[j] if ((i>>j) & 1): T += "+" print(j) T += S[op_cnt] c +=eval(T) print(c)
s069392017
p04001
u524039871
1559703532
Python
Python (3.4.3)
py
Runtime Error
29
3064
309
s=input() sl=[] ans=0 for iii in range(2**(len(s)-1)): sind='{:0'+str(len(s)-1)+'b}' astr=sind.format(iii) astr=astr.replace("1","+") astr=astr.replace("0","x") lans=s[0] for jjj in range(len(astr)): lans+=astr[jjj]+s[jjj+1] lans=lans.replace("x","") ans+=int(eval(lans)) print(ans)
s128293605
p04001
u736524428
1559542630
Python
Python (3.4.3)
py
Runtime Error
17
3060
794
s = input() max_plus = len(s) - 1 numList = [int(c) for c in s] sMax = (1 << max_plus) - 1 ans = 0 for plus_pos in range(sMax + 1): sum = 0 num = numList[0] for i in range(max_plus): if ((plus_pos >> i) & 1) == 1: sum += num num = numList[i + 1] else: ...
s772757338
p04001
u638320267
1559446044
Python
Python (3.4.3)
py
Runtime Error
17
3064
426
s = input() sum = 0 for i in range(2**(len(s)-1)): term = 0 for j in range(len(s)-1): term *= 10 if (i//(2**j))%2 == 0: sum += term + int(s[j]) term = 0 if j == len(s)-2: sum += int(s[-1]) else: term += int(s[j]) ...
s006990767
p04001
u867005447
1559178277
Python
Python (3.4.3)
py
Runtime Error
20
3064
455
num = input() num_array = [i for i in num] splits = len(num) - 1 n = 2 ** splits sum = 0 for i in range(n): bin = format(i, "0{}b".format(splits)) bin_array = [i for i in bin] tmp_num = str(num_array[0]) for index, value in enumerate(bin_array): if value == "0": tmp_num += num_ar...
s461238298
p04001
u805403870
1559025599
Python
Python (3.4.3)
py
Runtime Error
21
3064
394
s = input() answer = 0 sumList = [] numStr = "" for i in range(2**(len(s)-1)): bit = "0" + str(len(s) - 1) + "b" iStr = format(i, bit) numStr += s[0] for j in range(len(iStr)): if iStr[j] == "1": sumList.append(int(numStr)) numStr = s[j+1] else: numStr += s[j+1] sumList.append(int(nu...
s471606401
p04001
u537962130
1558441206
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38256
198
N=input() ans=0 l=itertools.product(range(2),repeat=len(N)-1) for i in l: tmp='' for j in range(len(i)): if i[j]==0: tmp+=N[j] else: tmp+=N[j]+'+' tmp+=N[-1] ans+=eval(tmp) print(ans)
s313869625
p04001
u497596438
1558380331
Python
PyPy3 (2.4.0)
py
Runtime Error
184
39792
273
S=input() ans=0 for i in range(2**(len(S)-1)): k=bin(i)[2:].zfill(len(S)-1) l=int(S[0]) for j in range(len(k)): t=int(k[j]) if t==1: ans+=l l=int(S[j+1]) else: l=l*10+int(S[j+1]) ans+=l print(ans)
s099252536
p04001
u292810930
1557116813
Python
Python (3.4.3)
py
Runtime Error
18
2940
199
S=list(map(int,list(input()))) def manyformulas(s): if len(s)==1: return s[0] return s[0]*2**(len(s)-2)+manyformulas(s[1:])+manyformulas([s[0]*10+s[1], *s[2:]]) print(manyformulas(S))
s507392584
p04001
u872887731
1556756266
Python
Python (3.4.3)
py
Runtime Error
18
3060
221
from itertools import product S = input() ans = 0 for string in product(["","+"],repeat=len(S) - 1): string = list(string) string.append("") sum_ = [a + b for a,b in zip(S,string)] ans += sum_ print(ans)
s734991013
p04001
u791050038
1556047040
Python
Python (3.4.3)
py
Runtime Error
17
3060
333
sum = 0 A = list(map(int, input().split)) def makenum(ar): s = 0 for i in range(len(ar)): s += ar[i] * (10 ** (len(ar) - i - 1)) return s for i in range(1 << len(A)): output = [] for j in range(len(A)): if((i >> j) & 1) == 1: output.append(A[j]) sum += makenum(outpu...
s715571191
p04001
u573970531
1555427566
Python
Python (3.4.3)
py
Runtime Error
21
3064
313
#import sys #input=sys.stdin.readline s=input() ans=0 for i in range(2 ** (len(s)-1)): bin_i = bin(i)[2:].rjust(len(s)-1,"0") li=[] n=s[0] for ix,sign in enumerate(bin_i): if sign=="0": n+=s[ix+1] else: li.append(int(n)) n=s[ix+1] li.append(int(n)) ans+=sum(li) print(ans)
s815071690
p04001
u573970531
1555427453
Python
Python (3.4.3)
py
Runtime Error
20
3064
335
#import sys #input=sys.stdin.readline s=input() ans=0 for i in range(2 ** (len(s)-1)): bin_i = bin(i)[2:].rjust(len(s)-1,"0") li=[] n=s[0] #0がなし、1が+ for ix,sign in enumerate(bin_i): if sign=="0": n+=s[ix+1] else: li.append(int(n)) n=s[ix+1] li.append(int(n)) ans+=sum(li) print...
s039627399
p04001
u573970531
1555427248
Python
Python (3.4.3)
py
Runtime Error
17
3064
333
import sys input=sys.stdin.readline s=input() ans=0 for i in range(2 ** (len(s)-1)): bin_i = bin(i)[2:].rjust(len(s)-1,"0") li=[] n=s[0] #0がなし、1が+ for ix,sign in enumerate(bin_i): if sign=="0": n+=s[ix+1] else: li.append(int(n)) n=s[ix+1] li.append(int(n)) ans+=sum(li) print(a...
s066854928
p04001
u201856486
1554727444
Python
Python (3.4.3)
py
Runtime Error
19
3192
4952
import sys # import bisect # import math # import itertools # import numpy as np # import collections """Template""" class IP: """ 入力を取得するクラス """ def __init__(self): self.input = sys.stdin.readline def I(self): """ 1文字の取得に使います :return: int """ ret...
s088719497
p04001
u772614554
1553831198
Python
Python (3.4.3)
py
Runtime Error
17
2940
83
from sys import stdin a = stdin.readline().rstrip() print(a.upper()) print(output)
s801668885
p04001
u569742427
1553818135
Python
Python (3.4.3)
py
Runtime Error
20
3064
466
S = input() N = len(S)-1 sumsum = 0 for i in range(2**N): binary = bin(i) binary = binary[2:].zfill(N) tmps = S[0] for j in range(N): if binary[j] == '0':    #ゼロの時はストックする 12<=3 = 123 tmps = tmps + S[j+1] else : sumsum += int(tmps) tmps = S[j+1] ...
s977021170
p04001
u392029857
1553126351
Python
Python (3.4.3)
py
Runtime Error
18
3064
870
s = input() op = ['','+'] if len(s) == 1: print(s) else: s = s + 'X'*(10 -len(s)) ans = [] for a in op: for b in op: for c in op: for d in op: for e in op: for f in op: for g in op: ...
s638437609
p04001
u582165344
1552514896
Python
Python (3.4.3)
py
Runtime Error
20
3060
272
s = input().split("") sum = 0 for i in range(2 ** (len(s)-1)) : st = str(s[0]) for j in range(len(s)-1) : if ((i >> j) & 1) : st = st + "+" + str(s[j+1]) else : st = st + str(s[j+1]) for item in st.split('+') : sum += int(item) print(sum)
s100720491
p04001
u853952087
1551888640
Python
Python (3.4.3)
py
Runtime Error
21
3064
346
s=int(input()) S=str(s) w=len(str(s))-1 l=[] L=[] for i in range(2**w): l.append(format(i, '0{}b'.format(w))) for e in l: q=[] x=int(S[0]) for i in range(len(e)): if e[i]=='0': x=x*10+int(S[i+1]) else: q.append(x) x=int(S[i+1]) q.append(x) L.ap...
s055830081
p04001
u853952087
1551888613
Python
Python (3.4.3)
py
Runtime Error
18
3064
345
s=int(input()) S=str(s) w=len(str(s))-1 l=[] L=[] for i in range(2**w): l.append(format(i, '0{}b'.format(w))) for e in l: q=[] x=int(S[0]) for i in range(len(e)): if e[i]=='0': x=x*10+int(S[i+1]) else: q.append(x) x=int(S[i+1]) q.append(x) L.ap...
s622552307
p04001
u594567187
1551244314
Python
PyPy3 (2.4.0)
py
Runtime Error
180
38640
408
target = input() length = len(target) binary = length - 1 target_list = [] answers = 0 for i in range(length): if i: target_list.append("") target_list.append(target[i]) for bit in range(2 ** binary): temp = target_list.copy() for i in range(binary): if bit & (1 << i): temp[1...
s431399593
p04001
u171366497
1549410922
Python
Python (3.4.3)
py
Runtime Error
84
7896
684
#2-1-1 #ABC045C s=input() lenth=len(s) kugiri=set() def roop(before,now,kugiri): if now==lenth: kugiri|={before,} return kugiri kugiri = roop(before+(0,),now+1,kugiri) kugiri = roop(before+(1,),now+1,kugiri) return kugiri kugiri = roop((0,),2,kugiri) kugiri = roop((1,),2,kugiri) def calc...
s270785683
p04001
u220904910
1549314079
Python
Python (3.4.3)
py
Runtime Error
30
3064
315
s=input() l=list(s) b=[] lst=[] # bi=[bin(2**i) for i in range(0,len(s))] for i in range(2**(len(s)-1)): b=list(str(bin(i))[2:].zfill(len(s)-1)) st=l[0] for j in range(len(b)): if int(b[j]): st+=l[j+1] else: st+='+'+l[j+1] lst.append(eval(st)) print(sum(lst))
s166435580
p04001
u309039873
1549221240
Python
Python (3.4.3)
py
Runtime Error
27
3064
484
S = input() power = 0 answer = 0 temps = int(S) while True: temps = temps/10 power += 1 if temps < 10: break SS = list(S) for i in range(1 << power): output = [] for j in range(power): if (i>>j)&1 == 1: output.append(SS[j]) output.append('+') else: ...
s748462603
p04001
u309039873
1549220969
Python
Python (3.4.3)
py
Runtime Error
28
3064
465
S = input() power = 0 answer = 0 temps = int(S) while True: temps = temps/10 power += 1 if temps < 10: break SS = list(S) for i in range(1 << power): output = [] for j in range(power): if (i>>j)&1 == 1: output.append(SS[j]) output.append('+') else: ...
s174504358
p04001
u077019541
1548927009
Python
Python (3.4.3)
py
Runtime Error
18
2940
1
a
s405848051
p04001
u375616706
1548704593
Python
Python (3.4.3)
py
Runtime Error
19
3188
653
H, W, N = map(int, input().split()) mat = [[0]*W for _ in range(H)] for _ in range(N): a, b = map(int, input().split()) mat[a-1][b-1] = 1 dp = [[0]*W for _ in range(H)] for h in range(H): cnt = 0 if mat[h][0] == 1: dp[h][0] = 1 for w in range(1, W): if mat[h][w] == 1: ...
s183549001
p04001
u669696235
1548352993
Python
Python (3.4.3)
py
Runtime Error
28
3060
219
N=input() slen=len(N)-1 ans=0 for i in range(2<<(slen-1)): k=N ins=0 for j in range(slen): if((i>>j)&1): k=k[:j+1+ins]+"+"+k[j+1+ins:] ins+=1 ans+=eval(k) print(ans)
s046073696
p04001
u876770991
1546751118
Python
Python (3.4.3)
py
Runtime Error
157
12408
394
import numpy as np import itertools S = input() nums = [s for s in S] idxs = np.arange(1, len(nums)) masks = list(itertools.product([False, True], repeat=len(idxs))) ret = 0 for mask in masks: selected_idxs = [0] +list( idxs[ np.array(mask)]) + [len(nums)] for i in range(len(selected_idxs) - 1): ret...
s814185140
p04001
u620945921
1543197677
Python
Python (3.4.3)
py
Runtime Error
18
3192
644
#import itertools list1=[k for k in input()] #print(list1) num1=len(list1) #print(num1) list00=[format(int(k), 'b') for k in range(2**(num1-1))] #print(list00) list0=['','+'] list01=[] for count1 in range(num1): x=list00[count1] list01.extend(x) #print(list01) total=0 for step1 in range(2): for step2 in range(...
s176757702
p04001
u620945921
1543197250
Python
Python (3.4.3)
py
Runtime Error
18
3064
639
#import itertools list1=[k for k in input()] print(list1) num1=len(list1) print(num1) list00=[format(int(k), 'b') for k in range(2**(num1-1))] print(list00) list0=['','+'] list01=[] for count1 in range(num1): x=list00[count1] list01.extend(x) print(list01) total=0 for step1 in range(2): for step2 in range(2): ...
s188029785
p04001
u209620426
1541886559
Python
Python (3.4.3)
py
Runtime Error
17
3060
241
def search(i,s): if i == n-1: li = [] s = "".join(s) li = list(map(int,s.split("+"))) total.append(sum(li)) return else: search(i+1,s) _s = s[:-(n-i)+1] + ["+"] + s[-(n-i)+1:] search(i+1,_s) search(0,s) print(sum(total))
s018643908
p04001
u366133198
1541560559
Python
Python (3.4.3)
py
Runtime Error
21
2940
723
#!/usr/bin/python3 import itertools def all_comb(n): comb = [] for i in range(0, n+1): comb.extend(list(itertools.co...
s351182252
p04001
u333768710
1538626745
Python
Python (3.4.3)
py
Runtime Error
26
3060
296
s = input() n = len(s) answer = 0 for i in range(2**(n-1)): calc_str = s[0] operator_maker = str(format(i, 'b')).zfill(n-1) for j, c in enumerate(operator_maker): if c == '1': calc_str += '+' calc_str += s[j+1] answer += eval(calc_str) print(answer)
s467471519
p04001
u218843509
1534157213
Python
PyPy3 (2.4.0)
py
Runtime Error
185
40304
429
from collections import Counter h, w, n = map(int, input().split()) dots = [list(map(int, input().split())) for _ in range(n)] c = Counter() for dot in dots: for i in range(-2, 1): for j in range(-2, 1): if 1 <= dot[0] + i < h - 1 and 1 <= dot[1] + j < w - 1: c[(dot[0] + i) * w + dot[1] + j] += 1 ans = [0...
s893423527
p04001
u144985238
1531103508
Python
Python (3.4.3)
py
Runtime Error
22
3188
1972
# 問題文 # 1 以上 9 以下の数字のみからなる文字列 S が与えられます。 この文字列の中で、あなたはこれら文字と文字の間のうち、いくつかの場所に + を入れることができます。 一つも入れなくてもかまいません。 ただし、+ が連続してはいけません。 # このようにして出来る全ての文字列を数式とみなし、和を計算することができます。 # ありうる全ての数式の値を計算し、その合計を出力してください。 # キーワード # 2n2n 通りを調べる全探索 (bit 全探索) # メモ化再帰が使えそう # 方向性 # 普通に計算すると、+ のありなし * n で2:2 3:4 4:8 2^n-1の通り数がある # 1234 # inp...
s133995662
p04001
u180908266
1529801036
Python
Python (3.4.3)
py
Runtime Error
90
3820
1752
from collections import deque N, M = map(int, input().split()) F_C_of_S = [{} for i in range(N)] # Companies of Station C_of_S = {} # def Union-find parent = [-1]*M def root(x): if (parent[x] < 0): return x else: parent[x] = y = root(parent[x]) return y def unite(x, y): px = root(x); py =...
s173457471
p04001
u180908266
1529715237
Python
Python (3.4.3)
py
Runtime Error
21
3316
615
from collections import deque N,M = map(int, input().split()) distance = [[float('inf'), 0]]*N distance[0] = [0, 0] Q = deque([[distance[0], 0]]) edges = [[] for _ in range(N)] for i in range(M): p,q,c = map(int, input().split()) edges[p-1] += [[q-1, c]] edges[q-1] += [[p-1, c]] flag = False while Q: dist,now = Q....
s360315222
p04001
u180908266
1529555426
Python
Python (3.4.3)
py
Runtime Error
17
3064
1346
N,M = map(int, input().split()) if M == 0: print(-1) exit() pqcs = [list(map(int, input().split())) for _ in range(M)] c_max = max(list(map(lambda x: x[2],pqcs))) node_num = (c_max+1)*N unsearached_nodes = list(range(node_num))#0~N-1(n-1)が乗換経由ノード/路線iの駅nは3*i+(n-1)番ノード #opt_nodes = [-1]*node_num distance = [float...
s215243534
p04001
u829895669
1527820480
Python
Python (3.4.3)
py
Runtime Error
17
3060
272
S = input() ans = 0 for i in range(1 << (len(S)-1)): eq = S for j in range(len(S)-1): if i & (1 << j): eq = eq[:j+1] + "," + eq[j+1:] else: pass eq = eq.split(",") eq = list(map(int,eq)) ans += sum(eq) print(ans)
s013979946
p04001
u829895669
1527820387
Python
Python (3.4.3)
py
Runtime Error
17
3060
245
S = input() ans = 0 for i in range(1 << (len(S)-1)): eq = S for j in range(len(S)-1): if i & (1 << j): eq = eq[:j+1] + "," + eq[j+1:] else: pass eq = eq.split(",") ans += sum(eq) print(ans)
s566535446
p04001
u265939044
1525407527
Python
Python (3.4.3)
py
Runtime Error
27
3064
343
S = input() R = 0 S = list(S) temp = [] if len(S)-1 == 0: R = int(S) for i in range(2**(len(S)-1)): for m in range(len(S)-1): if i+1 & 2**(m) > 0: temp.append(S[m] + "+") else: temp.append(S[m]) temp.append(S[len(S)-1]) temp = "".join(temp) R += eval(temp) ...
s443795622
p04001
u147458211
1524645411
Python
Python (3.4.3)
py
Runtime Error
17
3064
593
nums = map(int, list(input())) all_sum = 0 stack = [[0]*len(nums) -1] print(dfs(0, [0]*len(num) - 1)) def dfs(i, pluses): if i == len(num) - 2: pluses[i] = 0 sum1 = calc(pluses) pluses[i] = 1 sum2 = calc(pluses) return sum1 + sum2 else: i += 1 pluses[i] = 0 sum1 += dfs(i, pluses) ...
s110922021
p04001
u694433776
1524449494
Python
Python (3.4.3)
py
Runtime Error
22
2940
287
s=input() def solve(decided, left, idx): if idx==len(s): return decided+left # 手前に+を入れる ret1 = solve(decided+left,int(s[idx]),idx+1) # 入れない ret2 = solve(decided, left*10int(s[idx]), idx+1) return ret1+ret2 print(solve(0,int(s[0]),1))
s640815495
p04001
u766407523
1523470568
Python
Python (3.4.3)
py
Runtime Error
17
2940
149
def pt(s: list): if len(s) = 1: return eval(s[0]) return pt([s[0]+s[1]]+s[2:]) + pt([s[0]+'+'+s[1]]+s[2:]) print(pt(list((input()))))
s306038049
p04001
u766407523
1523468687
Python
Python (3.4.3)
py
Runtime Error
17
3060
152
def search(s): if len(s) <= 1: return eval(s[0]) return search([s[0]+s[1]]+s[2:]) + search([s[0]+'+'+s[1]]+s[2:]) print(search(input()))
s196549244
p04001
u667024514
1522097528
Python
Python (3.4.3)
py
Runtime Error
20
3316
542
from collections import Counter h, w, num = map(int, input().split()) lis = [] for i in range(num): k, j = map(lambda x: int(x) - 1,input().split()) for a in range(3): for b in range(3): cou1 = k - a cou2 = j - b if cou1 < 0 or cou1 > h - 3: continue ...
s287910036
p04001
u165233868
1522095278
Python
Python (2.7.6)
py
Runtime Error
10
2568
450
#s = int(raw_input()) 8 ssl = list(sl) 9 print('ssl',ssl) 10 total = 0 11 ss = sl 12 ss2 = '' 13 print('ss',ss) 14 15 for i in ss: 16 print('i',i,type(i),len(ss),type(len(ss))) 17 ss2 += str(i) 18 if i is str(len(ss)): 19 pass 20 else: 21 ss2 += '+...
s222574298
p04001
u319612498
1520727875
Python
Python (3.4.3)
py
Runtime Error
17
2940
502
s=list(map(int,list(input()))) n=len(s) ans=0 for i in range(1<<(n-1)): """ここで既に、n-1個の文字間のうち、どこに+を入れるかが決まる。入れるところにはbitが立ち(その桁が1となる)、入れないところにはbitが立たない(その桁が0となる)""" S=s[0] for j in range(n-1): if i & (1<<j): #bitが立っている時 S+="+"+s[j+1] else: #bitが立っていない時 S+=s[j+1] ans+=ev...
s207233201
p04001
u143492911
1520545992
Python
Python (3.4.3)
py
Runtime Error
17
2940
314
s=input() n=len(s) ans=0 for i in range(1<<n-1):#+を入れるかどうか num=s[0] for j in range(n-1):#+を入れるかどうか if i&(1<<j):#bitで考える,iと1<<jが同じ数字であれば実行 num+="+"+s[j+1] else: num+=s[j+1] ans+=eval(ins) print(ans)
s931153026
p04001
u435281580
1519675509
Python
Python (3.4.3)
py
Runtime Error
155
12516
703
import numpy as np N, M = map(int, input().split()) routes = np.array([list(map(int, input().split())) for _ in range(M)], 'i') #print(routes) # i駅まで到達したときの最小コスト(最終電車がjで示される) dp = [{} for _ in range(N + 1)] dp[1][0] = 0 for i in range(2, N + 1): for (f, t, m) in routes: if t != i: continue ...
s182175621
p04001
u984351908
1480882517
Python
Python (3.4.3)
py
Runtime Error
23
3184
639
def __main__(): h, w, n = list(map(int, input().split())) grid = [] for i in range(h): row = [] for j in range(w): row.append(0) grid.append(row) for i in range(n): ai, bi = list(map(int, input().split())) grid[ai - 1][bi - 1] = 1 result = [0]...
s829834930
p04001
u272028993
1476752331
Python
PyPy2 (5.6.0)
py
Runtime Error
40
8944
751
from collections import deque def main(): n,m=map(int,raw_input().split()) g=[[] for _ in xrange(n)] gc=[[] for _ in xrange(10**6)] mxc=0 for i in xrange(m): p,q,c=map(int,raw_input().split()) p-=1;q-=1;c-=1 g[p].append(c) g[q].append(c) gc[c].append(p) ...
s057033465
p04001
u276144769
1474723140
Python
Python (3.4.3)
py
Runtime Error
23
3064
200
dp=["","+"] s=input() su=0 for i in range(2**(len(s)-1)): val="" for j in range(len(s)-1): val+=s[j] val+=dp[int(bin(i)[j+2])] val+=s[len(s)-1] su+=eval(val) print(su)
s392828628
p04001
u276144769
1474683128
Python
Python (3.4.3)
py
Runtime Error
22
3064
194
dp=["","+"] s=input() su=0 for i in range(2**(len(s)-1)): val="" for j in range(len(s)-1): val+=s[j] val+=dp[bin(i)[j+2]] val+=s[len(s)-1] su+=eval(val) print(su)
s208269809
p04001
u276144769
1474681563
Python
Python (3.4.3)
py
Runtime Error
22
3064
181
dp=["","+"] s=input() su=0 for i in range(2**(len(s)-1)): val="" for j in range(len(s)-1): val+=s[j]+dp[bin(i)[j+2]] val+=s[len(s)-1] su+=eval(val) print(su)
s629776672
p04001
u477320129
1474060558
Python
Python (3.4.3)
py
Runtime Error
39
3064
459
from itertools import product H, W, N = list(map(int, input().split())) A = [tuple(map(int, input().split())) for _ in range(N)] count = {} for x, y in A: for xx, yy in product(range(x-1, x+2), range(y-1, y+2)): if not(2 <= xx <= H-1 and 2 <= yy <= W-1): continue count[(xx, yy)] = count....
s386085707
p04001
u393971002
1473889289
Python
Python (3.4.3)
py
Runtime Error
45
3064
544
s = input() l = len(s) - 1 # 各数の間の数 # 書く数の間に'+'を入れるときは1そうでないときは0にして2進数で表す # 全てで 2 ** l = 2 << (l - 1)通りできる total_patterns = 2 << (l - 1) ans = 0 for i in range(total_patterns): num_between = format(i,'b').zfill(l) # 10進数を2進数に変換 tmp = '' for j in range(l): if num_between[j] == '1': tmp += (s[...
s333923965
p04001
u393971002
1473888963
Python
Python (3.4.3)
py
Runtime Error
40
3064
412
s = input() start = time.time() l = len(s) - 1 # 各数の間の数 total_patterns = 2 << (l) ans = 0 for i in range(total_patterns): num_between = format(i,'b').zfill(l) # 10進数を2進数に変換 tmp = '' for j in range(l): if num_between[j] == '1': tmp += (s[j] + '+') else: tmp += s[j] tmp += s[...
s677549905
p04001
u393971002
1473884627
Python
Python (3.4.3)
py
Runtime Error
45
3188
522
s = input() int_s = [int(i) for i in s] l = len(int_s) total_patterns = 2 << (l - 2) def calc_sum(s): # '+'を区切りとして和を求める num = s.split('+') return sum(list(map(int, num))) ans = 0 for i in range(total_patterns): between = format(i,'b').zfill(l - 1) # 10進数を2進数に変換 tmp = '' for j in range(len(bet...
s695728664
p04001
u707500405
1473658334
Python
Python (2.7.6)
py
Runtime Error
28
2808
542
from collections import defaultdict from itertools import product from sys import stdin def gen_b(x,B): if x < 3: lb = 2 else: lb = x - 1 if x > B-2: ub = B-1 else: ub = x + 1 return xrange(lb,ub+1) def solve(): count = defaultdict(int) ans = [0]*10 L = map(lambda x:map(int,x.split()),stdin.readlines()) H,W,N ...
s961680043
p04001
u707500405
1473657900
Python
Python (2.7.6)
py
Runtime Error
31
2940
575
from collections import defaultdict from sys import stdin def gen_bound(x,B): if x < 3: lb = 2 else: lb = x - 1 if x > B-2: ub = B-1 else: ub = x + 1 return lb,ub+1 def solve(): count = defaultdict(int) ans = [0]*10 L = map(lambda x:map(int,x.split()),stdin.readlines()) H,W,N = L[0] for i in xrange(1,N+1): ...
s204489414
p04001
u765237551
1473648975
Python
Python (3.4.3)
py
Runtime Error
220
3444
454
from collections import defaultdict H, W, N = map(int, input().split()) poss = [list(map(int, input().split())) for _ in range(N)] d = defaultdict(int) for a, b in poss: for i, j in ((i, j) for i in range(a-1, a+2) for j in range(b-1, b+2)): if 1<i<H and 1<j<W: s = str(i)+":"+str(j) ...
s713686428
p04001
u680619771
1473647411
Python
Python (3.4.3)
py
Runtime Error
38
3064
958
import sys grid = [] painted = [] height, width, n = sys.stdin.readline().strip().split() height, width, n = int(height), int(width), int(n) def checkGrid(x, y, grid): count = 0 for col in range(x, x+3): for row in range(y, y+3): if grid[row][col] == 1: count += 1 retur...
s647580783
p04001
u098968285
1473642700
Python
Python (3.4.3)
py
Runtime Error
43
3064
385
# def makelist(n, m): # return [[0 for i in range(m)] for j in range(n)] # n = int(input()) # a, b = map(int, input().split()) # s = input() l = len(s) ans = 0 m = int('1'*(l-1), 2) for i in range(m+1): now = format(i, 'b').zfill(l-1) tmp = s[0] for k in range(l-1): if now[k] == '0': tmp += s[k+1] else...
s747733034
p04002
u107601154
1585887784
Python
Python (3.4.3)
py
Runtime Error
3207
780568
607
H,W,N= (int(x) for x in input().split()) a = [0] * N b = [0] * N for i in range(N): a[i],b[i] = (int(x) for x in input().split()) black = [[0 for i in range(W)] for j in range(H)] for i in range(N): black[a[i]-1][b[i]-1] = 1 answer = [0]*9 sum_black = [[0 for i in range(W-2)] for j in range(H-2)] for i in ran...
s329161048
p04002
u223904637
1575764071
Python
PyPy3 (2.4.0)
py
Runtime Error
3163
126724
402
h,w,n=map(int,input().split()) p=[] q=[-1,0,1] for i in range(n): a,b=map(int,input().split()) for j in q: for k in q: if 1<=a+j<=h and 1<=b+k<=w: p.append([a+j,b+k]) p.sort() n=len(p) f=1 ans=[0]*10 p.append([-1,-1]) for i in range(n): if p[i]==p[i+1]: f+=1 e...
s452839196
p04002
u627417051
1567920609
Python
PyPy3 (2.4.0)
py
Runtime Error
3163
132856
515
def getlist(): return list(map(int, input().split())) H, W, N = getlist() ans = [0] * 10 ans[0] = (H - 2) * (W - 2) L = [] for i in range(N): a, b = getlist() for j in range(3): for k in range(3): if H - 2 >= a - j and a - j >= 1 and W - 2 >= b - k and b - k >= 1: L.append([a - j, b - k]) L = sorted(L) n ...
s120340420
p04002
u627417051
1567920294
Python
PyPy3 (2.4.0)
py
Runtime Error
3163
145352
517
from fractions import gcd def getlist(): return list(map(int, input().split())) H, W, N = getlist() ans = [0] * 10 ans[0] = (H - 2) * (W - 2) L = [] for i in range(N): a, b = getlist() for j in range(3): for k in range(3): if H - 2 >= a - j and a - j >= 1 and W - 2 >= b - k and b - k >= 1: L.append([a - j...
s328900091
p04002
u059436995
1558630766
Python
Python (3.4.3)
py
Runtime Error
21
3316
504
from collections import defaultdict import sys h, w, n = int(sys.stdin.readline().split()) m3x3 =defaultdict(list) for _ in range(n): a, b = int(sys.stdin.readline().split()) for i in range(max(0, a - 3),min(h - 2, a)): for j in range(max(0, b - 3),min(w - 2, b)): if (i,j) in m3x3: ...
s889778736
p04002
u657913472
1551398563
Python
Python (3.4.3)
py
Runtime Error
18
3064
211
f=lambda:map(int,input().split()) h,w,n=f() c=[(h-2)*(w-2),*[0]*9] d={} while n: n-=1;x,y=f() for i in range(9): a=(x+i%3,y+i//3) if h>=x+i%3>2<y+i//3<=w:d[a]=d.get(a,0)+1;c[d[a]-1]-=1;c[d[a]]+=1 print(*c)
s635665160
p04002
u375616706
1548706665
Python
Python (3.4.3)
py
Runtime Error
3323
1695092
341
H, W, N = map(int, input().split()) mat = [[0]*(W+2) for _ in range(H+2)] for _ in range(N): a, b = map(int, input().split()) for i in range(-1, 2): for j in range(-1, 2): mat[a+i][b+j] += 1 ans = [0]*10 for i in range(H-2): for j in range(W-2): ans[mat[i+2][j+2]] += 1 for a ...
s396697767
p04002
u375616706
1548706572
Python
PyPy3 (2.4.0)
py
Runtime Error
3234
1420032
341
H, W, N = map(int, input().split()) mat = [[0]*(W+2) for _ in range(H+2)] for _ in range(N): a, b = map(int, input().split()) for i in range(-1, 2): for j in range(-1, 2): mat[a+i][b+j] += 1 ans = [0]*10 for i in range(H-2): for j in range(W-2): ans[mat[i+2][j+2]] += 1 for a ...
s229883346
p04002
u375616706
1548706125
Python
PyPy3 (2.4.0)
py
Runtime Error
4322
1098044
512
H, W, N = map(int, input().split()) mat = [[0]*W for _ in range(H)] for _ in range(N): a, b = map(int, input().split()) mat[a-1][b-1] = 1 dp = [[0]*(W-2) for _ in range(H)] ran = range(W) for h in range(H): for a, b, c in zip(ran, ran[1:], ran[2:]): co = mat[h][a]+mat[h][b]+mat[h][c] dp[h...
s561881881
p04002
u375616706
1548706038
Python
PyPy3 (2.4.0)
py
Runtime Error
3402
1282620
514
H, W, N = map(int, input().split()) mat = [[0]*W for _ in range(H)] for _ in range(N): a, b = map(int, input().split()) mat[a-1][b-1] = 1 dp = [[0]*(W-2) for _ in range(H)] ran = range(W) for h in range(H): for a, b, c in zip(ran, ran[1:], ran[2:]): co = mat[h][a]+mat[h][b]+mat[h][c] dp[h...