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. P8810 [蓝桥杯 2022 国 C] 数组个数 题解

    思路比较简单的一道题. 用的五维 dp,看到二维和三维的 dp 直接膜了 orz. 正文开始. 分析 不难看出 dp. 因为 \(b_i\) 的值只与 \(a_{i-1},a_i,a_{i+1}\) ...

  2. NOIP 2022 VP游记

    总结:挂大分. HA NOIP没初中生的份,VP. CSP-S 图论专场 NOIP 数数专场. CCF 我服你. T1 看完之后,感觉不难,瞎搞了 40min+,过了大样例. 对拍不会写. T2 猜不 ...

  3. GAN!生成对抗网络GAN全维度介绍与实战

    本文为生成对抗网络GAN的研究者和实践者提供全面.深入和实用的指导.通过本文的理论解释和实际操作指南,读者能够掌握GAN的核心概念,理解其工作原理,学会设计和训练自己的GAN模型,并能够对结果进行有效 ...

  4. Conda 命令深入指南

    Conda 命令深入指南 Conda 是一个功能强大的包管理系统,允许您为不同的项目创建和管理隔离的环境,从而更轻松地处理不同的依赖项集. 安装 可以按照 Conda 官方网站 (https://co ...

  5. [Python] 今天开始学习Python3了, 纪念一下

    #! /usr/bin/env python3 import time print("你好, 请告诉我你的名字.") name = input("名前: ") ...

  6. Microsoft Build 2021大会开始后,Develop Blog一系列更新

    .NET BLOG 发布.NET 6预览版4 https://devblogs.microsoft.com/dotnet/announcing-net-6-preview-4/ 发布.NET MAUI ...

  7. xgo多线程

    import threading import time #导入xgoedu from xgoedu import XGOEDU from xgolib import XGO #导入xgolib  # ...

  8. How can I access GPT-4?

    How can I access GPT-4?   Written by Joshua J.. Updated over a week ago API Access Most users will n ...

  9. .NET静态代码织入——肉夹馍(Rougamo)发布2.0

    肉夹馍(https://github.com/inversionhourglass/Rougamo)通过静态代码织入方式实现AOP的组件,其主要特点是在编译时完成AOP代码织入,相比动态代理可以减少应 ...

  10. JNI编程之字符串处理

    java中的字符串类型是String,对应的jni类型是jstring,由于jstring是引用类型,所以我们不能像基本数据类型那样去使用它,我们需要使用JNIEnv中的函数去处理jstring,下面 ...