結果

問題 No.113 宝探し
コンテスト
ユーザー akinyan
提出日時 2022-09-03 10:20:48
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
+ 427µs
コード長 872 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,406 ms
コンパイル使用メモリ 334,996 KB
実行使用メモリ 9,848 KB
最終ジャッジ日時 2026-09-25 01:29:39
合計ジャッジ時間 3,910 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ch = char;
using ll = long long;
using ld = long double;
using db = double;
using st = string;
using vdb = vector<db>;
using vvdb = vector<vdb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<ld>;
using vvd = vector<vd>;
using vs = vector<st>;
using vvs = vector<vs>;
using vc = vector<ch>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
const ll mod = 998244353;
const ll MOD = 1000000007;
using vp = vector<pair<ll,ll>>;
#define fi first
#define se second

int main(){
  cout << fixed << setprecision(20);
  st S;
  cin>>S;
  ll x=0,y=0;
  for(int i=0; i<S.size(); i++){
    if(S[i]=='N')
      y++;
    else if(S[i]=='E')
      x++;
    else if(S[i]=='W')
      x--;
    else
      y--;
  }
  cout<<sqrt(x*x+y*y)<<endl;
}
0