結果
問題 |
No.3 ビットすごろく
|
ユーザー |
|
提出日時 | 2019-10-26 17:37:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 569 bytes |
コンパイル時間 | 808 ms |
コンパイル使用メモリ | 77,204 KB |
実行使用メモリ | 37,976 KB |
最終ジャッジ日時 | 2024-09-14 14:15:59 |
合計ジャッジ時間 | 22,950 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 19 |
ソースコード
#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(); }