結果
問題 |
No.113 宝探し
|
ユーザー |
|
提出日時 | 2018-02-25 16:30:59 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 366 bytes |
コンパイル時間 | 400 ms |
コンパイル使用メモリ | 60,024 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 21:47:43 |
合計ジャッジ時間 | 1,156 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
#include <iostream> #include <string> #include <cmath> using namespace std; int main() { string S; cin >> S; int ns = 0, ew = 0; for(int i = 0; i < S.length(); ++i) { if((S[i] == 'N') || (S[i] == 'S')) { ns += ((S[i] == 'N') ? 1 : -1); } else { ew += ((S[i] == 'E') ? 1 : -1); } } cout << sqrt((ns * ns) + (ew * ew)) << endl; return 0; }