結果

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>

int main() {
	std::string direction;
	std::cin >> direction;

	int n = std::count(direction.begin(), direction.end(), 'N');
	int e = std::count(direction.begin(), direction.end(), 'E');
	int w = std::count(direction.begin(), direction.end(), 'W');
	int s = std::count(direction.begin(), direction.end(), 'S');

	int y = abs(n - s);
	int x = abs(e - w);

	double distance = sqrt(pow(x, 2) + pow(y, 2));
	std::cout << distance << std::endl;
	
	return 0;
}
0