結果
問題 |
No.1576 織姫と彦星
|
ユーザー |
![]() |
提出日時 | 2021-06-29 14:57:29 |
言語 | cLay (20241019-1) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 681 bytes |
コンパイル時間 | 2,757 ms |
コンパイル使用メモリ | 186,448 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-05 15:18:40 |
合計ジャッジ時間 | 4,030 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 54 |
ソースコード
{ VI nodes[32]; map<int,VI> edges; set<int> vis; ll@n,@st,@ed; nodes[__builtin_popcountl(st)].push_back(st); nodes[__builtin_popcountl(ed)].push_back(ed); rep(n){ ll@s; nodes[__builtin_popcountl(s)].push_back(s); } rep(i,31){ for(ll j:nodes[i]){ for(ll k:nodes[i+1]){ if(__builtin_popcount(j^k)==1){ edges[j].push_back(k); edges[k].push_back(j); } } } } int q[3000]; ll qr=0,qw=0,ans=0; q[qw++]=st; while(qr<qw){ ll qn=qw; while(qr<qn){ ll s=q[qr++]; if(s==ed){ wt(ans-1); exit(0); } for(ll j:edges[s]){ if(vis.find(j)==vis.end()){ vis.insert(j); q[qw++]=j; } } } ++ans; } wt(-1); }