QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#428446#8769. Champernowne Substringucup-team135#TL 9295ms10580kbPython33.3kb2024-06-01 19:34:182024-06-01 19:34:19

Judging History

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

  • [2024-06-01 19:34:19]
  • 评测
  • 测评结果:TL
  • 用时:9295ms
  • 内存:10580kb
  • [2024-06-01 19:34:18]
  • 提交

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)):
                    for f in range(2):
                        num=0
                        if(f==1):
                            num=x*(10**k)+l
                        else:
                            num=x*(10**(k+1))-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'
                                    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)
                                        answ=check(ch,pos,ch2)
                                        if(answ<res):
                                           res=answ
                                           ch1=ch
        print(res%p)
main()

詳細信息

Test #1:

score: 100
Accepted
time: 9295ms
memory: 10580kb

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

result:

ok 9 lines

Test #2:

score: -100
Time Limit Exceeded

input:

10
0000000000000000000000000
0000000?002100000000000?0
6999?999?999999989?999999
0???0?1000?0??000?????0?1
9??9?999998?9?999999100?0
96?9997999?8999991????010
99?99??999999999??????99?
?0?0000?00000000?0210?0?0
99?999?999?99?9??999?9?9?
9?????9?99?99??9??99??9??

output:

545305036
574985081
788888865
5889591
279576466
488873
902933968

result: