結果

問題 No.1491 銀将
ユーザー mmn15277198mmn15277198
提出日時 2021-05-02 23:52:55
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 657 bytes
コンパイル時間 1,923 ms
コンパイル使用メモリ 174,364 KB
実行使用メモリ 547,872 KB
最終ジャッジ日時 2024-07-21 09:03:12
合計ジャッジ時間 4,266 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 MLE * 1
other -- * 16
権限があれば一括ダウンロードができます

ソースコード

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