编程介的小学生 2018-12-12 12:18 采纳率: 0.2%
浏览 553
已采纳

数据结构中的无向图,用C语言实现的过程中的思路???

roblem 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 2019-06-30 10:15
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密
  • ¥15 关于#qt#的问题:我想实现qcustomplot完成坐标轴
  • ¥15 下列c语言代码为何输出了多余的空格