Amoebae
SRM 172 · 2003-11-20 · by lbackstrom
Problem Statement
Your boss, the absent-minded biologist, has gone too far. It's one thing if he chills his lemonade in the lab refrigerator, but this morning he inadvertently rearranged the petri dishes. Now the old bird is calling for Culture X. You've found a dish of amoebae that looks like it might be Culture X, and you even have a photograph of Culture X taken yesterday, but these critters move around freely. They spin and glide through the dish and even flip over, making it hard to tell whether you're still looking at the same culture.
You are given a
...XXXXXXX.......
....X.X.X........
...XXXXXX........
...............XX
......X.....XX..X
.XXXXX........X.X
.X.XXX.......XXXX
Given a second
Constraints
- known and candidate have the same number of elements
- known and candidate each have between 1 and 50 elements, inclusive
- all elements of known and candidate are equally long
- elements of known and candidate are each between 1 and 50 characters long, inclusive
- all characters in known and candidate must be either '.' or 'X'
{"...XXXXXXX.......",
"....X.X.X........",
"...XXXXXX........",
"...............XX",
"......X.....XX..X",
".XXXXX........X.X",
".X.XXX.......XXXX"}
{"X.X..........XXXX",
"XXX...XX......X.X",
"X.X...XX........X",
"XXX...XX.......XX",
"X.X....X.X.......",
"XXX...XX.X.......",
"X.......X........"}
Returns: 0
You've found Culture X! All the amoebae have been translated since yesterday. The one that was in the lower right corner has also been reflected in the horizontal axis. The one at lower left has been reflected and rotated, as has the big ugly one with two holes. The amoeba formed of two squares has been rotated.
{"...XXXXXXX.......",
"....X.X.X........",
"...XXXXXX........",
"...............XX",
"......X.....XX..X",
".XXXXX........X.X",
".X.XXX.......XXXX"}
{"X.X..........XXXX",
"XXX...XX......X.X",
"X.X...XX........X",
"......XX.......XX",
"X.X....X.X.......",
"XXX...XX.X.......",
"X.......X........"}
Returns: 3
Four amoebae from Culture X are present in the candidate petri dish, but the big ugly one with two holes is missing. Furthermore, the candidate dish has two amoebae that were not present in Culture X. In total, this makes a difference of 1+2=3.
{"......................",
"....XXX...............",
"..X...X......XX.XX....",
"..XX.........XX.XX....",
"...XX.................",
"..........X...X..XXXX.",
"..XXX.....XX.XX.XX..XX",
"..X........X.X..X....X",
".....XX....XXX..X....X",
".....XX.....X...XX..XX",
"............X....XXXX."}
{"....X......XX.XX.XX...",
"....XXX....XX.XX.XX...",
".........XX...........",
".........XX...........",
"......................",
"..X....XXXX....X......",
"..X...XX..XX...X......",
".XXX..X....X..XXX.....",
".X.X..X....X..X.X.....",
"XX.XX.XX..XX.XX.XX....",
"X...X..XXXX..X...X...."}
Returns: 4
Compared to Culture X, the candidate dish has an extra Y-shaped amoeba and an extra two-by-two amoeba, but it's missing a small L-shaped amoeba, and it doesn't have the squiggly one at all. That makes a symmetric difference of 4.
{".XXXX.X...X...XXXX..",
"X..XXXXXXX.X.....XX.",
".X.X.XX....X..XXX..X",
"..XXX.X.X....X......",
".XXXXX...X.....XXXX.",
"..X.XXX..XX....XXX.X",
".......XXX..X.X...XX",
"XX....X.....X...X.X.",
".....X.....XX..XXX.X",
"X...XX.X.X..X....X.X",
".X........X.........",
".X..X.........X.....",
"..X.X..X..........XX",
"........X.X...X.XX..",
"....X.......X.X..X.X",
"....XX..X..X.X.X...X",
"X.....X.........X.X.",
"X.X...X.............",
"..XXX.X...X..X..XX..",
"X.......XX...X......"}
{".X.....X.X......XX.X",
"X.X.X..X..XX........",
"X..XXX......X....XX.",
"XXXXX.............X.",
"XX.XXX...X.XX.XX..X.",
".XX.XX..XX.....X....",
"XXXX.X.X........XXX.",
".X....X..X..X.......",
".X.X..X......X.X...X",
".X..XXX..X.........X",
"X....X....X..X....X.",
".XX.....X......X....",
"......XXXX....X.....",
"...X...........X..XX",
"X.X...X....X.XX.....",
"X.X.XX..X......X....",
"X.X.XX.XX....X..X.X.",
"XX..XX..XX...XX...X.",
".X..X.XX....X...X...",
"..X..XX.XX..X.XX...."}
Returns: 0
{".....XXX...X.....XX.....XX.XX..XX..",
"..X.XX.XX.X....XXX....X......X.....",
".....XX...X....X.X....X.X.X........",
"X.....X.......XXX.X....X..XX.X.....",
".X.X....X.X........X..........XX...",
"........XX........X.....X..X.X.....",
".X..X...X...XX.X..X.....X..........",
"..............X......X...X....X..X.",
"XX..X.....XX..X...X...X.X..X....X..",
".X....XX..X...............X.X.XXXX.",
"...XXXXX.....X...X....X.XX..XXX..X.",
".........X..XX....X.X......XXXX....",
"..XXXX.X..XXX.X...........X..X.XX..",
"X...X...........X..X.X..X.XX..X.X..",
"..X....X.....X..X.X....X..X.X..XXXX",
"X..XXX..X..XX.XX.X..X...X...X..X.XX",
"....X....X.X...X..X..X..XXX...XXXX.",
".X..XX.XX.....X..XX..............XX",
"X..........X..X......XXXX.....X..X.",
".X.XXX...X..X..XX.X.X.X.X..X.......",
"X....X.........X....XXXX..X....X..X",
"..X.XX...X......X.X.......XX....X..",
"X.XXXX....X.XXX..XX..XXXX.X.XX.....",
"XXX.X........X.X..X..X....X..X.....",
"......X..X..XX..X.....XX........X..",
"...X.....XX..X..X..X.X......XX..X.X",
"..X..X.......XX......X......X...XX.",
"..X.XX......XX.X..X.....X...X.X..X.",
".X.X.XX.XXX.X..X.X.................",
".......X.XX..X..X..X.....X.X..XX..X",
"X...XX.......X...X...X.X....X......",
"X.......X.X......X.X.X......X.....X",
"....X.X.X.X....XXX..XX.....XX.X..X.",
"...X..X.X.XX......X.....XX.XXXX....",
"..X......X...X.X...X...X.X.XXXX...X"}
{"..XX......X..XX.X....X..X.XX..X....",
"...X.X.X.......X..X....X...........",
".XXX.X.XXX.....X.X.X..XX.XX.X.XX.XX",
"X...X......X.X........X...X.X.....X",
"X.....X....X...XX....X.X........XX.",
"..XXX...XXX............X.XX..XX..XX",
"....X.X..X..X.X...X.X....X.XX...X..",
".XX..X........XX..X......XX..X....X",
"...X......X...X..X...XX...XXX..X.X.",
"..XX...X..X...X...X.XX.....X.....X.",
".XX.X........X..X..X......XX.X.XX..",
".X.X..XX..X.XX......X....X.........",
"X..X.X..X........X.....X..X..XX...X",
"X.X.........X.XXX..XX..X.........X.",
".........X......XX.....X.....X..X.X",
"X..X.X.XXX.X.....X...X...X...X..X.X",
"X......X..X.XX.X......X....XX.....X",
"X.X...................X...X..X..XX.",
".........X........X..XX..X......X.X",
".X....X.X.X.......X..XX..XX.XXX...X",
".................XXX...XX...X..X...",
"..X...X...XX.....X.....X..XX....XX.",
".......XXX.XX....X...XX..XXX.X....X",
"........X...XXXX..X..........X.....",
"..........XX.X.XX.X.........XX....X",
"...X.....X.X.................X....X",
"...XX.X.....X.....XXXX...X...X.X...",
".............X.....X..X..X.X.X..X..",
"...............X....X....X..X.X.X.X",
".XX..XX........X.....X.XX....X....X",
"...X....X..X...XXX..X........X.....",
"X.XXX.XX..X......XX.X......X.X.X...",
".XX.X....X..X..X.X.................",
"....XXX.X.X......XX.....XX...X.XX..",
"......X....XX..X.....X...XX.X.....X"}
Returns: 64
Submissions are judged against all 43 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Amoebae with a public method int cultureX(vector<string> known, vector<string> candidate) · 43 test cases · 2 s / 256 MB per case