結果

問題 No.1500 Super Knight
ユーザー sirogamichan1sirogamichan1
提出日時 2021-04-25 14:10:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,447 bytes
コンパイル時間 1,834 ms
コンパイル使用メモリ 176,764 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-17 14:04:14
合計ジャッジ時間 5,571 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,760 KB
testcase_01 TLE -
testcase_02 -- -
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 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: ラムダ関数内:
main.cpp:30:51: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   30 |                                         for (auto [h, w] : pre)
      |                                                   ^
main.cpp:32:67: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   32 |                                                         for (auto [dh, dw] : p)
      |                                                                   ^

ソースコード

diff #

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

using ll = long long;
using P = array<ll, 2>;

vector<P> p {
		{3, 2}, {2, 3},
		{-2, 3}, {-3, 2},
		{-3, -2}, {-2, -3},
		{2, -3}, {3, -2},
		{-3, 0}, {3, 0},
		{0, 3}, {0, -3},
};

int main(int argc, char **argv)
{
	ll N; cin >> N;
	
	auto solve = [](ll N)
	{
			vector<ll> memo;
			set<P> now, pre;
			pre.insert({0, 0});
			memo.push_back(1);

			for (ll i = 0; i < N; ++i)
			{
					now = {};	
					for (auto [h, w] : pre)
					{
							for (auto [dh, dw] : p)
							{
									ll hh = h + dh;
									ll ww = w + dw;
									now.insert({hh, ww});
							}
					}

					// デバッグ用
					/*
					{
							std::cout << "########" << i+1 << "######"<< std::endl;

                            // グリッド表示
							std::cout << "grid : " << std::endl;
							const ll S = 80;
							vector<vector<bool>> dis(S, vector<bool>(S, false));
							for (auto [h, w] : now)
							{
									dis[h+S/2][w+S/2] = true;
							}

							for (ll h = 0; h < S; ++h)
							{
									for (ll w = 0; w < S; ++w)
									{
											char c = '.';
											if (dis[h][w])
													c = '#';
											std::cout << c << " ";
									}
									std::cout << std::endl;
							}

                            // マスの数
							std::cout << "cnt : " << now.size() << std::endl;
					}
					*/

					swap(now, pre);
			}

			return pre.size();
	};

	std::cout << solve(N) << std::endl;
}
0