結果

問題 No.113 宝探し
ユーザー Mizuno
提出日時 2024-10-07 21:37:34
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 458 bytes
コンパイル時間 625 ms
コンパイル使用メモリ 69,188 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-07 21:37:38
合計ジャッジ時間 1,687 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    int n = 0,e = 0,w = 0,ss = 0;
    int len = s.length();
    for(int i = 0; i < len; i++) {
        if(s[i] == 'N') n++;
        else if(s[i] == 'E') e++;
        else if(s[i] == 'W') w++;
        else if(s[i] == 'S') ss++;
    }
    double ans = sqrt(abs(w - e) * abs(w - e) + abs(n - ss) * abs(n - ss));
    cout << ans;
    
}
0