Grindelwald Photofit
Time limit2sMemory limit1024 MB
Check whether every painted pixel in grid p is allowed by its restriction in grid c, and print correct or incorrect.
- Level
Easy1 of 10
- Topics
- Implementation, Matrix
- Solved
- No attempts yet
Statement
The Ministry of Magic wants to put Grindelwald's photofit on the city's main electronic display. They ran into trouble with this.
The electronic photofit is a table with rows and columns. Each cell is the color of the pixel at row , column : R (red), G (green), B (blue), or . if the pixel must be left unpainted.
The display is also , but it is old. Each pixel has a restriction :
- : the pixel is broken and can only be left unpainted.
- : the pixel can only be painted red or left unpainted.
- : the pixel can only be painted green or left unpainted.
- : the pixel can be painted red or green, or left unpainted.
- : the pixel can only be painted blue or left unpainted.
- : the pixel can be painted red or blue, or left unpainted.
- : the pixel can be painted green or blue, or left unpainted.
- : the pixel can be painted red, green, or blue, or left unpainted.
The Ministry needs to determine whether the photofit can be placed on the display while satisfying all restrictions. Help them.
Input
The first line contains two integers and separated by a space (), the number of rows and columns.
The next lines each contain a string of characters. The -th character of the -th line is ().
After that, the next lines each contain a string of characters. The -th character of the -th line is ().
Output
Print correct if the photofit satisfies all restrictions . Otherwise, print incorrect.