結果

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

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
using namespace std;

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

	int pos[2] = {};
	for (auto i = s.begin(); i != s.end(); i++)
	{
		switch (*i)
		{
		case 'N':
			pos[0] += 1;
			break;
		case 'E':
			pos[1] += 1;
			break;
		case 'S':
			pos[0] -= 1;
			break;
		case 'W':
			pos[1] -= 1;
		default:
			break;
		}
	}
	cout << hypot(pos[0], pos[1]) << endl;

	return 0;
}
0