結果

問題 No.1020 Reverse
ユーザー MVP CREEDMVP CREED
提出日時 2020-04-10 22:11:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,322 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 8,992 KB
最終ジャッジ日時 2023-10-14 00:49:21
合計ジャッジ時間 1,592 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,908 KB
testcase_01 AC 16 ms
8,200 KB
testcase_02 AC 16 ms
8,276 KB
testcase_03 WA -
testcase_04 AC 16 ms
8,364 KB
testcase_05 AC 16 ms
8,404 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 17 ms
8,860 KB
testcase_09 AC 17 ms
8,700 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 17 ms
8,744 KB
testcase_13 AC 17 ms
8,976 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 18 ms
8,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def text2int(textnum, numwords={}):
    if not numwords:
      units = [
        "zero", "one", "two", "three", "four", "five", "six", "seven", "eight",
        "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
        "sixteen", "seventeen", "eighteen", "nineteen",
      ]

      tens = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]

      scales = ["hundred", "thousand", "million", "billion", "trillion"]

      numwords["and"] = (1, 0)
      for idx, word in enumerate(units):    numwords[word] = (1, idx)
      for idx, word in enumerate(tens):     numwords[word] = (1, idx * 10)
      for idx, word in enumerate(scales):   numwords[word] = (10 ** (idx * 3 or 2), 0)

    current = result = 0
    for word in textnum.split():
        if word not in numwords:
          raise Exception("Illegal word: " + word)

        scale, increment = numwords[word]
        current = current * scale + increment
        if scale > 100:
            result += current
            current = 0

    return result + current

n,k = input().split(" ")
try:
    n = text2int(n)
    k = text2int(k)
    s = input();
    s1 = s[k-1:n]
    s2 = s[0:k-1]
    print(s1+s2)

except:
    n = int(n)
    k = int(k)
    s = input();
    s1 = s[k-1:n]
    s2 = s[0:k-1]
    print(s1+s2)
0