QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#428461#8769. Champernowne Substringucup-team135#RE 0ms0kbPython33.3kb2024-06-01 19:40:002024-06-01 19:40:00

Judging History

你现在查看的是最新测评结果

  • [2024-06-01 19:40:00]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-06-01 19:40:00]
  • 提交

answer

def main():
    p=998244353
    t=int(input())
    B=25
    for i in range(t):
        ch2=10**40
        res=10**40
        s=str(input())
        while(ord(s[len(s)-1])-ord('0')>9 or ord(s[len(s)-1])-ord('0')<0):
            s=s[0:len(s)-1:1]
        def get(ch):
            val=int(ch)
            l=len(ch)
            res1=(val-10**(l-1))*l
            for i in range(l-1):
                res1+=(9*(10**i))*(i+1)
            return res1
        def check(ch,pos,ch1):
            val=int(ch)
            if(val>ch1):
                 return
            s1=str()
            while(len(s1)<pos+len(s)):
                s1+=str(val)
                val+=1
            to=s1[pos:pos+len(s):1]
            assert(len(s)==len(to))
            for i in range(len(s)):
                if(s[i]==to[i] or s[i]=='?'):
                    pass
                else:
                    return 10**40
            #print(ch,pos)
            ch1=ch
            return get(ch)+pos+1
        for k in range(B+1):
            for x in range(10):
                for l in range(27//max(k,1)):
                        num=0
                        num=x*(10**k)-l
                        if(num>=1 and len(str(num))<=k+1):
                            for a in range(B+1):
                                if(a+k+1<=B+1):
                                    ch=str()
                                    if(a>=1):
                                        ch+='1'
                                        for i in range(a-1):
                                            ch+='0'
                                    le=k+1-len(str(num))
                                    for i in range(le):
                                       ch+='0'
                                    ch+=str(num)
                                    was=False
                                    if(ch=="10003"):
                                        was=False
                                    ch1=ch
                                    assert(len(ch)==a+k+1)
                                    for pos in range(a+k+1):
                                        ch=ch1
                                        for i in range(len(s)):
                                            if(was):
                                                print(a)
                                            j=(pos+i)%(a+k+1)
                                            if(j<a):
                                                if(s[i]!='?'):
                                                    if(was):
                                                        print(i)
                                                    if(s[i]>ch[j]):
                                                        if(was and pos==4):
                                                            print(i,s[i],j)
                                                        ch=ch[0:j:1]+s[i]+ch[j+1:len(ch):1]
                                        if(was and pos==4):
                                            print(ch)
                                        if(ch[pos]==s[0]):
                                            answ=check(ch,pos,ch2)
                                        if(answ<res):
                                           res=answ
                                           ch1=ch
        print(res%p)
main()

详细

Test #1:

score: 0
Dangerous Syscalls

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:


result: