結果

問題 No.1326 ふたりのDominator
ユーザー tailstails
提出日時 2020-12-23 17:03:52
言語 cLay
(20231016-1)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 932 bytes
コンパイル時間 4,021 ms
コンパイル使用メモリ 188,540 KB
実行使用メモリ 27,276 KB
最終ジャッジ日時 2023-10-24 10:39:05
合計ジャッジ時間 6,401 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
11,856 KB
testcase_01 AC 4 ms
11,856 KB
testcase_02 AC 3 ms
11,864 KB
testcase_03 AC 4 ms
11,872 KB
testcase_04 AC 4 ms
11,876 KB
testcase_05 AC 4 ms
11,856 KB
testcase_06 AC 4 ms
11,856 KB
testcase_07 AC 4 ms
11,968 KB
testcase_08 AC 4 ms
11,956 KB
testcase_09 AC 4 ms
11,964 KB
testcase_10 AC 4 ms
11,972 KB
testcase_11 AC 5 ms
11,972 KB
testcase_12 AC 71 ms
22,984 KB
testcase_13 AC 69 ms
22,724 KB
testcase_14 AC 69 ms
22,732 KB
testcase_15 AC 68 ms
22,780 KB
testcase_16 AC 67 ms
23,016 KB
testcase_17 AC 58 ms
22,664 KB
testcase_18 AC 62 ms
23,592 KB
testcase_19 AC 46 ms
24,600 KB
testcase_20 AC 72 ms
25,952 KB
testcase_21 AC 72 ms
25,980 KB
testcase_22 AC 81 ms
27,276 KB
testcase_23 AC 52 ms
22,868 KB
testcase_24 AC 71 ms
22,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

vector<int> nev[5d4];
int ena[1d5][2];
int nvis[5d4];
unionFind uf;

int f1(int ni,int ei){
	if(nvis[ni]){
		return nvis[ni]>0&&++nvis[ni];
	}
	int level=0;
	for(int ej:nev[ni]){
		if(ej!=ei){
			int nj=ni^ena[ej][0]^ena[ej][1];
			nvis[ni]=1;
			int l1=f1(nj,ej)-(nvis[ni]-1);
			level+=l1;
			if(l1){
				uf(ei,ej);
			}
		}
	}
	nvis[ni]=-1;
	return level;
}

int ec[1d5],ecn;
int ge[2][2d5];

{
	int @n,@m;
	uf.walloc(m,1);
	rep(i,m){
		int @u,@v;
		--u;
		--v;
		nev[u].push_back(i);
		nev[v].push_back(i);
		ena[i][0]=u;
		ena[i][1]=v;
	}
	f1(0,-1);
	unordered_set<long> ens;
	int gen=0;
	rep(i,m){
		int j=uf(i);
		if(!ec[j]){
			ec[j]=~ecn++;
		}
		j=~ec[j];
		rep(k,2){
			if(ens.insert(j<<16|ena[i][k]).second){
				ge[0][gen]=ena[i][k];
				ge[1][gen]=n+j;
				++gen;
			}
		}
	}
	graph g;
	g.setEdge(n+ecn,gen,ge[0],ge[1]);
	HLD h;
	h.init(g);
	int @q;
	rep(q){
		int @x,@y;
		--x;--y;
		wt(x==y?0:h.dist(x,y)/2-1);
	}
}
0