結果

問題 No.113 宝探し
ユーザー michonz4
提出日時 2019-05-24 21:11:36
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 305 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 60,604 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-16 22:05:44
合計ジャッジ時間 1,390 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>

using namespace std;

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

  int x=0, y=0;
  for (auto &c:s) {
    if (c=='N') y++;
    else if (c=='S') y--;
    else if (c=='E') x++;
    else if (c=='W') x--;
  }

  cout << sqrt(pow(abs(x), 2)+pow(abs(y), 2)) << endl;
  return 0;
}
0