#abc261b. B - Tournament Result

B - Tournament Result

Score : 200200 points

问题描述

NN 名选手进行了一场循环赛。

给定一个 NN×NN 的表格 AA,其中记录了比赛结果。令 Ai,jA_{i,j} 表示 AA 中第 ii 行第 jj 列的元素。
i=ji=j,则 Ai,jA_{i,j}-;否则,Ai,jA_{i,j} 可以为 WLD
Ai,jA_{i,j}W,表示选手 ii 击败了选手 jj;若为 L,表示选手 ii 输给了选手 jj;若为 D,表示选手 ii 与选手 jj 战平。

判断给定的表格是否存在矛盾。

当满足以下任一条件时,该表格被认为存在矛盾:

  • 存在一对 (i,j)(i,j),使得选手 ii 击败了选手 jj,但选手 jj 并未输给选手 ii
  • 存在一对 (i,j)(i,j),使得选手 ii 输给了选手 jj,但选手 jj 并未击败选手 ii
  • 存在一对 (i,j)(i,j),使得选手 ii 与选手 jj 战平,但选手 jj 并未与选手 ii 战平。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

NN players played a round-robin tournament.

You are given an NN-by-NN table AA containing the results of the matches. Let Ai,jA_{i,j} denote the element at the ii-th row and jj-th column of AA.
Ai,jA_{i,j} is - if i=ji=j, and W, L, or D otherwise.
Ai,jA_{i,j} is W if Player ii beat Player jj, L if Player ii lost to Player jj, and D if Player ii drew with Player jj.

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)(i,j) such that Player ii beat Player jj, but Player jj did not lose to Player ii;
  • There is a pair (i,j)(i,j) such that Player ii lost to Player jj, but Player jj did not beat Player ii;
  • There is a pair (i,j)(i,j) such that Player ii drew with Player jj, but Player jj did not draw with Player ii.

Constraints

  • 2N10002 \leq N \leq 1000
  • Ai,iA_{i,i} is -.
  • Ai,jA_{i,j} is W, L, or D, for iji\neq j.

Input

Input is given from Standard Input in the following format:

NN

A1,1A1,2A1,NA_{1,1}A_{1,2}\ldots A_{1,N}

A2,1A2,2A2,NA_{2,1}A_{2,2}\ldots A_{2,N}

\vdots

AN,1AN,2AN,NA_{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 33 beat Player 44, while Player 44 also beat Player 33, which is contradictory.

Sample Input 2

2
-D
D-

Sample Output 2

correct

There is no contradiction.

update @ 2024/3/10 11:03:25