数组的矩阵的转移的算法,怎么采用C语言的程序的计算的方式来实现的

Problem Description
Five hundred years later, the number of dragon balls will increase unexpectedly, so it's too difficult for Monkey King(WuKong) to gather all of the dragon balls together.

His country has N cities and there are exactly N dragon balls in the world. At first, for the ith dragon ball, the sacred dragon will puts it in the ith city. Through long years, some cities' dragon ball(s) would be transported to other cities. To save physical strength WuKong plans to take Flying Nimbus Cloud, a magical flying cloud to gather dragon balls.
Every time WuKong will collect the information of one dragon ball, he will ask you the information of that ball. You must tell him which city the ball is located and how many dragon balls are there in that city, you also need to tell him how many times the ball has been transported so far.

Input
The first line of the input is a single positive integer T(0 < T <= 100).
For each case, the first line contains two integers: N and Q (2 < N <= 10000 , 2 < Q <= 10000).
Each of the following Q lines contains either a fact or a question as the follow format:
T A B : All the dragon balls which are in the same city with A have been transported to the city the Bth ball in. You can assume that the two cities are different.
Q A : WuKong want to know X (the id of the city Ath ball is in), Y (the count of balls in Xth city) and Z (the tranporting times of the Ath ball). (1 <= A, B <= N)

Output
For each test case, output the test case number formated as sample output. Then for each query, output a line with three integers X Y Z saparated by a blank space.

Sample Input
2
3 3
T 1 2
T 3 2
Q 2
3 4
T 1 2
Q 1
T 1 3
Q 1

Sample Output
Case 1:
2 3 0
Case 2:
2 2 1
3 3 2

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

1
M*N算法矩阵,是否是使用二位数组,怎么利用C语言实现
1
Sylvester矩阵算法构造的问题,采用C语言,谢谢大神
1
C语言的函数算法去解决一个矩阵的问题,涉及到大数的计算怎么实现的?
0
重量分配矩阵的数学运算,采用C语言实现关于数据结构的算法
0
查找最近的车站的一个算法问题,采用邻接矩阵的方式的表述,怎么计算的,运用C语言的相关知识
0
三角形矩阵的求和的算法,如何利用C语言的办法计算三角形和
1
矩阵里元素交换的一个算法,如何利用C语言的编程的技术实现的办法
0
运用C语言是如何解决这里的矩阵的一个转换颠倒的算法的?具体的思路
0
矩阵 的Hadamard积的数据结构的算法,采用C语言编程技术如何实现的思路
0
关于在矩阵中进行的路径的查找的算法,如何使用C语言来编程实现
0
NxN矩阵棋盘着色问题的符号处理,采用C语言算法编程的实现方式
0
矩阵数字的一个路径的算法,怎么利用C语言编写程序的方式实现的
0
正方形的矩阵的一个算法的问题思路,用C语言的方式去计算怎么做
0
最短矩阵的移动距离的一个算法问题怎么利用C语言的程序的设计来解决的
0
一个用矩阵保存的分数的算法,计算2位小数,怎么利用C语言实现
0
和谐的矩阵的判断算法,怎么实现对矩阵的判断用C语言的程序的设计的办法
0
矩阵的优化的一个算法的问题怎么实现,用C语言的程序的编程的技术的实现
0
一个矩形构成的矩阵的算法问题,如何利用C程序的设计的语言的方式实现呢
0
矩阵的一个构造方法的算法,怎么采用C程序的设计的语言代码来实现的
0
运用二维数矩阵的数据结构解决的这个问题的算法,怎么采用C语言程序的办法来实现代码?