結果

問題 No.113 宝探し
ユーザー kazu116kazu116
提出日時 2019-05-10 16:28:38
言語 Swift
(5.10.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 524 bytes
コンパイル時間 1,942 ms
コンパイル使用メモリ 153,048 KB
実行使用メモリ 13,200 KB
最終ジャッジ日時 2023-08-20 12:23:55
合計ジャッジ時間 3,526 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
12,816 KB
testcase_01 AC 6 ms
12,780 KB
testcase_02 AC 5 ms
12,968 KB
testcase_03 AC 6 ms
13,200 KB
testcase_04 AC 5 ms
12,784 KB
testcase_05 AC 5 ms
13,132 KB
testcase_06 AC 6 ms
12,904 KB
testcase_07 AC 6 ms
12,700 KB
testcase_08 AC 6 ms
12,748 KB
testcase_09 AC 5 ms
12,572 KB
testcase_10 AC 5 ms
12,604 KB
testcase_11 AC 6 ms
13,068 KB
testcase_12 AC 5 ms
12,920 KB
testcase_13 AC 5 ms
12,792 KB
testcase_14 AC 5 ms
12,764 KB
testcase_15 AC 6 ms
12,804 KB
testcase_16 AC 6 ms
12,972 KB
testcase_17 AC 6 ms
12,824 KB
testcase_18 AC 5 ms
12,696 KB
testcase_19 AC 6 ms
12,988 KB
testcase_20 AC 6 ms
12,916 KB
testcase_21 AC 6 ms
12,836 KB
testcase_22 AC 6 ms
13,024 KB
testcase_23 AC 5 ms
12,764 KB
testcase_24 AC 6 ms
12,932 KB
testcase_25 AC 5 ms
12,848 KB
testcase_26 AC 6 ms
12,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import Foundation

let location:[String] = readLine()!.map{String($0)}
var horizontal:Int = 0
var vertical:Int = 0
for i in 0..<location.count {
    let direction:String = location[i]
    switch direction {
    case "N":
        vertical += 1
    case "E":
        horizontal += 1
    case "W":
        horizontal -= 1
    case "S":
        vertical -= 1
    default:
        horizontal += 0
        vertical += 0
    }
}
let distance:Double = sqrt(pow(Double(horizontal), 2.0) + pow(Double(vertical), 2.0));
print(distance)
0