AtCoder abc352
E
Problem Statement
You are given a weighted undirected graph \(G\) with \(N\) vertices, numbered \(1\) to \(N\). Initially, \(G\) has no edges.
You will perform \(M\) operations to add edges to \(G\). The \(i\)-th operation $$(1 \leq i \leq M)$$ is as follows:
- You are given a subset of vertices \(S_i=\lbrace A_{i,1},A_{i,2},\dots,A_{i,K_i}\rbrace\) consisting of \(K_i\) vertices. For every pair \(u, v\) such that \(u, v \in S_i\) and \(u < v\), add an edge between vertices \(u\) and $$v$$ with weight $$C_i$$.
After performing all \(M\) operations, determine whether \(G\) is connected. If it is, find the total weight of the edges in a minimum spanning tree of \(G\).
赛时用并查集做连通图的判断,用优先队列维护每一个点的最小连接边(仅值),但想不出如何生成最小生成树,维护信息不足
F
Problem Statement
There are \(N\) people, numbered \(1\) to \(N\).
A competition was held among these \(N\) people, and they were ranked accordingly. The following information is given about their ranks:
- Each person has a unique rank.
- For each \(1 \leq i \leq M\), if person \(A_i\) is ranked \(x\)-th and person \(B_i\) is ranked \(y\)-th, then \(x - y = C_i\).
The given input guarantees that there is at least one possible ranking that does not contradict the given information.
Answer \(N\) queries. The answer to the \(i\)-th query is an integer determined as follows:
- If the rank of person \(i\) can be uniquely determined, return that rank. Otherwise, return \(-1\).
这应该是真的难题,赛时也才过了480个人,初步想法为带权并查集维护一条奇怪的链,带着缺口的链,然后几根链子来判断最后的答案