当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7244:Winner Prediction

题目描述
A tournament consisting of $n$ participants is currently taking place. The players are numbered from $1$ to $n$. Every match is between two participants, and there are no draws. The participant who wins the most matches wins the entire tournament; if there are multiple participants tied at the first place, all of them win the tournament.

At the current state, some matches have ended, and others are yet to start. You are given the results of all ended matches. Write a program to determine whether it is possible for player $1$ to win the tournament.

You are given $T$ independent test cases. Solve each of them.
输入解释
The first line of input consists of a single integer $T(1\leq T\leq 100)$, indicating the number of test cases. Then $T$ test cases follow.

Each of the $T$ test cases consists of multiple lines.

The first line contains three integers $n,m_1,m_2(1\leq n\leq 500,1\leq m_1,m_2 \leq 1000)$, indicating the number of participants, the number of ended matches and the number of upcoming matches.

Each of the next $m_1$ lines contains three space-separated integers $x,y,z(1\leq x,y \leq n,x \neq y,0\leq z \leq 1)$, indicating an ended match between player $x$ and player $y$ , $z = 1$ means player $x$ won the match and $z=0$ means player $y$ won the match.

Each of the next $m_2$ lines contains two space-separated integers $x,y(1 \leq x,y \leq n,x \neq y)$, indicating an upcoming match between player $x$ and player $y$.
输出解释
For each test case, if it is possible of player $1$ to win the tournament, print a line $\texttt{YES}$; otherwise print a line $\texttt{NO}$.
输入样例
2
4 2 1
2 3 1
3 2 1
1 4
4 2 2
2 3 1
2 4 1
1 2
3 4
输出样例
YES
NO

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7244

最后修改于 2022-09-15T06:17:35+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 524288/524288K(Java/Others)