結果

問題 No.729 文字swap
ユーザー YukicoderAYukicoderA
提出日時 2018-11-17 18:23:45
言語 Swift
(5.10.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 3,730 ms
コンパイル使用メモリ 163,920 KB
実行使用メモリ 13,976 KB
最終ジャッジ日時 2023-08-20 11:31:22
合計ジャッジ時間 5,019 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
13,644 KB
testcase_01 AC 6 ms
13,352 KB
testcase_02 AC 6 ms
13,568 KB
testcase_03 AC 6 ms
13,516 KB
testcase_04 AC 6 ms
13,592 KB
testcase_05 AC 6 ms
13,932 KB
testcase_06 AC 6 ms
13,976 KB
testcase_07 AC 6 ms
13,844 KB
testcase_08 AC 6 ms
13,636 KB
testcase_09 AC 6 ms
13,348 KB
testcase_10 AC 6 ms
13,928 KB
testcase_11 AC 6 ms
13,552 KB
testcase_12 AC 6 ms
13,648 KB
testcase_13 AC 6 ms
13,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import Foundation
        var text = readLine()!
        let indexs = readLine()!.components(separatedBy: " ")
        
        let index1 = Int(indexs[0])!
        let index2 = Int(indexs[1])!
        let idx1 = text.index(text.startIndex, offsetBy: index1)
        let idx2 = text.index(text.startIndex, offsetBy: index2)
        let w1 = text[idx1]
        let w2 = text[idx2]
        text.replaceSubrange(idx1..<text.index(idx1, offsetBy: 1), with: String(w2))
        text.replaceSubrange(idx2..<text.index(idx2, offsetBy: 1), with: String(w1))
        print(text)
0