結果
| 問題 | No.3 ビットすごろく |
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-02-01 04:15:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 648 bytes |
| コンパイル時間 | 325 ms |
| コンパイル使用メモリ | 50,944 KB |
| 最終ジャッジ日時 | 2024-11-14 18:58:59 |
| 合計ジャッジ時間 | 900 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:9: error: ‘vector’ was not declared in this scope
9 | vector<unsigned> v(n+10, -1);
| ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
2 | #include <algorithm>
+++ |+#include <vector>
3 | using namespace std;
main.cpp:9:16: error: expected primary-expression before ‘unsigned’
9 | vector<unsigned> v(n+10, -1);
| ^~~~~~~~
main.cpp:10:9: error: ‘v’ was not declared in this scope
10 | v[1]=1;
| ^
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n;
while (cin>>n) {
vector<unsigned> v(n+10, -1);
v[1]=1;
bool changed=true;
while (changed) {
changed=false;
for(int i=1;i<=n;++i) if (v[i]!=-1) {
int k=__builtin_popcount(i);
if (v[i+k]>v[i]+1) {
v[i+k]=v[i]+1;
changed=true;
}
if (v[i-k]>v[i]+1) {
v[i-k]=v[i]+1;
changed=true;
}
}
}
cout<<(int)v[n]<<endl;
}
}
hogeover30