题解 | Graph Games-2019牛客暑期多校训练营第三场A题

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

题目来源于牛客竞赛: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-th line contains two integers ui,vi(1≤ui,vi≤N), describing the the i-th edge (ui,vi). Each edge appears in the input at most once. The (M+2)-th line contains a integer Q(1≤Q≤200000) , the number of operations. In the follo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值