首页 > 其他分享 >Tournament Result

Tournament Result

时间:2022-09-04 21:24:31浏览次数:60  
标签:given There beat Tournament Player contradictory Result table

Problem Statement

$N$ players played a round-robin tournament.

You are given an $N$-by-$N$ table $A$ containing the results of the matches. Let $A_{i,j}$ denote the element at the $i$-th row and $j$-th column of $A$.
$A_{i,j}$ is - if $i=j$, and W, L, or D otherwise.
$A_{i,j}$ is W if Player $i$ beat Player $j$, L if Player $i$ lost to Player $j$, and D if Player $i$ drew with Player $j$.

Determine whether the given table is contradictory.

The table is said to be contradictory when some of the following holds:

  • There is a pair $(i,j)$ such that Player $i$ beat Player $j$, but Player $j$ did not lose to Player $i$;
  • There is a pair $(i,j)$ such that Player $i$ lost to Player $j$, but Player $j$ did not beat Player $i$;
  • There is a pair $(i,j)$ such that Player $i$ drew with Player $j$, but Player $j$ did not draw with Player $i$.

Constraints

  • $2 \leq N \leq 1000$
  • $A_{i,i}$ is -.
  • $A_{i,j}$ is W, L, or D, for $i\neq j$.

Input

Input is given from Standard Input in the following format:

$N$
$A_{1,1}A_{1,2}\ldots A_{1,N}$
$A_{2,1}A_{2,2}\ldots A_{2,N}$
$\vdots$
$A_{N,1}A_{N,2}\ldots A_{N,N}$

Output

If the given table is not contradictory, print correct; if it is contradictory, print incorrect.


Sample Input 1

4
-WWW
L-DD
LD-W
LDW-

Sample Output 1

incorrect

Player $3$ beat Player $4$, while Player $4$ also beat Player $3$, which is contradictory.


Sample Input 2

2
-D
D-

Sample Output 2

correct

There is no contradiction.

如果 \(a_{i,j}=D,a_{j,i}=D\)
如果 \(a_{i,j}=L,a_{j,i}=W\)
判定即可。

#include<cstdio>
int n;
char s[1005][1005]; 
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i!=j)
			{
				if(s[i][j]=='W'&&s[j][i]!='L')
				{
					printf("incorrect");
					return 0;
				}
				if(s[i][j]=='L'&&s[j][i]!='W')
				{
					printf("incorrect");
					return 0;
				}
				if(s[i][j]=='D'&&s[j][i]!='D')
				{
					printf("incorrect");
					return 0;
				}
			}
		}
	}
	printf("correct");
}

标签:given,There,beat,Tournament,Player,contradictory,Result,table
From: https://www.cnblogs.com/mekoszc/p/16656127.html

相关文章

  • Mybatis的ResultMap和ResultType的区别
    在使用mybatis进行数据库连接操作时对于SQL语句返回结果的处理通常有两种方式,一种就是resultType另一种就是resultMap,下面说下我对这两者的认识和理解resultType:当使用re......
  • 异常java.sql.SQLException: Before start of result set
    使用rs.getString();前一定要加上rs.next();原因:ResultSet对象代表SQL语句执行的结果集,维护指向其当前数据行的光标。每调用一次next()方法,光标向下移动一行。最初它位于......
  • startActivityForResult()被标注弃用,推荐使用registerForActivityResult()方法
    startActivityForResult()方法如今已经被废弃了,官方推荐的是使用ActivityResultAPI来实现两个Activity之间传递数据功能。但ActivityResultAPI时能做的事还有很多,下面......
  • mybatis 的ResultMap和ResultType区别是什么?
     官方文档说明:ResultType:期望从这条语句中返回结果的类全限定名或别名。注意,如果返回的是集合,那应该设置为集合包含的类型,而不是集合本身的类型。resultType和resul......
  • mybatis 中resultMap原理
    mybatis中从数据库中查询出数据,然后转化成对象的过程中起了关键作用的一个类是ResultMap.他定义了查询的结果最终转化成了哪个类的对象,并且定义了每个对象的属性是由......
  • C# Web Api HTTP Get (result as a string)
    为了方便调用,通常封装成一个通用的函数,如下:///<summary>///GetHttpasstringresult///</summary>///<paramname="url">RequestUrl.......
  • dsl查询queryResults转page
    privatestaticfinallongserialVersionUID=1L;//元素内容privateList<T>content;//是否有上一页privatebooleanfirst;//是否有下一......
  • 814 C Fighting Tournament
    写的时候思路想到了,但是不怎么会维护。这儿贴一个比较好理解的维护方式,用的双端队列。#include<bits/stdc++.h>usingnamespacestd;#defineintlonglong#pragma......
  • CF1719C Fighting Tournament 题解
    思路根据题意,很容易看出,每个人都完成一次比赛后,即完成\(n-1\)轮之后,力量值最大的人会留在第一的位置,且在第\(n-1\)轮完成后,除了力量值最大的人,其他人的胜场数都不会再......
  • org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or nu
    org.apache.ibatis.exceptions.TooManyResultsException:Expectedoneresult(ornull)tobereturnedbyselectOne(),butfound:2mybatis操作数据库时org.apache.......