如何排除掉冲突的项,怎么用C语言的程序具体的思想来编写出的代码的过程去实现的排除

Problem Description
Conflicts are everywhere in the world, from the young to the elderly, from families to countries. Conflicts cause quarrels, fights or even wars. How wonderful the world will be if all conflicts can be eliminated.
Edward contributes his lifetime to invent a 'Conflict Resolution Terminal' and he has finally succeeded. This magic item has the ability to eliminate all the conflicts. It works like this:
If any two people have conflict, they should simply put their hands into the 'Conflict Resolution Terminal' (which is simply a plastic tube). Then they play 'Rock, Paper and Scissors' in it. After they have decided what they will play, the tube should be opened and no one will have the chance to change. Finally, the winner have the right to rule and the loser should obey it. Conflict Eliminated!
But the game is not that fair, because people may be following some patterns when they play, and if the pattern is founded by others, the others will win definitely.
Alice and Bob always have conflicts with each other so they use the 'Conflict Resolution Terminal' a lot. Sadly for Bob, Alice found his pattern and can predict how Bob plays precisely. She is very kind that doesn't want to take advantage of that. So she tells Bob about it and they come up with a new way of eliminate the conflict:
They will play the 'Rock, Paper and Scissors' for N round. Bob will set up some restricts on Alice.
But the restrict can only be in the form of "you must play the same (or different) on the ith and jth rounds". If Alice loses in any round or break any of the rules she loses, otherwise she wins.
Will Alice have a chance to win?

Input
The first line contains an integer T(1 <= T <= 50), indicating the number of test cases.
Each test case contains several lines.
The first line contains two integers N,M(1 <= N <= 10000, 1 <= M <= 10000), representing how many round they will play and how many restricts are there for Alice.
The next line contains N integers B1,B2, ...,BN, where Bi represents what item Bob will play in the ith round. 1 represents Rock, 2 represents Paper, 3 represents Scissors.
The following M lines each contains three integers A,B,K(1 <= A,B <= N,K = 0 or 1) represent a restrict for Alice. If K equals 0, Alice must play the same on Ath and Bth round. If K equals 1, she must play different items on Ath and Bthround.

Output
For each test case in the input, print one line: "Case #X: Y", where X is the test case number (starting with 1) and Y is "yes" or "no" represents whether Alice has a chance to win.

Sample Input
2
3 3
1 1 1
1 2 1
1 3 1
2 3 1
5 5
1 2 3 2 1
1 2 1
1 3 1
1 4 1
1 5 1
2 3 0

Sample Output
Case #1: no
Case #2: yes

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

相似问题

1
用链表类完成一元多项式的加法 为什么vs在重载赋值运算符的时候断点,说head访问权限冲突?
1
支付宝以前的即时到账和现在的电脑网站扫码支付是否有冲突
2
嵌入式Linux字符型驱动开发过程中,多个程序在同一时间操作这个字符型设备出现冲突?
3
idea git解决完冲突之后仍显示有冲突为解决
1
在用eclipse编译时出现:类文件冲突:存在使用另一大小写的资源,这是为什么?
1
数据结构上的一个线性表的冲突的解决,是不是用哈希算法怎么采用C语言的实现方式
0
Vue-cli 封装了axios并且也封装了请求接口前半部分相同的url,这个跟vue跨域 proxy代理的api地址冲突吗
1
win10系统用scanf_s运行报错,写入内存冲突
0
cxf生成的webservice客户端程序在was8.5中运行报错,该排除错误还是另寻它法???
2
安卓两个录音线程冲突的问题?
2
C语言通过指针修改原地址值时显示读取权限冲突。
2
萌新求解!!!!!vs2017写c语言,函数参数间不能传址吗?
1
0xC0000005: 写入位置 0x0000001C 时发生访问冲突。越界错误但是找不到在哪里
1
在调试下面的代码时出现访问冲突的问题
2
为什么在C语言使用数组时会发生访问冲突?
0
MUI下拉刷新与区域滚动冲突的解决办法?
2
代码编译能够成功但是运行的时候就显示写入位置 0x01100000 时发生访问冲突是为什么啊
8
同一类的不同对象,在调用同一成员函数时,是如何保证不冲突且各自输出各自想要的结果的?
2
(C语言)在二叉搜索树的学习时遇到了问题,求大佬帮忙看看