結果
問題 |
No.113 宝探し
|
ユーザー |
![]() |
提出日時 | 2016-08-15 13:48:37 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 527 bytes |
コンパイル時間 | 641 ms |
コンパイル使用メモリ | 60,536 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 21:20:18 |
合計ジャッジ時間 | 1,407 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
#include <iostream> #include <cmath> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; int main(void){ string s; cin >> s; int x = 0, y = 0; rep(i, s.size()){ if(s[i] == 'N'){ x += dx[0]; y += dy[0]; }else if(s[i] == 'E'){ x += dx[1]; y += dy[1]; }else if(s[i] == 'S'){ x += dx[2]; y += dy[2]; }else{ x += dx[3]; y += dy[3]; } } double ans = sqrt((pow((double)x - 0.0, 2.0) + pow((double)y, 2.0))); cout << ans << endl; return 0; }