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. 【pytorch】目标检测:新手也能彻底搞懂的YOLOv5详解

    YOLOv5是Glenn Jocher等人研发,它是Ultralytics公司的开源项目.YOLOv5根据参数量分为了n.s.m.l.x五种类型,其参数量依次上升,当然了其效果也是越来越好.从2020 ...

  2. Linux查看磁盘空间,文件系统、挂载

    Linux磁盘空间,文件系统.挂载 概述 在使用以下命令查看磁盘使用情况时 df -h du -sh 目标路径 作为初级开发者,Linux入门级选手,可能不禁要问Linux系统的文件系统跟window ...

  3. 小白快速入门SRC挖掘(以edusrc为例)

    edusrc平台介绍 我们可以在关于页面看到edusrc的收录规则: 现阶段,教育行业漏洞报告平台接收如下类别单位漏洞: 教育部 各省.自治区教育厅.直辖市教委.各级教育局 学校 教育相关软件 可以看 ...

  4. 问题总结:浮点数之间的等值判断,基本数据类型不能用==来比较,包装数据类型不能用equals来判断

    浮点数之间的等值判断,基本数据类型不能用==来比较,包装数据类型不能用equals来判断. 说明:浮点数采用"尾数+阶码"的编码方式,类似于科学计数法的"有效数字+指数& ...

  5. 每日一库:lumberjack -- 日志轮换和管理

    在开发应用程序时,记录日志是一项关键的任务,以便在应用程序运行时追踪问题.监视性能和保留审计记录.Go 语言提供了灵活且强大的日志记录功能,可以通过多种方式配置和使用.其中一个常用的日志记录库是 gi ...

  6. Text2Cypher:大语言模型驱动的图查询生成

    话接上文<图技术在 LLM 下的应用:知识图谱驱动的大语言模型 Llama Index> 同大家简单介绍过 LLM 和图.知识图谱相关的结合,现在我来和大家分享下最新的成果.毕竟,从 GP ...

  7. Linux: Authentication token is no longer valid

    遇见问题: [oracle@sxty-jkdb-184:/u01/rman]crontab -l Authentication token is no longer valid; new one re ...

  8. 从内核世界透视 mmap 内存映射的本质(源码实现篇)

    本文基于内核 5.4 版本源码讨论 通过上篇文章 <从内核世界透视 mmap 内存映射的本质(原理篇)>的介绍,我们现在已经非常清楚了 mmap 背后的映射原理以及它的使用方法,其核心就是 ...

  9. NW排错

    fist date VM备份失败时: NW server上(linux): > nsradmin >p type : nsr recover > cd /nsr/logs >n ...

  10. nodejs修改npm包安装位置

    适用于非个人电脑.便携使用 npm config set cache D:\nodejs\node_cache npm config set prefix D:\nodejs npm config s ...