結果

問題 No.113 宝探し
ユーザー ミドリムシ
提出日時 2017-10-14 03:43:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 341 bytes
コンパイル時間 652 ms
コンパイル使用メモリ 61,264 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-17 12:48:33
合計ジャッジ時間 1,642 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 8 WA * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:15:34: warning: multi-character character constant [-Wmultichar]
   15 |                 }else if(S[i] == 'EW'){
      |                                  ^~~~

ソースコード

diff #

#include <iostream>
#include <cmath>
using namespace std;
 
int main(){
	string S;
	cin >> S;
	int NS = 0;
	int EW = 0;
	for(int i = 0; i < S.size(); i++){
		if(S[i] == 'N'){
			NS++;
		}else if(S[i] == 'S'){
			NS--;
		}else if(S[i] == 'EW'){
			EW++;
		}else{
			EW--;
		}
	}
	cout << sqrt(abs(NS) * abs(NS) + abs(EW) * abs(EW)) << endl;
}
0