結果

問題 No.3 ビットすごろく
ユーザー Mcpu3Mcpu3
提出日時 2019-10-26 17:37:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 569 bytes
コンパイル時間 824 ms
コンパイル使用メモリ 76,660 KB
実行使用メモリ 38,048 KB
最終ジャッジ日時 2023-10-12 15:29:52
合計ジャッジ時間 25,336 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 6 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 67 ms
4,348 KB
testcase_06 AC 6 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 54 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 971 ms
11,972 KB
testcase_15 AC 2,485 ms
30,124 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
4,352 KB
testcase_22 AC 991 ms
12,036 KB
testcase_23 AC 2,913 ms
37,756 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1 ms
4,348 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bitset>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	queue<pair<int, int>> a;
	a.emplace();
	vector<int> b(N, -1);
	while (!a.empty()) {
		b[a.front().first] = 1 + a.front().second;
		bitset<14> c = 1 + a.front().first;
		int d = a.front().first + c.count(), e = a.front().first - c.count();
		if (-1 < e && -1 == b[e]) a.emplace(e, 1 + a.front().second);
		if (N > d && -1 == b[d]) a.emplace(d, 1 + a.front().second);
		a.pop();
	}
	cout << b.back();
}
0