Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

My code shows wrong answer but works in custom invocation (Codeforces Round #823 (Div. 2))

Revision en3, by dietmilk68, 2022-09-28 17:06:35

[problem:C]

n = int(input())
for i in range(n):
    s = list(map(int, list(input())))
    for i in reversed(range(len(s))):
        if s == sorted(s):
            break
        to_shift = max(s[:i+1])
        idx_toshift = s.index(to_shift)
        temp = s[i]
        if s[i] == s[idx_toshift]:
            s[i] = min(s[idx_toshift] + 1, 9)
        else:
            s[i] = min(s[idx_toshift]+1, 9)
            s[idx_toshift] = temp


    print("".join(map(str, s)))

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English dietmilk68 2022-09-28 17:06:35 0 (published)
en2 English dietmilk68 2022-09-28 17:06:16 18 (saved to drafts)
en1 English dietmilk68 2022-09-28 17:05:34 578 Initial revision (published)