結果

問題 No.1577 織姫と彦星2
ユーザー 👑 tails
提出日時 2021-06-29 14:57:57
言語 cLay
(20250308-1 + boost 1.89.0)
コンパイル:
clayc _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 681 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,728 ms
コンパイル使用メモリ 202,896 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2026-03-27 00:05:22
合計ジャッジ時間 10,424 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 20 RE * 33
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

{
	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);
}
0