結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-19 13:24:21 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 871 bytes |
| 記録 | |
| コンパイル時間 | 2,057 ms |
| コンパイル使用メモリ | 321,848 KB |
| 最終ジャッジ日時 | 2026-05-27 05:18:35 |
| 合計ジャッジ時間 | 2,781 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:76,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:62,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bit: In instantiation of 'constexpr int std::__popcount(_Tp) [with _Tp = int]':
main.cpp:24:37: required from here
24 | int v1 = u + std::__popcount(u);
| ~~~~~~~~~~~~~~~^~~
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bit:308:34: error: argument 1 in call to function '__builtin_popcountg' has signed type
308 | return __builtin_popcountg(__x);
| ^~~
ソースコード
#include <bits/stdc++.h>
#define int int32_t
#define Int int64_t
#define uint uint32_t
#define uInt uint64_t
void init() {
}
void code() {
int n;
std::cin >> n;
std::vector<int> vis(n + 1, -1);
std::queue<int> q;
vis[1] = 1;
q.emplace(1);
while (!q.empty()) {
auto u = q.front(); q.pop();
int v1 = u + std::__popcount(u);
int v2 = u - std::__popcount(u);
if (v1 <= n && vis[v1] == -1) {
q.emplace(v1);
vis[v1] = vis[u] + 1;
}
if (v2 >= 1 && vis[v2] == -1) {
q.emplace(v2);
vis[v2] = vis[u] + 1;
}
}
std::cout << vis[n] << '\n';
}
int main() {
std::cin.tie(nullptr)->sync_with_stdio(false);
// for (int i = 1, n = (std::cin >> n, n); i <= n; i++)
{
init();
code();
}
return 0;
}