結果

問題 No.113 宝探し
コンテスト
ユーザー Grun1396
提出日時 2017-02-28 21:05:34
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
+ 319µs
コード長 741 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 328 ms
コンパイル使用メモリ 90,568 KB
実行使用メモリ 9,864 KB
最終ジャッジ日時 2026-09-25 01:10:58
合計ジャッジ時間 2,052 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){
    string str;
    cin >> str;
    int y = 0;
    int x = 0;
    double ans;
    for(int d = 0; d < str.length(); d++){
        switch(str[d]){
            case 'N':
                 y++;
                 break;
            case 'W':
                 x--;
                 break;
            case 'E':
                 x++;
                 break;
            case 'S':
                 y--;
                 break;
        }
    }
 //   cout << "x:" << x << " y:" << y << "x^2+y^2:" << x*x+y*y << endl;
    ans = sqrt(x*x+y*y);
//    cout <<"test:" << 1000*sqrt(x*x+y*y) << endl;
    cout << fixed << ans << endl;

    return 0;
}
0