結果

問題 No.113 宝探し
ユーザー #leucobird#leucobird
提出日時 2021-03-25 22:46:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 378 bytes
コンパイル時間 1,410 ms
コンパイル使用メモリ 167,676 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-27 08:19:10
合計ジャッジ時間 2,342 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main(void)
{
  string s;
  cin >> s;

  int x = 0, y = 0;
  rep(i, s.size())
  {
    if (s[i] == 'N') y++;
    else if (s[i] == 'E') x++;
    else if (s[i] == 'S') y--;
    else if (s[i] == 'W') x--;
  }
  double ans = sqrt(x * x + y * y);

  printf("%.5f\n", ans);
  return 0;
}
0