結果
問題 | No.1020 Reverse |
ユーザー | MVP CREED |
提出日時 | 2020-04-10 22:11:26 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,322 bytes |
コンパイル時間 | 298 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,588 KB |
最終ジャッジ日時 | 2024-09-15 20:36:14 |
合計ジャッジ時間 | 1,429 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
10,752 KB |
testcase_01 | AC | 30 ms
10,496 KB |
testcase_02 | AC | 29 ms
10,880 KB |
testcase_03 | WA | - |
testcase_04 | AC | 29 ms
10,752 KB |
testcase_05 | AC | 29 ms
10,752 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 30 ms
11,264 KB |
testcase_09 | AC | 31 ms
11,388 KB |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 31 ms
11,460 KB |
testcase_13 | AC | 31 ms
11,480 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 31 ms
11,392 KB |
ソースコード
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)