結果

問題 No.3 ビットすごろく
コンテスト
ユーザー Mcpu3
提出日時 2019-10-26 17:37:14
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 569 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 835 ms
コンパイル使用メモリ 91,940 KB
実行使用メモリ 38,116 KB
最終ジャッジ日時 2026-04-04 13:03:58
合計ジャッジ時間 19,379 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge5_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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