编程介的小学生 2017-02-16 03:45 采纳率: 20.5%
浏览 1351
已采纳

Undirected Graph

Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:

There is an undirected graph with n vertices and m edges. Then Yuta does q operations on this graph. Each operation is described by two integers L,R (1≤L≤R≤n) and can be split into three steps:

  1. Delete all the edges which have at least one vertice outside the range [L,R].

  2. Yuta wants you to tell him the number of connected component of the graph.

  3. Restore the graph.

This task is too hard for Rikka to solve. Can you help her?
Input There are at most 100 testcases and there are at least 97 testcases with n,m,q≤1000.

For each testcase, the first line contains three numbers n,m,q (n,q≤105,m≤2×105).

Then m lines follow. Each line contains two numbers ui,vi (1≤ui,vi≤105) which describe an edge of the graph.

Then q lines follows. Each line contains two numbers Li,Ri (1≤L≤R≤n) which describe an operation.
Output For each operation you need print a single line with a single number - the answer of this operation.
Sample Input
3 3 2
1 2
1 3
2 3
1 2
1 3

Sample Output
2
1

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-02-20 17:17
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序