結果

問題 No.18 うーさー暗号
ユーザー バカらっくバカらっく
提出日時 2018-03-02 11:47:23
言語 Swift
(5.10.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 380 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 110,676 KB
実行使用メモリ 7,984 KB
最終ジャッジ日時 2023-08-20 10:23:24
合計ジャッジ時間 1,637 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,920 KB
testcase_01 AC 3 ms
7,740 KB
testcase_02 AC 3 ms
7,708 KB
testcase_03 AC 3 ms
7,768 KB
testcase_04 AC 3 ms
7,748 KB
testcase_05 AC 4 ms
7,816 KB
testcase_06 AC 4 ms
7,836 KB
testcase_07 AC 3 ms
7,984 KB
testcase_08 AC 4 ms
7,756 KB
testcase_09 AC 3 ms
7,752 KB
testcase_10 AC 3 ms
7,740 KB
testcase_11 AC 3 ms
7,748 KB
testcase_12 AC 3 ms
7,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let charTable = "abcdefghijklmnopqrstuvwxyz".uppercased().map{$0}

var caseDic = [Character:Int]()

for i in 0..<charTable.count {
    caseDic[charTable[i]] = i
}

let inpt = readLine()!.map{$0}

var ans = ""

for i in 0..<inpt.count {
    var idx = caseDic[inpt[i]]! - (i+1)
    while idx < 0 {
        idx += charTable.count
    }
    ans += String(charTable[idx])
}

print(ans)
0