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");
}

[ABC261B] Tournament Result的更多相关文章

  1. spark源码分析以及优化

    第一章.spark源码分析之RDD四种依赖关系 一.RDD四种依赖关系 RDD四种依赖关系,分别是 ShuffleDependency.PrunDependency.RangeDependency和O ...

  2. Rock-Paper-Scissors Tournament[HDU1148]

    Rock-Paper-Scissors TournamentTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Ja ...

  3. CodeForces - 283E Cow Tennis Tournament

    Discription Farmer John is hosting a tennis tournament with his n cows. Each cow has a skill level s ...

  4. No result defined for action com.lk.IndexAction and result success

    意图访问一个 /es/index.action 竟然出现: [SAE ] ERROR [05-11 13:54:32] [http-80-5] com.opensymphony.xwork2.util ...

  5. FunDA(1)- Query Result Row:强类型Query结果行

    FunDA的特点之一是以数据流方式提供逐行数据操作支持.这项功能解决了FRM如Slick数据操作以SQL批次模式为主所产生的问题.为了实现安全高效的数据行操作,我们必须把FRM产生的Query结果集转 ...

  6. PHP CI框架 result()详解

    该方法执行成功返回一个对象数组,失败则返回一个空数组. 一般情况下,我们使用下面的方法遍历结果,代码就像这样: $query = $this->db->query("要执行的 S ...

  7. Codeforces CF#628 Education 8 A. Tennis Tournament

    A. Tennis Tournament time limit per test 1 second memory limit per test 256 megabytes input standard ...

  8. CI生成查询记录集result(),row(),row_array().....

    result() 该方法执行成功返回一个对象数组,失败则返回一个空数组. 一般情况下,我们使用下面的方法遍历结果,代码就像这样: $query = $this->db->query(&qu ...

  9. Execute Sql Task 的Result DataSet如何返回

    Execute Sql Task的Result DataSet 主要有以下四种,当Execute Sql Task返回结果之后,需要使用SSIS Variable 来接收数据. 例子中使用的数据表代码 ...

  10. Struts2 源码分析——Result类实例

    本章简言 上一章笔者讲到关于DefaultActionInvocation类执行action的相关知识.我们清楚的知道在执行action类实例之后会相关处理返回的结果.而这章笔者将对处理结果相关的内容 ...

随机推荐

  1. tailwindcss -原子化 CSS 框架

    原子化 CSS 框架 我记得很久之前有时候为了少写些css,我们通常会有如下的样板代码 .block { display: block; } .flex { display:flex } .flex- ...

  2. 搭建Minio分布式服务

    本文主要介绍Minio的分布式环境搭建,安装比较简单,因博主只有一台window,所以使用VM虚拟机搭建的. 搭建前可以先了解下minio: 1.官方文档:https://docs.min.io/cn ...

  3. 在同一个k8s集群中部署多套nginx-controller

    1.nginx-controller部署请参考我的另一篇博客 nginx Ingress Controller Packaged by Bitnami 2.修改values.yaml 不通contro ...

  4. Tomcat--文件上传--文件包含--(CVE-2017-12615)&&(CVE-2020-1938)

    Tomcat--文件上传--文件包含--(CVE-2017-12615)&&(CVE-2020-1938) 复现环境 采用Vulfocus靶场环境进行复现,搭建操作和文章参考具体搭建教 ...

  5. 这些负载均衡都解决哪些问题?服务、网关、NGINX

    这篇文章解答一下群友的一系列提问: 在微服务项目中,有服务的负载均衡.网关的负载均衡.Nginx的负载均衡,这几个负载均衡分别用来解决什么问题呢? 在微服务项目中,服务的负载均衡.网关的负载均衡和Ng ...

  6. ios ipa apple company 开发者账号申请分享攻略

    ios公司开发者账号申请分享攻略 好不容易终于申请下来了ios 公司开发者账号,真是一路艰辛和漫长啊,特别是对于远在大洋彼岸的大中华国家.以下我就分享一下这一路下来的经验,希望对于那些新手同仁们有所帮 ...

  7. 11g GI监听测试增加其他本地端口

    11.2 GI中监听器的地址和端口信息被移到了 endpoints_listener.ora中. 使用 endpoints_listener.ora的情况下不应使用lsnrctl管理LISTENER, ...

  8. interface 接口相关【GO 基础】

    〇.接口简介 接口(interface)定义了一个对象的行为规范,只定义规范不实现,由具体的对象来实现规范的细节.也就是说,接口可以将一种或多种特征归纳到一起,其他不同的对象通过实现此接口,来表示可以 ...

  9. 【Azure Developer】在App Service上放置一个JS页面并引用msal.min.js成功获取AAD用户名示例

    问题描述 在App Service上放置一个JS页面并引用msal.min.js,目的是获取AAD用户名并展示. 问题解答 示例代码 <!DOCTYPE html> <html> ...

  10. Android-Java-反序列化JSON

    import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; String jsonStr= WebAPIOperato ...