結果

問題 No.113 宝探し
ユーザー sasa
提出日時 2025-03-13 17:51:51
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 373 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 36,352 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2025-03-13 17:51:54
合計ジャッジ時間 1,869 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%s",str);
      |         ~~~~~^~~~~~~~~~
main.cpp:13:29: warning: ‘tate’ may be used uninitialized [-Wmaybe-uninitialized]
   13 |                         tate--;
      |                         ~~~~^~
main.cpp:8:16: note: ‘tate’ was declared here
    8 |         double tate,yoko;
      |                ^~~~
main.cpp:17:29: warning: ‘yoko’ may be used uninitialized [-Wmaybe-uninitialized]
   17 |                         yoko--;
      |                         ~~~~^~
main.cpp:8:21: note: ‘yoko’ was declared here
    8 |         double tate,yoko;
      |                     ^~~~

ソースコード

diff #

#include <stdio.h>
#include <string.h>
#include <math.h>

int main(){
	char str[100];
	scanf("%s",str);
	double tate,yoko;
	for(int i = 0;i < (int)strlen(str);i++){
		if(str[i] == 'N'){
			tate++;
		}else if(str[i] == 'S'){
			tate--;
		}else if(str[i] == 'E'){
			yoko++;
		}else if(str[i] == 'W'){
			yoko--;
		}
	}
	printf("%.20lf\n", sqrt(yoko * yoko + tate * tate));
}
0