相等性和相似性的判断的算法,如何才能利用C程序的编写的技术来实现的呢

Problem Description
Everyone konws how to traveling a tree using the DFS strategy. But we also know that there are many ways to do so. For example, giving a tree as the following picture, we may get three ways: 010011, 001101, 01010011. 0 stands for the down operation while 1 means the up operation.
Now we make a constraint: if one node has k direct childs, you can visit a node at most 2*k times, if k == 0, you can visit it only once, in the example, the root has two direct child. Like the example, you can only get two ways: 010011, 001101. Because the way 01010011 will visit the node in yellow four times.
Here is the problem: ACboy drawed a tree, but is not very nice, so he won't show you the picture. Instread he will give you two strings indicating that the ways to travel the tree. Of cource, the strings will only contain 0 and 1. And your mission is to tell whether ACboy is telling the truth. For example, he drawed a picture as the following, if he give you 010011 and 001101, then he is telling the truth, but if he give you 010011 and 01010011, you konw that he is telling a lie.

Input
On the first line of input is a single positive integer n, telling the number of test scenarios to follow.Each test case consists of two lines, each containing a string of the characters '0' and '1' of length at most 3000, both describing a way to travel the tree.

Output
For each test case output a line containing the word "True" or the word "False", depending on whether ACboy is telling the truth.

Sample Input
2
010011
001101
010011
01010011

Sample Output
True
False

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

相似问题

12
关于地址赋值给指针的问题,求大神
2
c#+AE实现查找一个图层中所选的polyline要素是否闭合
11
java,判断两个Integer数组是否相等,有没有新奇高效的方法?
2
换行\n和数据库取出来的\\n要怎么判断他们相等?
2
不同变量的值相等的时候 地址也相同
8
急求!怎么这做判断啊 不相等 retrun老是返回正确的
0
当所有结点的权值都相等时,用这些结点构造的二叉树上只有?
1
表单数据和数据库字段里的内容匹配 为什么系统判断为不相等
0
用fgets或者fscanf从文件输入到链表中的内容错误!!
0
用fscanf和fgets从文件读取数据存储到链表失败是为什么??
2
C语言计算:化学方程式,判断其格式上是否正确(这里不考虑意义上的正确性问题)。如果正确输出YES,否则NO
0
C语言如何输入两个二叉树的二进制判断二叉树是否是相等的
1
为什么C语言中字符串从文件中调用出来后会和键盘上输入的不相等?
0
输入两个正规式,然后进行相等性的判断,采用C语言如何解决
2
Java怎样判断键盘输入的字符与指定字符相等?
0
二叉树的相等性的判断算法问题,运用C语言具体怎么实现的一个思路?
1
贪心算法 要求参与每个活动的时间相等 应该如何设计思路
0
罗马数字的一个转换的问题怎么判断相等性,用C语言的程序设计过程是如何的
4
Hql找不到数据库中年月日相等的时间戳的记录
1
求一元二次方程的根(改了一晚上,还是不正确,这是我第一次的程序)(希望大佬们指点一二,感谢感谢)