結果
問題 |
No.113 宝探し
|
ユーザー |
![]() |
提出日時 | 2015-05-25 09:43:07 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 771 bytes |
コンパイル時間 | 667 ms |
コンパイル使用メモリ | 59,732 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 20:56:23 |
合計ジャッジ時間 | 1,360 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
#include<iostream> #include<math.h> #include<string> using namespace std; int main(){ string h; cin >> h; int x = 0; int y = 0; int next = 0; double ans; while (1){ int loc = h.find("N", next); if (loc == string::npos){ break; } else{ next = loc+1; } y += 1; } next = 0; while (1){ int loc = h.find("E", next); if (loc == string::npos){ break; } else{ next = loc + 1; } x += 1; } next = 0; while (1){ int loc = h.find("W", next); if (loc == string::npos){ break; } else{ next = loc + 1; } x -= 1; } next = 0; while (1){ int loc = h.find("S", next); if (loc == string::npos){ break; } else{ next = loc + 1; } y -= 1; } ans = sqrt(x*x + y*y); cout << ans << endl; return 0; }