結果

問題 No.1491 銀将
ユーザー mmn15277198mmn15277198
提出日時 2021-05-02 23:52:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 657 bytes
コンパイル時間 1,649 ms
コンパイル使用メモリ 171,220 KB
実行使用メモリ 472,140 KB
最終ジャッジ日時 2023-09-28 14:22:21
合計ジャッジ時間 4,795 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 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 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int k;
map<pair<int,int> , int> mp;
const int dx[5] = {1 , 1 , -1 , -1 , 0};
const int dy[5] = {1 , -1 , 1 , -1 , 1};

void dfs(int x , int y , int depth) {
  if (depth >= k) return;
  auto p = make_pair(x , y);
  mp[p]++;
  for (int i = 0; i < 5; i++) {
    int new_x = x + dx[i];
    int new_y = y + dy[i];
    p = make_pair(new_x , new_y);
    if (mp[p] != 0) continue;
    dfs(new_x , new_y , depth + 1);
  }
  return;
}

int main () {
  cin >> k;
  dfs(0 , 0 , 0);
  /*
  for (auto i : mp) {
    cout << i.first.first << " " << i.first.second << endl;
  }
  */
  cout << mp.size() << endl;
  return 0;
}
0