编程介的小学生 2019-09-15 21:38 采纳率: 20.5%
浏览 100

Boring Game 用的C语言

Problem Description
Brian's little sister Mary is fond of strange games involving lots of calculation. Unfortunately she's not so good at mathematics so Brian's often asked to calculate the values needed for her. Recently Brian's facing another such problem:
An undirected graph with N vertexes and M edges is first drawn by Mary. Then, Mary randomly assigns an integer value to each of the vertexes. After that, Mary will perform a sequence of operations on the graph, each operation being of one of the following type:
a) Among all vertexes connecting with vertex X via some edges, find the least value that is no less than value K. If such value cannot be found, zero will be returned instead.
b) Updates the value assigned to vertex X to K.
c) Erases an edge connecting vertex A and B from the graph.
Mary’s interested in the average value of all answers to type a) operations. Would you please help Brian to finish this boring task?

Input
There are multiple test cases in the input file. Each case starts with three integers, N, M, and Q (1 <= N <= 2 * 104, 0 <= M <= 6 * 104, 1 <= Q <= 3 * 105). The next N lines describe the initial value assigned to each vertex. The next part of each test case consists of M lines, and describes the edges in the graph at the beginning. Vertexes are numbered from 1 to N. The last part of each test case describes the operations to be performed on the tree. For operations of a) type, a line similar to “F X K” will be given; for operations of b) type, a line with the format of “U X K” will be given; and for c) type, the description will be given in the format similar to “E A B”. You can assume that there will always be at least one a) type query. The absolute value assigned to any vertex at any time will not exceed 10000.
There is a blank line between two successive cases. Input ends with End-of-File.

Output
For each test case, output one real number – the requested value with precision up to 0.001, in the format as indicated in the sample output.

Sample Input
3 3 8
4
5
8
1 2
2 3
1 3
F 1 4
E 1 3
F 2 7
E 2 3
E 1 2
F 2 7
U 3 6
F 3 3

1 0 1
0
F 1 0

Sample Output
Case 1: 4.500
Case 2: 0.000

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 聚类分析或者python进行数据分析
    • ¥15 逻辑谓词和消解原理的运用
    • ¥15 三菱伺服电机按启动按钮有使能但不动作
    • ¥15 js,页面2返回页面1时定位进入的设备
    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号