結果

問題 No.1577 織姫と彦星2
ユーザー tailstails
提出日時 2021-06-29 15:11:55
言語 cLay
(20240104-1)
結果
AC  
実行時間 1,368 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 2,195 ms
コンパイル使用メモリ 175,764 KB
実行使用メモリ 11,036 KB
最終ジャッジ日時 2023-09-19 02:30:50
合計ジャッジ時間 27,452 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 82 ms
4,380 KB
testcase_06 AC 10 ms
4,376 KB
testcase_07 AC 716 ms
7,664 KB
testcase_08 AC 148 ms
5,364 KB
testcase_09 AC 1,368 ms
10,644 KB
testcase_10 AC 142 ms
4,380 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 341 ms
6,032 KB
testcase_13 AC 97 ms
4,380 KB
testcase_14 AC 500 ms
6,804 KB
testcase_15 AC 78 ms
5,056 KB
testcase_16 AC 667 ms
8,340 KB
testcase_17 AC 268 ms
5,860 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 526 ms
8,032 KB
testcase_20 AC 404 ms
7,740 KB
testcase_21 AC 633 ms
9,012 KB
testcase_22 AC 652 ms
7,932 KB
testcase_23 AC 114 ms
5,420 KB
testcase_24 AC 1,105 ms
7,544 KB
testcase_25 AC 63 ms
4,528 KB
testcase_26 AC 126 ms
5,624 KB
testcase_27 AC 793 ms
4,508 KB
testcase_28 AC 460 ms
6,764 KB
testcase_29 AC 246 ms
4,384 KB
testcase_30 AC 280 ms
5,356 KB
testcase_31 AC 718 ms
7,540 KB
testcase_32 AC 3 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 202 ms
4,888 KB
testcase_35 AC 596 ms
7,616 KB
testcase_36 AC 636 ms
7,804 KB
testcase_37 AC 1,098 ms
11,036 KB
testcase_38 AC 1,070 ms
9,080 KB
testcase_39 AC 148 ms
5,544 KB
testcase_40 AC 162 ms
5,196 KB
testcase_41 AC 960 ms
6,024 KB
testcase_42 AC 422 ms
4,380 KB
testcase_43 AC 439 ms
4,584 KB
testcase_44 AC 3 ms
4,384 KB
testcase_45 AC 37 ms
4,484 KB
testcase_46 AC 65 ms
4,380 KB
testcase_47 AC 935 ms
4,536 KB
testcase_48 AC 178 ms
4,380 KB
testcase_49 AC 227 ms
5,644 KB
testcase_50 AC 103 ms
4,480 KB
testcase_51 AC 13 ms
4,380 KB
testcase_52 AC 1,178 ms
7,424 KB
testcase_53 AC 1,061 ms
7,984 KB
testcase_54 AC 272 ms
4,692 KB
testcase_55 AC 1,032 ms
7,076 KB
testcase_56 AC 80 ms
5,388 KB
testcase_57 AC 24 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

int q[5d4];
{
	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);
				}
			}
		}
	}
	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