102611: [AtCoder]ABC261 B - Tournament Result

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:6 Solved:0

Description

Score : $200$ points

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.

Input

题意翻译

$N$ 个人进行了循环赛。 给你一张 $N$ 行 $N$ 列的结果表 $A$ ,其中字符为 $-,W,L,D$。 $W$ 指胜利,$L$ 指失败,$D$ 指平局。 如果有以下情况,则为矛盾 + $a_{i,j}$ 为 $W$ ,但 $a_{j,i}$ 不为 $L$ + $a_{i,j}$ 为 $L$ ,但 $a_{j,i}$ 不为 $W$ + $a_{i,j}$ 为 $D$ ,但 $a_{j,i}$ 不为 $D$ 求表格是否有矛盾,如果有矛盾输出 $correct$ ,否则输出 $incorrect$ . $2 \le N \le 1000$

Output

分数:200分 部分 问题描述 有N名选手参加了一次循环赛。 你将得到一个N×N的表格A,其中包含了比赛的结果。令A_{i,j}表示A中第i行和第j列的元素。 如果i=j,那么A_{i,j}为“-”;否则,A_{i,j}为“W”、“L”或“D”。 如果选手i击败了选手j,那么A_{i,j}为“W”;如果选手i输给了选手j,那么A_{i,j}为“L”;如果选手i与选手j战平,那么A_{i,j}为“D”。 确定给定的表格是否有矛盾。 当满足以下条件之一时,称该表格存在矛盾: * 存在一对(i,j),选手i击败了选手j,但选手j并未输给选手i; * 存在一对(i,j),选手i输给了选手j,但选手j并未击败选手i; * 存在一对(i,j),选手i与选手j战平,但选手j并未与选手i战平。 部分 约束 * 2≤N≤1000 * A_{i,i}为“-”。 * 对于i≠j,A_{i,j}为“W”、“L”或“D”。 输入 输入格式如下: N A_{1,1}A_{1,2}…A_{1,N} A_{2,1}A_{2,2}…A_{2,N} vdots A_{N,1}A_{N,2}…A_{N,N} 输出 如果给定的表格没有矛盾,输出“correct”;如果有矛盾,输出“incorrect”。 部分 样例输入1 4 -WWW L-DD LD-W LDW- 样例输出1 incorrect 选手3击败了选手4,而选手4也击败了选手3,这是矛盾的。 部分 样例输入2 2 -D D- 样例输出2 correct 没有矛盾。

加入题单

算法标签: