結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-26 19:12:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 632 bytes |
| コンパイル時間 | 680 ms |
| コンパイル使用メモリ | 77,180 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-01 09:32:11 |
| 合計ジャッジ時間 | 1,670 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
#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(0, 1);
vector<int> b(N, -1);
b.front() = 1;
while (!a.empty()) {
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);
b[e] = 1 + a.front().second;
}
if (N > d && -1 == b[d]) {
a.emplace(d, 1 + a.front().second);
b[d] = 1 + a.front().second;
}
a.pop();
}
cout << b.back();
}