题目链接:点击打开链接
A. Contest
time limit per test
memory limit per test
input
output
a points and Vasya solved the problem that costs b points. Besides, Misha submitted the problem c minutes after the contest started and Vasya submitted the problem d minutes after the contest started. As you know, on Codeforces the cost of a problem reduces as a round continues. That is, if you submit a problem that costs p points tminutes after the contest started, you get
points.
Misha and Vasya are having an argument trying to find out who got more points. Help them to find out the truth.
Input
a, b, c, d (250 ≤ a, b ≤ 3500, 0 ≤ c, d ≤ 180).
a and b are divisible by 250
Output
Output on a single line:
Misha" (without the quotes), if Misha got more points than Vasya.
Vasya" (without the quotes), if Vasya got more points than Misha.
Tie" (without the quotes), if both of them got the same number of points.
Examples
input
500 1000 20 30
output
Vasya
input
1000 1000 1 1
output
Tie
input
1500 1000 176 177
output
Misha
水题不多说~~
题目链接:点击打开链接
B. Misha and Changing Handles
time limit per test
memory limit per test
input
output
Misha hacked the Codeforces site. Then he decided to let all the users change their handles. A user can now change his handle any number of times. But each new handle must not be equal to any handle that is already used or that was used at some point.
Misha has a list of handle change requests. After completing the requests he wants to understand the relation between the original and the new handles of the users. Help him to do that.
Input
q (1 ≤ q ≤ 1000), the number of handle change requests.
q
old and new, separated by a space. The strings consist of lowercase and uppercase Latin letters and digits. Strings old and new are distinct. The lengths of the strings do not exceed 20.
old, and handlenew
Output
n
n lines print the mapping between the old and the new handles of the users. Each of them must contain two strings, old andnew, separated by a space, meaning that before the user had handle old, and after all the requests are completed, his handle is new. You may output lines in any order.
Each user who changes the handle must occur exactly once in this description.
Examples
input
5Misha ILoveCodeforces Vasya Petrov Petrov VasyaPetrov123 ILoveCodeforces MikeMirzayanov Petya Ivanov
output
3Petya Ivanov Misha MikeMirzayanov Vasya VasyaPetrov123
题解:(这道题用map也行得通)以下是字符串拷贝函数的使用,strcmp ( a,b ) 作用:是把字符串 b 连同串结束标志 ‘ \0 ' 复制到 a 中,也就是把串 a 换成 串 b
题目链接:点击打开链接
C. Misha and Forest
time limit per test
memory limit per test
input
output
n vertices. For each vertex v from 0 to n - 1 he wrote down two integers, degreev and sv, were the first integer is the number of vertices adjacent to vertex v, and the second integer is the XOR sum of the numbers of vertices adjacent to v (if there were no adjacent vertices, he wrote down 0).
degreev and sv
Input
n (1 ≤ n ≤ 216), the number of vertices in the graph.
i-th of the next lines contains numbers degreei and si (0 ≤ degreei ≤ n - 1, 0 ≤ si < 216), separated by a space.
Output
m, the number of edges of the graph.
m lines, each containing two distinct numbers, a and b (0 ≤ a ≤ n - 1, 0 ≤ b ≤ n - 1), corresponding to edge (a, b).
Edges can be printed in any order; vertices of the edge can also be printed in any order.
Examples
input
32 3 1 0 1 0
output
21 0 2 0
input
21 1 1 0
output
10 1
Note
2. This operation exists in many modern programming languages. For example, in languages C++, Java and Python it is represented as "^", and in Pascal — as "xor".
题意:给你一个无环无重边的图,并且给你每个点的与其相邻点的个数和相邻点标号的异或值,让你输出所有的边。
题解:其实给的图其实是一棵树,要解决此题就要从叶子节点入手,因为与叶子节点相邻的点只有一个,而叶子结点的异或值就是该点的标号,然后删去叶子结点,逐步往上递推就可以得到所有的边。