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
s433527446
p04045
u000123984
1583282925
Python
Python (3.4.3)
py
Runtime Error
17
2940
199
n,k = map(int, input().split()) li = [] i = 0 for i<k: li.append(int(input())) i += 1 else: Li = list(n) while not len(set(li)&set(Li)): n += 1 Li = list(n) else: print("".join(Li))
s587931355
p04045
u000123984
1583282751
Python
Python (3.4.3)
py
Runtime Error
17
2940
203
n,k = map(int, input().split()) li = [] i = 0 for i<k: li.append(int(input())) i += 1 else: Li = list(n) while not set(li)&set(Li) == set(): n += 1 Li = list(n) else: print("".join(Li))
s795267920
p04045
u000123984
1583282514
Python
Python (3.4.3)
py
Runtime Error
24
2940
200
n,k = map(int, input().split()) li = [] i = 0 for i<k: li.append(int(input())) i += 1 else: Li = list(n) while not set(li)&set(Li) == {}: n += 1 Li = list(n) else: print("".join(Li))
s244751703
p04045
u000123984
1583282406
Python
Python (3.4.3)
py
Runtime Error
17
2940
180
n,k = map(int, input().split()) li = [] i = 0 for i<k: li.append(int(input())) i += 1 else: Li = list(n) while li&Li: n += 1 Li = list(n) else: print("".join(Li))
s078372369
p04045
u000123984
1583281835
Python
Python (3.4.3)
py
Runtime Error
17
2940
190
n,k = map(int, input().split()) li = [] i = 0 for i<k: li.append(int(input())) i += 1 else: Li = list(str(n)) while li&Li: n += 1 Li = list(str(n)) else: print("".join(Li))
s511104597
p04045
u852798899
1583112338
Python
Python (3.4.3)
py
Runtime Error
17
3064
337
n, k = map(int, input().split()) d = list(map(int, input().split())) digit = [str(i) for i in range(10) if not i in d] ans = [] stack = [i for i in digit] while stack: s = stack.pop() if int(s) >= n: ans.append(s) else: for i in digit: if len(i+s) <= len(str(n)+1): stack.append(i+s) print(min(ans))
s348035345
p04045
u852798899
1583111337
Python
Python (3.4.3)
py
Runtime Error
48
3064
333
n, k = map(int, input().split()) d = list(map(int, input().split())) digit = [str(i) for i in range(10) if not i in d] ans = [] stack = [i for i in digit] while stack: s = stack.pop() if int(s) >= n: ans.append(s) else: for i in digit: if len(i+s) <= len(str(n)): stack.append(i+s) print(min(ans))
s332442476
p04045
u048561338
1582919566
Python
Python (3.4.3)
py
Runtime Error
214
2940
255
N,K=input().split() D=input().split() while True: for s in D: if N.count(s)!=0: frag=1 else: pass if frag==1: a=int(N)+1 N=str(a) frag=0 else: break print(N)
s984903932
p04045
u257251421
1582831192
Python
Python (3.4.3)
py
Runtime Error
17
3064
1403
N, K = map(int, input().split()) D = list(map(int, input().split())) N_str = str(N) nl = list(N_str) D_str = [] for i in D: D_str.append(str(i)) d_in_n = False for i in nl: if not i in D_str: continue else: d_in_n = True break if d_in_n == False: print(N) else: while len(nl) < 4: nl.insert(0,'0') L = [] for i in range(10): if not i in D: L.append(i) SUB = [] if nl[0] == '0' and nl[1] == '0' and nl[2] == '0': for l in L: N2 = l sub = N2 - N if N2 - N > 0: SUB.append(N2) elif nl[0] == '0' and nl[1] == '0': for k in L: for l in L: N2 = 10*k + l sub = N2 - N if N2 - N > 0: SUB.append(N2) elif nl[0] == '0': for j in L: for k in L: for l in L: N2 = 100*j + 10*k + l sub = N2 - N if N2 - N > 0: SUB.append(N2) else: for i in L: for j in L: for k in L: for l in L: N2 = 1000*i + 100*j + 10*k + l sub = N2 - N if N2 - N > 0: SUB.append(N2) SUB_s = sorted(SUB) print(SUB_s[0])
s881618628
p04045
u257251421
1582829001
Python
Python (3.4.3)
py
Runtime Error
20
3064
681
N, K = map(int, input().split()) D = list(map(int, input().split())) N_str = str(N) nl = list(N_str) D_str = [] for i in D: D_str.append(str(i)) d_in_n = False for i in nl: if not i in D_str: continue else: d_in_n = True break if d_in_n == False: print(N) else: L = [] for i in range(10): if not i in D: L.append(i) SUB = [] for i in L: for j in L: for k in L: for l in L: N2 = 1000*i + 100*j + 10*k + l sub = N2 - N if N2 - N > 0: SUB.append(N2) SUB_s = sorted(SUB) print(SUB_s[0])
s132125779
p04045
u257251421
1582828732
Python
Python (3.4.3)
py
Runtime Error
18
3064
690
N, K = map(int, input().split()) D = list(map(int, input().split())) N_str = str(N) nl = list(N_str) D_str = [] for i in D: D_str.append(str(i)) d_in_n = False for i in nl: if not i in D_str: continue else: d_in_n = True break if d_in_n == False: print(N) else: L = [] for i in range(10): if not i in D: L.append(i) SUB = [] for i in L: for j in L: for k in L: for l in L: N2 = 1000*i + 100*j + 10*k + l sub = N2 - N if N2 - N > 0: SUB.append(N2 - N) SUB_s = sorted(SUB) print(SUB_s[0] + N)
s666851219
p04045
u048561338
1582584924
Python
Python (3.4.3)
py
Runtime Error
216
2940
259
N,K=input().split() dis=list() dis=input().split() while True: for c in dis: if N.count(c)!=0: frag=1 else: pass if frag==1: N=int(N)+1 N=str(N) frag=0 else: break print(N)
s816482826
p04045
u048561338
1582584731
Python
Python (3.4.3)
py
Runtime Error
220
2940
260
N,K=input().split() dis=list(K) dis=input().split() while True: for c in dis: if N.count(c)!=0: frag=1 else: pass if frag==1: N=int(N)+1 N=str(N) frag=0 else: break print(N)
s854761401
p04045
u048561338
1582584340
Python
Python (3.4.3)
py
Runtime Error
213
2940
261
N,K=input().split() dis=list(K) dis=input().split() while True: for c in dis: if N.count(c)!=0: frag=1 else: pass if frag==1: N=int(N)+1 N=str(N) frag=0 else: break print(N)
s910077611
p04045
u620157187
1582536320
Python
Python (3.4.3)
py
Runtime Error
37
3064
606
N, K = map(int, input().split()) D = list(map(str, input().split())) num_set = set(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']) N_list = list(str(N)) diff_list = sorted(list(num_set.difference(set(D)))) if (list(set(D)&set(N_list)) == []): print(N) else: if '0' in diff_list: n_list = [diff_list[1]] + ['0']*len(N_list) else: n_list = [diff_list[0]]*len(N_list+1) str_n = '' for i in n_list: str_n += str(i) new_n = int(str_n)+1 for ii in range(N, new_n): if list(set(list(str(ii)))&set(D)) == []: print(ii) break
s519747783
p04045
u068584789
1582489410
Python
Python (3.4.3)
py
Runtime Error
17
3060
288
n, k = map(int, input().split()) d = list(map(int, input().split())) a = 0 for i in range(n, 10000): if checknum(i, d): a = i break print(a) def checknum(n, d): for s in str(n): if d.count(int(s)) > 0: return False return True if __name__ == '__main__': main()
s372765487
p04045
u734936991
1582409239
Python
Python (3.4.3)
py
Runtime Error
17
3060
381
#!/use/bin/env python3 (n, k) = [int(s) for s in input().split()] a = [int(s) for s in input().split()] like = [] ans = n while (1): c = True for ii in range(0, 4): b = b // 10 d = b % 10 if b == 0: break if d in a: c = False break if (c): ans = n break n += 1 print(ans)
s851141967
p04045
u052221988
1581799867
Python
Python (3.4.3)
py
Runtime Error
17
3060
268
n, k = map(int, input().split()) list_num = [input() for i in range(k)] price = n while True : i = 0 for i in range(len(str(price))) : if str(price)[i] in list_num : price += 1 break else : print(price) break
s942944719
p04045
u736729525
1581730334
Python
PyPy3 (2.4.0)
py
Runtime Error
174
38256
531
from functools import lru_cache N, K = map(int, input().split()) D = input().split() O = [] for c in "0123456789": if c not in D: O.append(c) # N = 523 # D = 2 3 @lru_cache() def func(s, i, over): if i == len(s): return "" # d < N[0] if over: return O[0] + func(s, i+1, over=True) for d in O: if d < s[i]: continue if s[i] == d: return d + func(s, i+1, over=False) return d + func(s, i+1, over=True) print(func(str(N), 0, over=False))
s471397095
p04045
u736729525
1581730306
Python
PyPy3 (2.4.0)
py
Runtime Error
174
38256
531
from functools import lru_cache N, K = map(int, input().split()) D = input().split() O = [] for c in "0123456789": if c not in D: O.append(c) # N = 523 # D = 2 3 @lru_cache() def func(s, i, over): if i == len(s): return "" # d < N[0] if over: return O[0] + func(s, i+1, over=True) for d in O: if d < s[i]: continue if s[i] == d: return d + func(s, i+1, over=False) return d + func(s, i+1, over=True) print(func(str(N), 0, over=False))
s553321790
p04045
u143212659
1581717184
Python
Python (3.4.3)
py
Runtime Error
20
3060
394
#!/usr/bin/env python3 # -*- coding: utf-8 -*- def main(): N, K = map(int, input().split()) D = set(list(map(int, input().split()))) F = set(list(range(10))) - D result = '' for n in str(N): if int(n) in F: result += n else: result += str(min([f for f in F if f > int(n)])) print(result) if __name__ == "__main__": main()
s685696716
p04045
u595289165
1581449848
Python
Python (3.4.3)
py
Runtime Error
18
3064
484
n, k = map(int, input().split()) d = set(map(int, input().split())) inf = 10 * n + 1 num = [] for i in range(10): if i in d: pass else: num.append(i) for i in num: if i >= int(str(n)[0]): ans = i break def dfs(pos, x): if pos == len(str(n)): if x >= n: return x else: return inf ret = [ dfs(pos + 1, 10 * x + num_i) for num_i in num ] return min(ret) print(dfs(1, ans))
s735177766
p04045
u556610039
1581346230
Python
Python (3.4.3)
py
Runtime Error
17
3064
460
n, k = map(int, input().split()) d_i = set(map(int, input().split())) full = set(range(10)) useableList = full - d_i useable_Top = full - d_i - set([0]) answer = [] isTop = True for x in str(n): if int(x) in useableList: answer.append(x) elif isTop: answer.append(min(useable_Top - set(range(int(x) + 1)))) else: answer.append(min(useableList)) if isTop: isTop = False; ans = '' for x in range(len(answer)): ans += str(answer[x]) print(ans)
s840302495
p04045
u857070771
1580226843
Python
Python (3.4.3)
py
Runtime Error
19
3188
273
n,k=map(int,input().split()) d={int(x) for x in input().split()} e={0,1,2,3,4,5,6,7,8,9} f=list(d^e) ans=[] for i in f: for j in f: for k in f: for l in f: ans.append(1000*i+100*j+10*k+l) ans=[m for m in ans if m>= n] print(min(ans))
s186809174
p04045
u857070771
1580226190
Python
Python (3.4.3)
py
Runtime Error
149
12480
258
import numpy as np m,k=map(int,input().split()) d={int(x) for x in input().split()} e={np.arange(10)} f=list(d&e) ans=[] for i in f: for j in f: for k in f: for l in f: ans.append(1000*i+100*j+10*k+l) print(min(ans))
s471508901
p04045
u984276646
1580152563
Python
Python (3.4.3)
py
Runtime Error
40
3416
410
N, K = map(int, input().split()) D = list(map(int, input().split())) S = "" ND = [] for i in range(10): if i not in D: ND.append(i) if K == 9: while int(S) < N: S = str(ND[0]) + S[:] print(int(S)) else: l = 0 F = ND[0] while F < N: l += 1 s = l F = 0 ju = 1 while s != 0: F += ND[s%(10-K)] * ju s //= 10 - K ju *= 10 print(F, end = ' ') print(F)
s135002621
p04045
u984276646
1580152216
Python
Python (3.4.3)
py
Runtime Error
30
3064
386
N, K = map(int, input().split()) D = list(map(int, input().split())) S = "" ND = [] for i in range(10): if i not in D: ND.append(i) if K == 9: while int(S) < N: S = str(ND[0]) + S[:] print(int(S)) else: l = 0 F = ND[0] while F < N: l += 1 s = l F = 0 ju = 1 while s != 0: F += ND[s%(10-K)] * ju s //= 10 - K ju *= 10 print(F)
s166208744
p04045
u696831348
1579712540
Python
Python (3.4.3)
py
Runtime Error
17
3060
244
N, K = map(int, input().split()) D = list(map(int, input().split())) flg = True while True: num = str(N) for i in range(len(num)): if num[i] in D: flg = False break if fig is True: print(int(num)) break N += 1
s354045818
p04045
u355865104
1579491610
Python
Python (3.4.3)
py
Runtime Error
17
3064
313
if __name__ == "__main__": N,K = input().split() D = input().split() num = set([str(i) for i in range(10)]) diff = num^set(D) print(diff) ans = N while True: strN = set(list(ans)) if strN - diff: ans += 1 else: break print(ans)
s552316850
p04045
u355865104
1579491526
Python
Python (3.4.3)
py
Runtime Error
17
2940
301
if __name__ == "__main__": N, K = input().split(" ") D = input().split() num = set([str(i) for i in range(10)]) diff = num ^ set(D) temp = N while True: setN = set(list(N)) if setN - diff: temp += 1 else: break print(temp)
s786767069
p04045
u540761833
1579386412
Python
Python (3.4.3)
py
Runtime Error
18
3064
446
import bisect N,K = map(int,input().split()) D = list(map(int,input().split())) num = {0,1,2,3,4,5,6,7,8,9} Ds = set(D) diff = num^Ds if 0 in diff: diff.remove(0) lenn = len(str(N)) print(str(min(diff)) + '0'*(lenn-1)) else: lenn = len(str(N)) diff = list(diff) diff.sort() strN = str(N) for i in range(lenn): intN = int(strN[i]) ind = bisect.bisect_left(diff,intN) print(diff[ind],end='')
s789442993
p04045
u355865104
1579318272
Python
Python (3.4.3)
py
Runtime Error
18
3064
593
import os if __name__ == "__main__": temp = input().split(" ") N = temp[0] L = int(temp[1]) D = list(map(int, input().split(" "))) like = [] for i in range(0, 10): if D.count(i) == 0: like.append(i) ans = [] for n in N: for l in like: if int(l) >= int(n): ans.append(l) break if int("".join(map(str, ans))) < int("".join(map(str, N))): ans = [] for i in range(0, len(N)): ans.append(min(like)) print("".join(map(str, ans)))
s689612134
p04045
u380933932
1579066443
Python
Python (3.4.3)
py
Runtime Error
17
2940
223
nk=list(map(int,input().split())) d=list(map(int,input().split())) i=nk[0] ans=0 while ans=0: flag=0 for j in range(len(str(i))): if str(i)[j] in d: flag=1 break if flag==0: ans=i i+=1 print(ans)
s004414323
p04045
u380933932
1579066422
Python
Python (3.4.3)
py
Runtime Error
17
3060
222
nk=list(map(int,input().split())) d=set(map(int,input().split())) i=nk[0] ans=0 while ans=0: flag=0 for j in range(len(str(i))): if str(i)[j] in d: flag=1 break if flag==0: ans=i i+=1 print(ans)
s125513384
p04045
u179169725
1577937306
Python
Python (3.4.3)
py
Runtime Error
19
3064
723
# https://atcoder.jp/contests/abc042/tasks/arc058_a # 最悪でも10**6探索する程度なのでNを一つづつ足して全探索でもよくね? N, K = list(map(int, input().split())) D = set(input().split()) def is_inD(n: int): tmp = set(str(n)) return tmp.isdisjoint(D) # 頭の悪い全探索 # for i in range(N, N + 10 ** 6): # if is_inD(i): # print(i) # exit() # もっとスケーラブルな方法 all_nums = {str(i) for i in range(10)} use_nums = all_nums - D N_str = str(N) L = len(N_str) ans = [] for l in range(L): tmp = [] for num in use_nums: if int(num) >= int(N_str[l]): tmp.append(num) ans.append(min(tmp)) print(int(''.join(ans)))
s190375541
p04045
u141429472
1577576161
Python
Python (3.4.3)
py
Runtime Error
76
3960
301
import sys input = sys.stdin.readline N,K=map(int,input().rstrip().split()) D=list(map(int,input().rstrip().split())) def dfs(N): for i in range(K): if(str(N).find(str(D[i]))!=-1): dfs(N+1) return else: print(N) return return dfs(N)
s354540588
p04045
u141429472
1577575851
Python
Python (3.4.3)
py
Runtime Error
105
6784
1043
import sys input = sys.stdin.readline N,K=map(int,input().rstrip().split()) D=list(map(int,input().rstrip().split())) def dfs(N): for i in range(K): if(str(N).find(str(D[i]))!=-1): dfs(N+1) return else: print(N) return return def resolve(): dfs(N) from io import StringIO import unittest class TestClass(unittest.TestCase): def assertIO(self, input, output): stdout, stdin = sys.stdout, sys.stdin sys.stdout, sys.stdin = StringIO(), StringIO(input) resolve() sys.stdout.seek(0) out = sys.stdout.read()[:-1] sys.stdout, sys.stdin = stdout, stdin self.assertEqual(out, output) def test_入力例_1(self): input = """1000 8 1 3 4 5 6 7 8 9""" output = """2000""" self.assertIO(input, output) def test_入力例_2(self): input = """9999 1 0""" output = """9999""" self.assertIO(input, output) if __name__ == "__main__": #unittest.main() resolve()
s737995449
p04045
u141429472
1577575756
Python
PyPy3 (2.4.0)
py
Runtime Error
366
57708
1022
import sys input = sys.stdin.readline N,K=map(int,input().rstrip().split()) D=list(map(int,input().rstrip().split())) def dfs(N): for i in range(K): if(str(N).find(str(D[i]))!=-1): dfs(N+1) return else: print(N) def resolve(): dfs(N) from io import StringIO import unittest class TestClass(unittest.TestCase): def assertIO(self, input, output): stdout, stdin = sys.stdout, sys.stdin sys.stdout, sys.stdin = StringIO(), StringIO(input) resolve() sys.stdout.seek(0) out = sys.stdout.read()[:-1] sys.stdout, sys.stdin = stdout, stdin self.assertEqual(out, output) def test_入力例_1(self): input = """1000 8 1 3 4 5 6 7 8 9""" output = """2000""" self.assertIO(input, output) def test_入力例_2(self): input = """9999 1 0""" output = """9999""" self.assertIO(input, output) if __name__ == "__main__": #unittest.main() resolve()
s849938192
p04045
u141429472
1577575321
Python
Python (3.4.3)
py
Runtime Error
102
6588
1022
import sys input = sys.stdin.readline N,K=map(int,input().rstrip().split()) D=list(map(int,input().rstrip().split())) def dfs(N): for i in range(K): if(str(N).find(str(D[i]))!=-1): dfs(N+1) return else: print(N) def resolve(): dfs(N) from io import StringIO import unittest class TestClass(unittest.TestCase): def assertIO(self, input, output): stdout, stdin = sys.stdout, sys.stdin sys.stdout, sys.stdin = StringIO(), StringIO(input) resolve() sys.stdout.seek(0) out = sys.stdout.read()[:-1] sys.stdout, sys.stdin = stdout, stdin self.assertEqual(out, output) def test_入力例_1(self): input = """1000 8 1 3 4 5 6 7 8 9""" output = """2000""" self.assertIO(input, output) def test_入力例_2(self): input = """9999 1 0""" output = """9999""" self.assertIO(input, output) if __name__ == "__main__": #unittest.main() resolve()
s964271346
p04045
u923657126
1577468677
Python
Python (3.4.3)
py
Runtime Error
17
3064
686
n, k = map(int,input().split()) d = list(map(int,input().split())) ns = str(n) e = [] for i in range(k): if i not in d: e.append(i) f = True ans_s = '' for j in range(len(ns)): if f: for l in range(len(e)): if e[l] >= int(ns[j]): ans_s += str(e[l]) if e[l] > int(ns[j]): f = False break else: ans_s += str(e[0]) ans_od = '' if e[0]==0: ans_od += str(e[1]) else: ans_od += str(e[0]) for m in range(len(ns)): ans_od += str(e[0]) if ans_s != '': if int(ans_s)>=n: print(int(ans_s)) else: print(int(ans_od)) else: print(int(ans_od))
s618953863
p04045
u923657126
1577465306
Python
Python (3.4.3)
py
Runtime Error
17
3064
792
n, k = map(int,input().split()) d = list(map(int,input().split())) def over_digit(): ans_d = '' if e[0]==0: ans_d += str(e[1]) else: ans_d += str(e[0]) for m in range(len(ns)): ans_d += str(e[0]) return ans_d ns = str(n) e = [] for i in range(k): if i not in d: e.append(i) f = True ans_s = '' for j in range(len(ns)): if f: for l in range(len(e)): if e[l] >= int(ns[j]): ans_s += str(e[l]) if e[l] > int(ns[j]): f_con = False break else: ans_s += str(e[0]) if ans_s != '': if int(ans_s)>=n: print(int(ans_s)) else: ans = int(over_digit()) print(ans) else: ans = int(over_digit()) print(ans)
s511413966
p04045
u923657126
1577465241
Python
Python (3.4.3)
py
Runtime Error
17
3064
792
n, k = map(int,input().split()) d = list(map(int,input().split())) ns = str(n) e = [] for i in range(k): if i not in d: e.append(i) f = True ans_s = '' for j in range(len(ns)): if f: for l in range(len(e)): if e[l] >= int(ns[j]): ans_s += str(e[l]) if e[l] > int(ns[j]): f_con = False break else: ans_s += str(e[0]) if ans_s != '': if int(ans_s)>=n: print(int(ans_s)) else: ans = int(over_digit()) print(ans) else: ans = int(over_digit()) print(ans) def over_digit(): ans_d = '' if e[0]==0: ans_d += str(e[1]) else: ans_d += str(e[0]) for m in range(len(ns)): ans_d += str(e[0]) return ans_d
s667180854
p04045
u581187895
1577417069
Python
Python (3.4.3)
py
Runtime Error
25
3316
293
import bisect from itertools import product N, K = map(int, input().split()) D = map(int, input().split()) like_num = set(range(0,10)) ^ set(D) length = len(str(N)) comb = [int("".join(map(str, a))) for a in product(like_num, repeat=length)] ind = bisect.bisect_left(comb, N) print(comb[ind])
s252633980
p04045
u308695322
1576997408
Python
Python (3.4.3)
py
Runtime Error
17
3064
643
n, k = input().split() d_list = list(map(int, input().split())) u_list = [u for u in range(10) if u not in d_list] replace_lis = [u_list[0]] * 10 for i in range(10): for j in range(i,10): if j in u_list: replace_lis[i] = j break n_list = list(map(int, list(n)[::-1])) + [0] for i in range(len(n_list)): if n_list[i] == 10: n_list[i] = 0 n_list[i + 1] += 1 if n_list[i] not in u_list: if n_list[i] > u_list[0]: n_list[i + 1] += 1 n_list[i] = replace_lis[n_list[i]] result = 0 for i in range(len(n_list)): result += n_list[i] * (10**i) print(result)
s051498846
p04045
u308695322
1576996672
Python
Python (3.4.3)
py
Runtime Error
17
3064
772
n, k = input().split() d_list = list(map(int, input().split())) u_list = [u for u in range(10) if u not in d_list] replace_lis = [u_list[0]] * 10 for i in range(10): for j in range(i,10): if j in u_list: replace_lis[i] = j break n_list = list(map(int, list(n)[::-1])) + [0] # print(f'n_list = {n_list}') # print(f'u_list = {u_list}') # print(f'replace_lis = {replace_lis}') # print('result', end="") for i in range(len(n_list)): if n_list[i] == 10: n_list[i] = 0 n_list[i + 1] += 1 if n_list[i] not in u_list: n_list[i] = replace_lis[n_list[i]] if n_list[i] == u_list[0]: n_list[i + 1] += 1 result = 0 for i in range(len(n_list)): result += n_list[i] * (10**i) print(result)
s678749790
p04045
u308695322
1576995423
Python
Python (3.4.3)
py
Runtime Error
17
3064
571
n, k = input().split() d_list = list(map(int, input().split())) u_list = [u for u in range(10) if u not in d_list] replace_lis = [u_list[0]] * 10 for i in range(10): for j in range(i,10): if j in u_list: replace_lis[i] = j break n_list = list(map(int, list(n)[::-1])) + [0] for i in range(len(n_list)): if n_list[i] not in u_list: n_list[i] = replace_lis[n_list[i]] if n_list[i] == u_list[0]: n_list[i + 1] += 1 result = 0 for i in range(len(n_list)): result += n_list[i] * (10**i) print(result)
s207169616
p04045
u433559751
1576979857
Python
Python (3.4.3)
py
Runtime Error
17
3064
452
N, K = map(str, input().split(" ")) num_hate = list(map(int, input().split(" "))) num_ok = [i for i in range(10) if i not in num_hate] N_new = N #print(num_ok) for i in range(len(N)): if int(N[i]) in num_hate: if i == 0: if num_ok[i] == 0: N_new = N.replace(N[i], str(num_ok[i+1]), 1) else: N_new = N.replace(N[i], str(num_ok[i]), 1) else: N_new = N.replace(N[i], str(num_ok[i]), 1) print(N_new)
s231617041
p04045
u477343425
1576024988
Python
Python (3.4.3)
py
Runtime Error
17
2940
715
#include <bits/stdc++.h> using namespace std; using ll = long long; int N, K; int D[11]; int main() { cin >> N >> K; for (int i = 0; i < K; i++) { cin >> D[i]; } ll num = N; while (1) { string s = to_string(num); // 数字を文字列にする bool ok = true; // 嫌いな数字が存在しないならtrue // 嫌いな数字の有無を判定 for (int i = 0; i < K; i++) { if (count(s.begin(), s.end(), D[i]+'0')) { ok = false; num++; break; } } // 嫌いな数字が無ければnumを出力して終了 if (ok) { cout << num << endl; return 0; } } return 0; }
s637355663
p04045
u994521204
1575649430
Python
PyPy3 (2.4.0)
py
Runtime Error
173
38768
367
N, K = list(map(int, input().split())) D = list(map(int, input().split())) number = [i for i in range(10)] num_lis = list(set(number) - set(D)) ans=[] for i in num_lis: for j in num_lis: for k in num_lis: for l in num_lis: a = 1000*i + 100 *j + 10*k + l if a>=N: ans.append(a) print(ans[0])
s801810158
p04045
u994521204
1575649276
Python
Python (3.4.3)
py
Runtime Error
19
3064
366
N, K = list(map(int, input().split())) D = list(map(int, input().split())) number = [i for i in range(10)] num_lis = list(set(number) - set(D)) ans=[] for i in num_lis: for j in num_lis: for k in num_lis: for l in num_lis: a = 1000*i + 100 *j + 10*k + l if a>=N: ans.append(a) print(ans[0])
s619608203
p04045
u815444398
1575156182
Python
Python (3.4.3)
py
Runtime Error
17
3064
322
p,c=map(int,input().split()) dlike = list(map(int,input().split())) like = [0,1,2,3,4,5,6,7,8,9] num = list(str(p)) result = list() for i in dlike: like.remove(i) for j in range(len(num)): for k in like: if int(num[j]) <= k: result.append(str(k)) break print(int(''.join(result)))
s379656793
p04045
u754022296
1574380490
Python
Python (3.4.3)
py
Runtime Error
17
3064
300
import bisect n, k = input().split() A = sorted(list({i for i in range(10)} - set(map(int, input().split())))) greater = False ans = "" for i in n: if greater: ans += str(A[0]) else: t = A[bisect.bisect_left(A, int(i))] if t > int(i): greater = True ans += str(t) print(ans)
s457945947
p04045
u673361376
1574117371
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38256
627
import bisect N,K = map(int,input().split()) N = [int(n) for n in str(N)] D = set(map(int,input().split())) nums = [] for i in range(10): if i not in D:nums.append(i) if len(nums) == 0: print(''.join([str(n) for n in N])) exit() nums.sort() i = len(N)-1 while i>=0: if N[i] not in nums: if nums[-1] < N[i]: prv_len = len(N) tmp_N = [int(s) for s in str(int(''.join([str(n) for n in N[:i]])) + 1)] N = tmp_N + [nums[0]] if len(N) > prv_len: i += 1 else: j = bisect.bisect(nums,N[i]) j = j if j != -1 else 0 N[i] = nums[j] i -= 1 print(''.join([str(n) for n in N]))
s605658750
p04045
u673361376
1574117332
Python
PyPy3 (2.4.0)
py
Runtime Error
173
38256
600
import bisect N,K = map(int,input().split()) N = [int(n) for n in str(N)] D = set(map(int,input().split())) nums = [] for i in range(10): if i not in D:nums.append(i) if len(nums) == 0: print(N) exit() nums.sort() i = len(N)-1 while i>=0: if N[i] not in nums: if nums[-1] < N[i]: prv_len = len(N) tmp_N = [int(s) for s in str(int(''.join([str(n) for n in N[:i]])) + 1)] N = tmp_N + [nums[0]] if len(N) > prv_len: i += 1 else: j = bisect.bisect(nums,N[i]) j = j if j != -1 else 0 N[i] = nums[j] i -= 1 print(''.join([str(n) for n in N]))
s254630947
p04045
u673361376
1574116960
Python
PyPy3 (2.4.0)
py
Runtime Error
171
38384
604
import bisect N,K = map(int,input().split()) N = [int(n) for n in str(N)] D = set(map(int,input().split())) nums = [] for i in range(10): if i not in D:nums.append(i) nums.sort() if len(nums) == 0: print(N) exit() i = len(N)-1 while i>=0: if N[i] not in nums: if nums[-1] < N[i]: prv_len = len(N) tmp_N = [int(s) for s in str(int(''.join([str(n) for n in N[:i]])) + 1)] N = tmp_N + [nums[0]] if len(N) > prv_len: i += 1 else: j = bisect.bisect_left(nums,N[i]) j = j if j != -1 else 0 N[i] = nums[j] i -= 1 print(''.join([str(n) for n in N]))
s233435695
p04045
u673361376
1574116844
Python
PyPy3 (2.4.0)
py
Runtime Error
166
38256
582
import bisect N,K = map(int,input().split()) N = [int(n) for n in str(N)] D = set(map(int,input().split())) nums = [] for i in range(10): if i not in D:nums.append(i) nums.sort() if len(nums) == 0: print(N) exit() i = len(N)-1 while i>=0: if N[i] not in nums: if nums[-1] < N[i]: prv_len = len(N) tmp_N = [int(s) for s in str(int(''.join([str(n) for n in N[:i]])) + 1)] N = tmp_N + [nums[0]] if len(N) > prv_len: i += 1 else: j = bisect.bisect_left(nums,N[i]) N[i] = nums[j] i -= 1 print(''.join([str(n) for n in N]))
s809329574
p04045
u673361376
1574116805
Python
PyPy3 (2.4.0)
py
Runtime Error
167
38256
577
import bisect N,K = map(int,input().split()) N = [int(n) for n in str(N)] D = set(map(int,input().split())) nums = [] for i in range(10): if i not in D:nums.append(i) nums.sort() if len(nums) == 0: print(N) exit() i = len(N)-1 while i>=0: if N[i] not in nums: if nums[-1] < N[i]: prv_len = len(N) tmp_N = [int(s) for s in str(int(''.join([str(n) for n in N[:i]])) + 1)] N = tmp_N + [nums[0]] if len(N) > prv_len: i += 1 else: j = bisect.bisect(nums,N[i]) N[i] = nums[j] i -= 1 print(''.join([str(n) for n in N]))
s249827767
p04045
u673361376
1574116727
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38256
537
import bisect N,K = map(int,input().split()) N = [int(n) for n in str(N)] D = set(map(int,input().split())) nums = [] for i in range(10): if i not in D:nums.append(i) nums.sort() i = len(N)-1 while i>=0: if N[i] not in nums: if nums[-1] < N[i]: prv_len = len(N) tmp_N = [int(s) for s in str(int(''.join([str(n) for n in N[:i]])) + 1)] N = tmp_N + [nums[0]] if len(N) > prv_len: i += 1 else: j = bisect.bisect(nums,N[i]) N[i] = nums[j] i -= 1 print(''.join([str(n) for n in N]))
s933154477
p04045
u135847648
1574082186
Python
Python (3.4.3)
py
Runtime Error
17
3064
574
# 1<=n<10000 n,k = map(int,input().split()) d = list(map(int,input().split())) #使える数字を判別する。 nums = list(range(10)) s = [str(num) for num in nums if not num in d] #print(s) #使える数字の組み合わせでnより大きい最小値4ケタ n = list(str(n)) ans = [0]*len(n) for i in range(len(n)): if i == 0 and n[i] == "0" : # 0以外で一番小さい数を最初に持ってくる ans[0] = s[1:][0] else: # nよりも大きいやつを ans[i] = min([s_num for s_num in s if s_num >= n[i]]) print("".join(ans))
s874194277
p04045
u097317219
1573764545
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38516
177
N,K = map(int,input().split()) D = set(map(int,input().split())) ans = N while(True): if any(i in D for i in list(map(str,ans))): ans += 1 else: print(ans) break
s816729437
p04045
u117348081
1573750899
Python
Python (3.4.3)
py
Runtime Error
19
3188
460
import bisect n,k = map(int, input().split()) d = list(map(int, input().split())) num = [ i for i in range(10)] num += d a = [ x for x in set(num) if num.count(x)<2] s = str(n) m = len(s) ans = [] for i in range(m): x = int(s[i]) index = bisect.bisect_left(a,x) if a[index]==x: ans.append(str(x)) else: ans.append(str(a[index])) for j in range(m-i-1): ans.append(str(a[0])) break print("".join(ans))
s753932893
p04045
u633450100
1573672214
Python
Python (3.4.3)
py
Runtime Error
17
3064
631
N,K = [int(i) for i in input().split()] D = [int(i) for i in input().split()] use = [0,1,2,3,4,5,6,7,8,9] Keta = [] Keta.append(N // 1000) Keta.append(N % 1000 // 100) Keta.append(N % 1000 % 100 // 10) Keta.append(N % 1000 % 100 % 10) #print("Keta is {}".format(Keta)) Keta_Min = [] for i in range(len(D)): use.remove(D[i]) #print("use is {}".format(use)) for i in range(4): A = [] for j in range(len(use)): if Keta[i] <= use[j]: A.append(use[j]) #print(i,A) Keta_Min.append(min(A)) Answer = 0 Answer = Keta_Min[0] * 1000 + Keta_Min[1] * 100 + Keta_Min[2] * 10 + Keta_Min[3] print(Answer)
s927377345
p04045
u633450100
1573672147
Python
Python (3.4.3)
py
Runtime Error
17
3064
630
N,K = [int(i) for i in input().split()] D = [int(i) for i in input().split()] use = [0,1,2,3,4,5,6,7,8,9] Keta = [] Keta.append(N // 1000) Keta.append(N % 1000 // 100) Keta.append(N % 1000 % 100 // 10) Keta.append(N % 1000 % 100 % 10) #print("Keta is {}".format(Keta)) Keta_Min = [] for i in range(len(D)): use.remove(D[i]) #print("use is {}".format(use)) for i in range(4): A = [] for j in range(len(use)): if Keta[i] <= use[j]: A.append(use[j]) print(i,A) Keta_Min.append(min(A)) Answer = 0 Answer = Keta_Min[0] * 1000 + Keta_Min[1] * 100 + Keta_Min[2] * 10 + Keta_Min[3] print(Answer)
s598864850
p04045
u633450100
1573671007
Python
Python (3.4.3)
py
Runtime Error
17
3064
613
N,K = [int(i) for i in input().split()] D = [int(i) for i in input().split()] use = [0,1,2,3,4,5,6,7,8,9] Keta = [] Keta.append(N // 1000) Keta.append(N % 1000 // 100) Keta.append(N % 1000 % 100 // 10) Keta.append(N % 1000 % 100 % 10) print("Keta is {}".format(Keta)) Keta_Min = [] for i in range(len(D)): use.remove(D[i]) print("use is {}".format(use)) for i in range(4): A = [] for j in range(len(use)): if Keta[i] <= use[j]: A.append(use[j]) Keta_Min.append(min(A)) Answer = 0 Answer = Keta_Min[0] * 1000 + Keta_Min[1] * 100 + Keta_Min[2] * 10 + Keta_Min[3] print(Answer)
s524842697
p04045
u539517139
1573666828
Python
PyPy3 (2.4.0)
py
Runtime Error
176
39792
222
n,k=map(int,input().split()) d=list(input().split()) x=list(range(1,10000)[::-1]) for i in d: a=[] for j in x: if i not in str(j): a.append(j) x=a import bisect as bi x=x[::-1] print(x[bi.bisect_left(x,n)])
s251612335
p04045
u539517139
1573666629
Python
PyPy3 (2.4.0)
py
Runtime Error
182
39664
212
n,k=map(int,input().split()) d=list(input().split()) x=list(range(1,10000)[::-1]) for i in d: a=[] for j in x: if i not in str(j): a.append(j) x=a import bisect as bi print(x[bi.bisect_left(x,n)])
s172290293
p04045
u539517139
1573666057
Python
PyPy3 (2.4.0)
py
Runtime Error
160
38256
189
n,k=map(int,input().split()) d=list(input().split()) x=range(1,10000)[::-1] for i in d: for j in x: if i in str(j): x.remove(j) import bisect as bi print(x[bi.bisect_left(x,n)])
s291584089
p04045
u633450100
1573662691
Python
Python (3.4.3)
py
Runtime Error
19
3064
616
N,K = [int(i) for i in input().split()] D = [int(i) for i in input().split()] use = [0,1,2,3,4,5,6,7,8,9] Keta = [] Keta.append(N // 1000) Keta.append(N % 1000 // 100) Keta.append(N % 1000 % 100 // 10) Keta.append(N % 1000 % 100 % 10) Keta_Min = [] for i in range(len(D)): use.remove(D[i]) for i in range(4): A = [] for j in range(len(use)): if Keta[i] == 0: Keta_Min.append(0) elif Keta[i] <= use[j]: A.append(use[j]) Keta_Min.append(min(A)) Answer = 0 Answer = Keta_Min[0] * 1000 + Keta_Min[1] * 100 + Keta_Min[2] * 10 + Keta_Min[3] print(Answer)
s816127564
p04045
u633450100
1573662650
Python
Python (3.4.3)
py
Runtime Error
18
3064
679
N,K = [int(i) for i in input().split()] D = [int(i) for i in input().split()] use = [0,1,2,3,4,5,6,7,8,9] Keta = [] Keta.append(N // 1000) Keta.append(N % 1000 // 100) Keta.append(N % 1000 % 100 // 10) Keta.append(N % 1000 % 100 % 10) print("Keta is {}".format(Keta)) Keta_Min = [] for i in range(len(D)): use.remove(D[i]) print("use is {}".format(use)) for i in range(4): A = [] for j in range(len(use)): if Keta[i] == 0: Keta_Min.append(0) elif Keta[i] <= use[j]: A.append(use[j]) Keta_Min.append(min(A)) Answer = 0 Answer = Keta_Min[0] * 1000 + Keta_Min[1] * 100 + Keta_Min[2] * 10 + Keta_Min[3] print(Answer)
s680996921
p04045
u633450100
1573662310
Python
Python (3.4.3)
py
Runtime Error
17
3064
557
N,K = [int(i) for i in input().split()] D = [int(i) for i in input().split()] use = [0,1,2,3,4,5,6,7,8,9] Keta = [] Keta.append(N // 1000) Keta.append(N % 1000 // 100) Keta.append(N % 1000 % 100 // 10) Keta.append(N % 1000 % 100 % 10) Keta_Min = [] for i in range(len(D)): use.remove(D[i]) for i in range(4): A = [] for j in range(len(use)): if Keta[i] <= use[j]: A.append(use[j]) Keta_Min.append(min(A)) Answer = 0 Answer = Keta_Min[0] * 1000 + Keta_Min[1] * 100 + Keta_Min[2] * 10 + Keta_Min[3] print(Answer)
s292806981
p04045
u600402037
1573661613
Python
Python (3.4.3)
py
Runtime Error
17
3064
338
N, K = map(int, input().split()) D = set(map(int, input().split())) safe = set(range(10)) - D def test(N): return set((int(x) for x in str(N))) <= safe def F(N): while N % 10: if text(N): return N N += 1 N //= 10 x = F(N) y = min(safe) return 10 * x + y answer = F(N) print(answer)
s865934309
p04045
u779728630
1573448950
Python
Python (3.4.3)
py
Runtime Error
17
3064
275
N, K = map(int, input().split()) Dlist = [1,1,1,1,1,1,1,1,1,1] for i in range(K): D = int(input()) Dlist[D]=0 while True: f = True Nx = str(N) for i in range(len(Nx)): if Dlist[int(Nx[i])] == 0: f = False if f: print(N) break else: N += 1
s127801369
p04045
u021759654
1573264635
Python
Python (3.4.3)
py
Runtime Error
17
3060
186
total, k = map(int, input().split()) ds = list(input().split()) for i in range(total,total*10+2): for d in ds: if d in list(str(ans)): break else: print(i) exit(0)
s346482277
p04045
u215018528
1573024962
Python
Python (3.4.3)
py
Runtime Error
17
3064
499
N, K = map(int, input().split()) D = list(map(int, input().split())) D = list(set(D)) nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] for d in D: nums.remove(d) l = [int(x) for x in str(N)] ans = [] for i, e in enumerate(l): if e in D: for num in nums: if e < num: ans.append(str(num)) else: for _ in range(i + 1, len(l)): ans.append(str(min(nums))) break else: ans.append(str(e)) print(int(''.join(ans)))
s804896250
p04045
u503294750
1572818733
Python
Python (3.4.3)
py
Runtime Error
18
2940
236
line=input().split() N=int(line[0]) K=int(line[1]) D=input().rstrip().split() for i in range(N,10*N+1): s=str(i) flag=True for x in D: if x in s: flag=False break if flag: print(s) break else: continue
s610358459
p04045
u134520518
1572307441
Python
Python (3.4.3)
py
Runtime Error
17
3060
410
n,k = input().split() d = list(input().split()) ans = '' for i in range(10): if not str(i) in d: sm = str(i) break for i in range(len(str(n))): if n[i] in d: co = str(int(n[i])+1) while(1): if not co in d: break co = co + 1 ans = ans + co + sm*(len(n)-i-1) break else: ans = ans + n[i] print(ans)
s098698889
p04045
u171115409
1572128926
Python
Python (3.4.3)
py
Runtime Error
17
3064
598
# -*- coding: utf-8 -*- # 入力 N, K = input().split() K = int(K) D = list(map(int, input().split())) dd = [False]*10 for i in D: dd[i] = True def find_min(lis, index): for i in range(index+1, len(lis)): if(lis[i] == False): return i def make_num(num, order): ans = 0 for i in range(order): ans += num*10**(order-1) return ans n = len(N) res = 0 for i in range(n): if(dd[int(N[i])] == True): res += find_min(dd, int(N[i])) * 10**(n-1-i) if(i<n-2): res += make_num(find_min(dd, -1), n-2) break; else: res += int(N[i])*10**(n-1-i) print(res)
s702207893
p04045
u368882459
1572035252
Python
Python (3.4.3)
py
Runtime Error
18
3060
246
n, k = map(int, input().split()) d = sorted(list({0, 1, 2, 3, 4, 5, 6, 7, 8, 9} - set(map(int, input().split())))) n = str(n) ans = '' for i in n: for j in d: if j >= int(i): ans += str(j) break print(int(ans))
s530256826
p04045
u368882459
1572035104
Python
Python (3.4.3)
py
Runtime Error
17
3060
246
n, k = map(int, input().split()) d = sorted(list({0, 1, 2, 3, 4, 5, 6, 7, 8, 9} - set(map(int, input().split())))) n = str(n) ans = '' for i in n: for j in d: if j >= int(i): ans += str(j) break print(int(ans))
s223927117
p04045
u318042557
1571966005
Python
PyPy3 (2.4.0)
py
Runtime Error
194
40176
363
N, K = map(int, input().split()) d = list(map(int, input().split())) a = [] for i in range(10): if d.count(i) == 0: a.append(i) ans = [] def dfs(s): if int(s) >= N or len(s) > len(str(N)): return s for i in a: S = dfs(s + str(i)) if int(S) >= N: ans.append(int(S)) return s dfs('0') print(min(ans))
s900658124
p04045
u079427319
1571809564
Python
Python (3.4.3)
py
Runtime Error
17
3064
815
val, size = map(int, input().split()) disabledList = [int(x) for x in input().split()] # number enableList = list(set(range(10)) - set(disabledList)) # number resultList = [] # str, must reverse isTenOver = False for char in list(str(val)).reverse(): targetInt = int(char) if isTenOver: targetInt += 1 if int(char) in enableList: isTenOver = False resultList.append(char) continue resultList = [min(enableList)] * len(resultList) if int(char) > max(enableList): isTenOver = True resultList.append(str(min(enableList))) else: isTenOver = False minNum = min(filter(lambda x:x > int(char), enableList)) resultList.append(str(minNum)) if isTenOver: minNum = min(filter(lambda x:x > 0, enableList)) resultList.append(str(minNum)) print(''.join(resultList.reverse()))
s140783643
p04045
u079427319
1571809012
Python
Python (3.4.3)
py
Runtime Error
18
3064
752
val, size = map(int, input().split()) disabledList = [int(x) for x in input().split()] # number enableList = list(set(range(10)) - set(disabledList)) # number resultList = [] # int, must reverse isTenOver = False for char in list(str(val)).reverse(): targetInt = int(char) if isTenOver: targetInt += 1 if int(char) in enableList: isTenOver = False resultList.append(char) elif int(char) > max(enableList): isTenOver = True resultList.append(str(min(enableList))) else: isTenOver = False minNum = min(filter(lambda x:x > int(char), enableList)) resultList.append(str(minNum)) if isTenOver: minNum = min(filter(lambda x:x > 0, enableList)) resultList.append(str(minNum)) print(''.join(resultList.reverse()))
s251705391
p04045
u099300051
1571754640
Python
Python (3.4.3)
py
Runtime Error
2104
3060
325
N,K = map(int,input().split()) D = input().split() i = 0 money = N-1 while money < N: i = i+1 ans = [] ans += str(money+i) for j in range(len(ans)): for k in range(len(D)): if D[k] == ans[j]: flag = True break if flag: break if not(flag): money = money + i print(money)
s356966413
p04045
u673981655
1571682838
Python
Python (3.4.3)
py
Runtime Error
18
3064
196
n = list(map(int, input().split())) N = n[0] K = n[1] d = list(map(int, input().split())) num = [i for i in range(1,10)] dd = [] for i in d: num.remove(i) total = 1000*min(num) print(total)
s952135563
p04045
u673981655
1571682747
Python
Python (3.4.3)
py
Runtime Error
17
3060
204
n = list(map(int, input().split())) N = n[0] K = n[1] d = list(map(int, input().split())) num = [i for i in range(1,10)] dd = [] for i in d: num.remove(i) a = 0 for i in num: a += i*1000 print(a)
s043092790
p04045
u386819480
1570417127
Python
Python (3.4.3)
py
Runtime Error
19
3064
899
#!/usr/bin/env python3 import sys def solve(N: int, K: int, D: "List[int]"): ln = list(map(int, list(str(N)))) c = 0 for i in range(len(ln)-1,-1,-1): ln[i] += c while(ln[i] in D): ln[i] += 1 c = ln[i] // 10 ln[i] %= 10 if(c > 0): l = [c] + l print(''.join(map(str, ln))) return # Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int K = int(next(tokens)) # type: int D = [int(next(tokens)) for _ in range(K)] # type: "List[int]" solve(N, K, D) if __name__ == '__main__': main()
s325266063
p04045
u386819480
1570417041
Python
Python (3.4.3)
py
Runtime Error
18
3064
899
#!/usr/bin/env python3 import sys def solve(N: int, K: int, D: "List[int]"): ln = list(map(int, list(str(N)))) c = 0 for i in range(len(ln)-1,-1,-1): ln[i] += c while(ln[i] in D): ln[i] += 1 c = ln[i] // 10 ln[i] %= 10 if(c > 0): ln.appendleft(c) print(''.join(map(str, ln))) return # Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int K = int(next(tokens)) # type: int D = [int(next(tokens)) for _ in range(K)] # type: "List[int]" solve(N, K, D) if __name__ == '__main__': main()
s825315214
p04045
u386819480
1570416980
Python
Python (3.4.3)
py
Runtime Error
18
3064
881
#!/usr/bin/env python3 import sys def solve(N: int, K: int, D: "List[int]"): ln = list(map(int, list(str(N)))) c = 0 for i in range(len(ln)-1,-1,-1): while(ln[i] in D): ln[i] += 1 c = ln[i] // 10 ln[i] %= 10 if(c > 0): ln.appendleft(c) print(''.join(map(str, ln))) return # Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() N = int(next(tokens)) # type: int K = int(next(tokens)) # type: int D = [int(next(tokens)) for _ in range(K)] # type: "List[int]" solve(N, K, D) if __name__ == '__main__': main()
s154248639
p04045
u403986473
1570233474
Python
Python (3.4.3)
py
Runtime Error
17
3064
746
# 入力 N, K = map(int, input().split()) Ds = input().split() D_list = [int(n) for n in Ds] # 嫌いな数字D n_list = [int(n) for n in str(N)] # 1つずつのNの値 number = list(range(10)) # 0-9までの数字 likes = list(set(D_list) ^ set(number)) # 好きな数字 for i in range(len(n_list)): if n_list[i] in D_list: # 嫌いな時 try: # 嫌いな値より大きな値が存在する時(0とか) big = min(list(filter(lambda x:x>=n_list[i], likes))) n_list[i] = big except ValueError: # 嫌いな値より大きな値が存在しない時(9とか) n_list[i] = min(likes) if n_list[i+1] != 9: n_list[i+1] = n_list[i+1] + 1 print(n_list[i], end='')
s771453819
p04045
u920543723
1569440030
Python
Python (3.4.3)
py
Runtime Error
17
2940
547
import numpy as np n = list(map(int, input().split())) d = np.array(list(map(int, input().split()))) a = len(str(n[0])) x = np.zeros(a + 1) for i in range(a + 1): x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i) i = 0 while i += a: i += 1 if np.any(d == x[0]) and x[0] != 0: i = 0 while np.any(d == x[i]): x[i] += 1 x[i + (i != a):] = 0 if x[i] == 10: x[i - 1] += 1 x[i:] = 0 ans = 0 for i in range(a + 1): ans += x[i] * np.power(10, a - i) print(int(ans))
s691811551
p04045
u920543723
1569439925
Python
Python (3.4.3)
py
Runtime Error
2108
12396
551
import numpy as np n = list(map(int, input().split())) d = np.array(list(map(int, input().split()))) a = len(str(n[0])) x = np.zeros(a + 1) for i in range(a + 1): x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i) i = 0 while i != a + 1: i += 1 while np.any(d == x[i]): x[i] += 1 x[i + (i != a):] = 0 if x[i] == 10: x[i - 1] += 1 x[i:] = 0 if np.any(d == x[0]) and x[0] != 0: i = 0 ans = 0 for i in range(a + 1): ans += x[i] * np.power(10, a - i) print(int(ans))
s945133429
p04045
u920543723
1569439805
Python
Python (3.4.3)
py
Runtime Error
2108
14424
565
import numpy as np n = list(map(int, input().split())) d = np.array(list(map(int, input().split()))) a = len(str(n[0])) x = np.zeros(a + 1) for i in range(a + 1): x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i) i = 0 while i != a + 1: i += 1 if x[i] == 10: x[i - 1] += 1 x[i:] = 0 i = 0 while np.any(d == x[i]): x[i] += 1 x[i + (i != a):] = 0 if np.any(d == x[0]) and x[0] != 0: i = 0 ans = 0 for i in range(a + 1): ans += x[i] * np.power(10, a - i) print(int(ans))
s462441600
p04045
u920543723
1569439309
Python
Python (3.4.3)
py
Runtime Error
2108
12396
585
import numpy as np n = list(map(int, input().split())) d = np.array(list(map(int, input().split()))) a = len(str(n[0])) x = np.zeros(a + 1) for i in range(a + 1): x[i] = (n[0] % np.power(10, a - i + 1)) // np.power(10, a - i) i = 1 while 1: while np.any(d == x[i]): x[i] += 1 x[i + (i != a):] = 0 if x[i] == 10: x[i - 1] += 1 x[i:] = 0 i = 0 i += 1 if np.any(d == x[0]) and x[0] != 0: i = 0 if i == a: break ans = 0 for i in range(a + 1): ans += x[i] * np.power(10, a - i) print(int(ans))
s510324306
p04045
u752907799
1569202626
Python
Python (3.4.3)
py
Runtime Error
22
3316
269
N, K = map(int, input().split()) ok = [True]*10; d = [int(s) for s in input().split()] for i in d: ok[i] = False ans = 0 for i in range(N, 10*N+1): j = i while j > 0 and ok[j%10]: j /= 10 if j == 0: ans = i break print(ans)
s912715211
p04045
u404794295
1569125116
Python
Python (3.4.3)
py
Runtime Error
17
3064
653
inp=input().split(" ") N=int(inp[0]) K=int(inp[1]) dislike=input().split(" ") like=[] for i in range(0,10): if str(i) not in dislike: like.append(str(i)) def search_min(n,like): n=str(n) if len(n)==1: for i in like: if i>=n: return i else: if n[0] in like: if n[1]<=like[-1]: return n[0]+search_min(n[1:],like) else: j=like.index(n[0]) return like[j+1]+like[0]*(len(n)-1) else: for i in like: if i>n[0]: return i+like[0]*(len(n)-1) print(search_min(N,like))
s016280344
p04045
u404794295
1569124998
Python
Python (3.4.3)
py
Runtime Error
17
3064
651
inp=input().split(" ") N=int(inp[0]) K=int(inp[1]) dislike=input().split(" ") like=[] for i in range(0,10): if str(i) not in dislike: like.append(str(i)) def search_min(n,like): n=str(n) if len(n)==1: for i in like: if i>=n: return i else: if n[0] in like: if n[1]<=like[-1]: return n[0]+search_min(n[1:],like) else: j=like.index(n[0]) return like[j+1]+like[0]*(len(n)-1) else: for i in like: if i>n[0]: return i+like[0]*(len(n)-1) int(search_min(N,like))
s864088106
p04045
u404794295
1569124959
Python
Python (3.4.3)
py
Runtime Error
17
3064
646
inp=input().split(" ") N=int(inp[0]) K=int(inp[1]) dislike=input().split(" ") like=[] for i in range(0,10): if str(i) not in dislike: like.append(str(i)) def search_min(n,like): n=str(n) if len(n)==1: for i in like: if i>=n: return i else: if n[0] in like: if n[1]<=like[-1]: return n[0]+search_min(n[1:],like) else: j=like.index(n[0]) return like[j+1]+like[0]*(len(n)-1) else: for i in like: if i>n[0]: return i+like[0]*(len(n)-1) search_min(N,like)
s986732968
p04045
u404794295
1569027091
Python
Python (3.4.3)
py
Runtime Error
18
3064
646
inp=input().split(" ") N=int(inp[0]) K=int(inp[1]) dislike=input().split(" ") like=[] for i in range(0,10): if str(i) not in dislike: like.append(str(i)) def search_min(n,like): n=str(n) if len(n)==1: for i in like: if i>=n: return i else: if n[0] in like: if n[1]<=like[-1]: return n[0]+search_min(n[1:],like) else: j=like.index(n[0]) return like[j+1]+like[0]*(len(n)-1) else: for i in like: if i>n[0]: return i+like[0]*(len(n)-1) search_min(N,like)
s432884712
p04045
u760767494
1568593318
Python
Python (3.4.3)
py
Runtime Error
25
3956
233
l = list(range(10001)) l = list(map(str, l)) c = 0 N, K = map(int, input().split()) ld = list(map(str, input().split())) del l[:N] while True: if any(x in l[c] for x in ld): c += 1 else: break print(int(l[c]))
s241194795
p04045
u760767494
1568593277
Python
Python (3.4.3)
py
Runtime Error
25
4084
243
l = list(range(10001)) l = list(map(str, l)) print(l) c = 0 N, K = map(int, input().split()) ld = list(map(str, input().split())) del l[:N] while True: if any(x in l[c] for x in ld): c += 1 else: break print(int(l[c]))