結果

問題 No.3408 1215 Segments
コンテスト
ユーザー titia
提出日時 2025-12-15 04:34:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,145 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 461 ms
コンパイル使用メモリ 82,788 KB
実行使用メモリ 79,384 KB
最終ジャッジ日時 2025-12-15 04:34:37
合計ジャッジ時間 13,720 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20 WA * 8 TLE * 2 -- * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline

LIST=[[[0,1,2,4,5,6],[3,4,5,6]],
      [[2,5],[1,4]],
      [[0,2,3,4,6]],
      [[0,2,3,5,6]],
      [[1,2,3,5]],
      [[0,1,3,5,6]],
      [[0,1,3,4,5,6],[1,3,4,5,6]],
      [[0,2,5],[0,1,2,5]],
      [[]],
      [[0,1,2,3,5,6],[0,1,2,3,5]]
      ]

def calc(S):
    NOW=[[0]*7]
    NNOW=[]

    for i in range(len(S)):
        s=S[i]
        now2=[]

        while NOW:
            nowl=NOW.pop()    
                
            for ll in LIST[int(s)]:
                ni=nowl[:]
                for x in ll:
                    ni[x]+=1
                now2.append(ni[:])

        #print(now2)

        now2.sort()
        NOW=[]
        for x in now2:
            if NOW and NOW[-1]==x:
                continue
            if max(x)-min(x)>=5:
                continue
            NOW.append(x)

        #print(s,NOW)

        if NOW==[]:
            return len(S)-i

    for x in NOW:
        if len(set(x))==1:
            return -1
    return 0

N=int(input())
while True:
    #print(N)
    ANS=calc(str(N))

    if ANS==-1:
        print(N)
        break
    else:
        N+=10**ANS

        
0