結果

問題 No.331 CodeRunnerでやれ
ユーザー yuppe19 😺yuppe19 😺
提出日時 2019-03-26 20:14:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 955 bytes
コンパイル時間 909 ms
コンパイル使用メモリ 78,724 KB
実行使用メモリ 24,084 KB
平均クエリ数 1.35
最終ジャッジ日時 2023-09-23 16:51:32
合計ジャッジ時間 9,107 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 154 ms
24,084 KB
testcase_01 AC 155 ms
8,004 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <array>
#include <iostream>
#include <vector>
using namespace std;

constexpr int N = 50;
                            // N  E  S   W
constexpr array<int, 4> dr = {-1, 0, 1,  0},
                        dc = { 0, 1, 0, -1};
vector<vector<vector<bool>>> seen;

void rec(int r, int c, int d, bool save) {
  if(save) { seen[r][c][d] = true; }
  string s; cin >> s;
  if(s[0] == 'M') { exit(0); }
  int dist = stoi(s);
  if(dist == 20151224) {
    cout << 'F' << endl;
    rec(r+dr[d], c+dc[d], d, true);
    return;
  }
  if(dist) {
    if(seen[r+dr[d]][c+dc[d]][d]) {
      int nd = (d + 1) % 4;
      cout << 'R' << endl;
      rec(r, c, nd, false);
    } else {
      cout << 'F' << endl;
      rec(r+dr[d], c+dc[d], d, true);
    }
    return;
  }
  int nd = (d + 1) % 4;
  cout << 'R' << endl;
  rec(r, c, nd, false);
}

int main(void) {
  seen.assign(N, vector<vector<bool>>(N, vector<bool>(4, false)));
  rec(N/2, N/2, 2, true);
  return 0;
}
0