Connection Status:
Competition Arena > EightRooks
SRM 657 · 2015-03-26 · by rng_58 · Simple Search, Iteration
Class Name: EightRooks
Return Type: String
Method Name: isCorrect
Arg Types: (vector<string>)
Problem Statement

Problem Statement

Cat Snuke is playing a puzzle called Eight Rooks Puzzle.

In this puzzle, he must put exactly eight rooks onto an 8x8 chessboard. No two rooks must be in the same row, and no two rooks must be in the same column.

You are given a String[] board. The j-th character of the i-th element of board is either 'R' or '.'. If this is 'R', the cell in row i, column j contains a rook. Otherwise the cell doesn't contain a rook.

Determine whether Snuke solved the puzzle correctly. If he solved the puzzle correctly, return "Correct". Otherwise return "Incorrect".

Constraints

  • board will contain exactly 8 elements.
  • Each element of board will contain exactly 8 characters.
  • Each character in board will be either 'R' or '.'.
Examples
0)
{"R.......",
 ".R......",
 "..R.....",
 "...R....",
 "....R...",
 ".....R..",
 "......R.",
 ".......R"}
Returns: "Correct"
1)
{"........",
 "....R...",
 "........",
 ".R......",
 "........",
 "........",
 "..R.....",
 "........"}
Returns: "Incorrect"

The number of rooks is not eight.

2)
{"......R.",
 "....R...",
 "...R....",
 ".R......",
 "R.......",
 ".....R..",
 "..R.....",
 ".......R"}
Returns: "Correct"
3)
{"......R.",
 "....R...",
 "...R....",
 ".R......",
 "R.......",
 ".......R",
 "..R.....",
 ".......R"}
Returns: "Incorrect"

The rightmost column contains two rooks.

4)
{"........",
 "........",
 "........",
 "........",
 "........",
 "........",
 "........",
 "........"}
Returns: "Incorrect"

Submissions are judged against all 65 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class EightRooks with a public method string isCorrect(vector<string> board) · 65 test cases · 2 s / 256 MB per case

Submitting as anonymous