B - Tournament Result Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 200

問題文

N 人の人が総当り戦の試合をしました。

NN 列からなる試合の結果の表 A が与えられます。Ai 行目 j 列目の要素を A_{i,j} と表します。
A_{i,j}i=j のとき - であり、それ以外のとき W, L, D のいずれかです。
A_{i,j}W, L, D であることは、人 i が人 j との試合に勝った、負けた、引き分けたことをそれぞれ表します。

与えられた表に矛盾があるかどうかを判定してください。

次のいずれかが成り立つとき、与えられた表には矛盾があるといいます。

  • ある組 (i,j) が存在して、人 i が人 j に勝ったが、人 j が人 i に負けていない
  • ある組 (i,j) が存在して、人 i が人 j に負けたが、人 j が人 i に勝っていない
  • ある組 (i,j) が存在して、人 i が人 j に引き分けたが、人 j が人 i に引き分けていない

制約

  • 2 \leq N \leq 1000
  • A_{i,i}- である
  • i\neq j のとき、A_{i,j}W, L, D のいずれかである

入力

入力は以下の形式で標準入力から与えられる。

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}

出力

与えられた表に矛盾がないとき correct、矛盾があるとき incorrect と出力せよ。


入力例 1

4
-WWW
L-DD
LD-W
LDW-

出力例 1

incorrect

3 が人 4 に勝ったにもかかわらず、人 4 も人 3 に勝ったことになっており、矛盾しています。


入力例 2

2
-D
D-

出力例 2

correct

矛盾はありません。

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.