結果
問題 |
No.113 宝探し
|
ユーザー |
![]() |
提出日時 | 2015-05-02 14:02:08 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 485 bytes |
コンパイル時間 | 1,048 ms |
コンパイル使用メモリ | 158,424 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 20:53:41 |
合計ジャッジ時間 | 1,752 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int conv(char)’: main.cpp:16:1: warning: control reaches end of non-void function [-Wreturn-type] 16 | } | ^
ソースコード
#include<bits/stdc++.h> using namespace std; const int dx[]={0,1,-1,0}; const int dy[]={-1,0,0,1}; int conv(char c){ switch(c){ case 'N': return 0; case 'E': return 1; case 'W': return 2; case 'S': return 3; } } int main(){ int y=0,x=0; string str; cin>>str; for(int i=0;i<str.size();i++){ int cur=conv(str[i]); y+=dy[cur]; x+=dx[cur]; } cout<<hypot(y,x)<<endl; return 0; }