QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#429063 | #8769. Champernowne Substring | ucup-team191# | TL | 0ms | 0kb | Python3 | 2.6kb | 2024-06-02 00:27:00 | 2024-06-02 00:27:00 |
answer
t=int(input())
pocs=''
for i in range(1,1000):
pocs+=str(i)
def getPos(x):
an=0
for i in range(1,len(x)):
an+=9*(10**(i-1))*i
return an+len(x)*(int(x)-10**(len(x)-1))
def matc(x,y):
assert(len(x)==len(y))
for i in range(len(x)):
if x[i]!=y[i] and y[i]!='?':
return False
return True
for _ in range(t):
s=input()
fo=False
for i in range(0,len(pocs)-len(s)+1):
if matc(pocs[i:i+len(s)],s):
print(i+1)
fo=True
break
if fo:
continue
an=10**27
for i in range(1,26):
su=''
for j in range(10):
su+='9'*i+str(j)
for j in range(10):
su+='1'+'0'*i+str(j)
gp=getPos('9'*i+'0')+1
for j in range(0,len(su)-len(s)+1):
if matc(su[j:j+len(s)],s):
an=min(an,gp+j)
for lA in range(0,25):
for x in range(9):
sx=str(x)
for y in range(0,25-lA):
su=''
for j in range(10):
su+='U'*lA+str(x)+'9'*y+str(j)
for j in range(10):
su+='U'*lA+str(x+1)+'0'*y+str(j)
le=2+y+lA
for j in range(0,len(su)-len(s)+1):
mo=[-1 for wa in range(lA)]
mog=True
for k in range(0,len(s)):
if su[j+k]=='U':
if s[k]!='?':
uu=int(s[k])
ind=(j+k)%le
if ind==0 and uu==0:
mog=False
break
if mo[ind]==-1:
mo[ind]=uu
elif mo[ind]!=uu:
mog=False
break
elif s[k]!='?':
if s[k]!=su[j+k]:
mog=False
break
if not mog:
continue
nu=''
for k in range(lA):
if mo[k]==-1:
if k==0:
nu+='1'
else:
nu+='0'
else:
nu+=str(mo[k])
nu+=str(x)+'9'*y+'0'
an=min(an,getPos(nu)+j+1)
print(an%998244353)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
9 0 ???1 121 1?1?1 ??5?54?50?5?505?65?5 000000000000 ?2222222 ?3????????9??8???????1??0 9?9??0????????????2
output:
11 7 14 10 314159 796889014 7777 8058869 38886