QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#428683#8769. Champernowne Substringucup-team135#RE 0ms0kbPython34.1kb2024-06-01 20:56:562024-06-01 20:56:57

Judging History

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

  • [2024-06-01 20:56:57]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-06-01 20:56:56]
  • 提交

answer

import math
def main():
    p=998244353
    t=int(input())
    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]
        B=len(s)
        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):
            if(ch[0]=='0'):
                return 10**40
            val=int(ch)
            if(val>ch1):
                 return
            s1=str()
            while(len(s1)<pos+len(s)):
                h=str(val)
                for i in range(len(h)):
                    if(len(s1)+i>=pos and len(s1)+i<pos+len(s) and s1[i-pos]!='?' and h[i]!=s1[i-pos]):
                        return 10**40
                s1+=h
                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
            ch1=ch
            return get(ch)+pos+1
        for k in range(B+1):
            for x in range(11):
                for l in range(27//max(k,1)):
                        num=0
                        num=x*(10**k)-l
                        if(x==10 and k==0 and l==3):
                            pass
                                #print(num)
                        if(num>=1 and len(str(num))<=k+1):
                            if(x==1 and k==0 and l==3):
                                pass
                                #print(num)
                            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(a==0 and x==10 and k==0 and l==3):
                                        pass
                                        #print(ch)
                                    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)
                                        answ=10**40
                                        if(s[0]=='?' or ch[pos]==s[0]):
                                            answ=check(ch,pos,ch2)
                                        if(answ<res):
                                           res=answ
                                           ch1=ch
        print(res%p)
main()

Details

Tip: Click on the bar to expand more detailed information

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: