結果

問題 No.1020 Reverse
ユーザー MaboyMaboy
提出日時 2021-06-28 23:51:47
言語 Swift
(5.10.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 275 bytes
コンパイル時間 2,436 ms
コンパイル使用メモリ 172,864 KB
実行使用メモリ 14,504 KB
最終ジャッジ日時 2023-09-08 00:06:05
合計ジャッジ時間 3,350 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
13,568 KB
testcase_01 AC 6 ms
13,288 KB
testcase_02 AC 6 ms
13,312 KB
testcase_03 AC 5 ms
13,372 KB
testcase_04 AC 5 ms
13,484 KB
testcase_05 AC 5 ms
13,408 KB
testcase_06 AC 5 ms
13,396 KB
testcase_07 AC 12 ms
14,200 KB
testcase_08 AC 8 ms
14,276 KB
testcase_09 AC 8 ms
13,580 KB
testcase_10 AC 15 ms
13,896 KB
testcase_11 AC 21 ms
14,276 KB
testcase_12 AC 8 ms
13,804 KB
testcase_13 AC 8 ms
14,352 KB
testcase_14 AC 23 ms
14,140 KB
testcase_15 AC 33 ms
14,392 KB
testcase_16 AC 34 ms
14,504 KB
testcase_17 AC 6 ms
13,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import Foundation
let n = readLine()!.split(separator: " ").map{Int($0)!}
var S = String(readLine()!)
let (N,K) = (n[0],n[1])
let s = S.index(S.startIndex, offsetBy: K-1)
var T = String(S[..<s])
let U = S[s...]
if (N - K) % 2 == 0{
    T = String(T.reversed())
}
print(U + T)
0