結果

問題 No.1020 Reverse
ユーザー nagitaosunagitaosu
提出日時 2020-04-10 21:53:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 270 bytes
コンパイル時間 410 ms
コンパイル使用メモリ 10,728 KB
実行使用メモリ 12,768 KB
最終ジャッジ日時 2023-10-14 00:24:27
合計ジャッジ時間 2,149 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,856 KB
testcase_01 AC 15 ms
8,000 KB
testcase_02 AC 16 ms
7,948 KB
testcase_03 AC 15 ms
7,772 KB
testcase_04 AC 15 ms
7,852 KB
testcase_05 AC 15 ms
7,852 KB
testcase_06 AC 15 ms
7,864 KB
testcase_07 AC 22 ms
11,108 KB
testcase_08 AC 26 ms
11,916 KB
testcase_09 AC 23 ms
11,260 KB
testcase_10 AC 28 ms
12,612 KB
testcase_11 AC 28 ms
12,664 KB
testcase_12 AC 29 ms
12,716 KB
testcase_13 AC 28 ms
12,768 KB
testcase_14 AC 28 ms
12,636 KB
testcase_15 AC 28 ms
12,384 KB
testcase_16 AC 28 ms
12,648 KB
testcase_17 AC 27 ms
12,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys
input = sys.stdin.readline

n, k = map(int, input().split())
s = list(input().rstrip())

if (n - k + 1) % 2 == 1:
    t = s[:k-1]
    t.reverse()
    s =  s[k-1:] + t
else:
    s =  s[k-1:] + s[:k-1]
print("".join([item for item in s]))
0