题目来源于牛客竞赛:https://ac.nowcoder.com/acm/contest/discuss
题目描述:
You are given an undirected graph with N vertices and M edges. The edges are numbered from 1 to M. Denote the set S(x) as: All the vertices we can reach from vertex x by exactly one edge.
You are supposed to deal with Q operations of the following two types: (1,l,r)-- reverse the status of edges numbered between l to r(1≤l≤r≤M). i e.Delete the edge if it is in the graph, otherwise add it to the graph.
(2,u,v) – ask whether S(u) and S(v) are exactly the same (1≤u≤v≤N
).
Note that all the M edges are in the graph at the beginning.
输入描述:
The input contains multiple cases. The first line of the input contains a single positive integer T, the number of cases.
For each case, the first line contains two integers N (1≤N≤100000) and M (1≤M≤200000), the number of vertices and edges in the graph. In the following M lines, the i-t

该博客介绍了如何解决牛客暑期多校训练营中关于图游戏的编程问题,涉及图的集合判断和区间操作。文章提出了使用哈希技巧表示集合,并通过度数分块、树状数组和暴力维护来优化算法,实现O(Q√M)的时间复杂度和O(M)的空间复杂度。
最低0.47元/天 解锁文章
312

被折叠的 条评论
为什么被折叠?



