結果
| 問題 |
No.113 宝探し
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-08-09 06:03:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 620 bytes |
| コンパイル時間 | 605 ms |
| コンパイル使用メモリ | 79,148 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-03 07:57:59 |
| 合計ジャッジ時間 | 1,415 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
#include <iostream> //cin, cout
#include <vector> //vector
#include <algorithm> //sort,min,max
#include <string> //string
#include <ios> //fixed
#include <iomanip> //setprecision
#include <utility> //swap
#include <cstdlib> //abs(int)
#include <cmath> //sqrt
#include <sstream> //stringstream,getline
using namespace std;
int main() {
string S;
cin >> S;
int X = 0, Y = 0;
for (unsigned int i = 0; i < S.length(); i++) {
switch (S[i]) {
case 'N':Y++; break;
case 'E':X++; break;
case 'W':X--; break;
case 'S':Y--; break;
}
}
double ans = sqrt(X * X + Y * Y);
cout << ans << endl;
return 0;
}