結果

問題 No.1806 Rotating Golem
ユーザー #leucobird#leucobird
提出日時 2022-02-19 09:29:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 302 bytes
コンパイル時間 1,417 ms
コンパイル使用メモリ 164,096 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 20:30:27
合計ジャッジ時間 2,514 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:14:19: 警告: ‘n_b’ may be used uninitialized [-Wmaybe-uninitialized]
   14 |   cout << abs(n_a - n_b) << endl;
      |               ~~~~^~~~~
main.cpp:9:12: 備考: ‘n_b’ はここで定義されています
    9 |   int n_a, n_b;
      |            ^~~
main.cpp:14:19: 警告: ‘n_a’ may be used uninitialized [-Wmaybe-uninitialized]
   14 |   cout << abs(n_a - n_b) << endl;
      |               ~~~~^~~~~
main.cpp:9:7: 備考: ‘n_a’ はここで定義されています
    9 |   int n_a, n_b;
      |       ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(void) {
  char a, b;
  cin >> a >> b;

  string str_dir = "NESW";
  int n_a, n_b;
  for (int i = 0; i < str_dir.size(); i++) {
    if (a == str_dir[i]) n_a = i;
    if (b == str_dir[i]) n_b = i;
  }
  cout << abs(n_a - n_b) << endl;
  return 0;
}
0