{"task": {"agent_timeout": 600, "task": "230", "verifier_timeout": 7200, "instruction": "Please implement a Python 3 solution to the below problem.\nReason through the problem and:\n1. Restate the problem in plain English\n2. Conceptualize a solution first in plain English\n3. Write a pseudocode solution\n4. Save your solution as solution.py\nNo outside libraries are allowed.\n\n[BEGIN PROBLEM]\nProblem 2: Island Travels [Neal Wu, 2007]\n\nFarmer John has taken the cows to a vacation out on the ocean! The cows are\nliving on N (1 <= N <= 15) islands, which are located on an R x C grid (1\n<= R, C <= 50). An island is a maximal connected group of squares on the\ngrid that are marked as 'X', where two 'X's are connected if they share a\nside. (Thus, two 'X's sharing a corner are not necessarily connected.)\n\nBessie, however, is arriving late, so she is coming in with FJ by\nhelicopter. Thus, she can first land on any of the islands she chooses. She\nwants to visit all the cows at least once, so she will travel between\nislands until she has visited all N of the islands at least once.\n\nFJ's helicopter doesn't have much fuel left, so he doesn't want to use it\nuntil the cows decide to go home. Fortunately, some of the squares in the\ngrid are shallow water, which is denoted by 'S'. Bessie can swim through\nthese squares in the four cardinal directions (north, east, south, west) in\norder to travel between the islands. She can also travel (in the four\ncardinal directions) between an island and shallow water, and vice versa.\n\nFind the minimum distance Bessie will have to swim in order to visit all of\nthe islands. (The distance Bessie will have to swim is the number of\ndistinct times she is on a square marked 'S'.) After looking at a map of\nthe area, Bessie knows this will be possible.\n\nPROBLEM NAME: island\n\nINPUT FORMAT:\n\n* Line 1: Two space-separated integers: R and C.\n\n* Lines 2..R+1: Line i+1 contains C characters giving row i of the\n        grid. Deep water squares are marked as '.', island squares are\n        marked as 'X', and shallow water squares are marked as 'S'.\n\nSAMPLE INPUT:\n\n5 4\nXX.S\n.S..\nSXSS\nS.SX\n..SX\n\nINPUT DETAILS:\n\nThere are three islands with shallow water paths connecting some of them.\n\nOUTPUT FORMAT:\n\n* Line 1: A single integer representing the minimum distance Bessie\n        has to swim to visit all islands.\n\nSAMPLE OUTPUT:\n\n3\n\nOUTPUT DETAILS:\n\nBessie can travel from the island in the top left to the one in the middle,\nswimming 1 unit, and then travel from the middle island to the one in the\nbottom right, swimming 2 units, for a total of 3 units.\n\n[END PROBLEM]\n", "memory": "2048m", "runnable": false, "difficulty": "medium", "language": "", "cpus": 1, "instruction_truncated": false, "category": "python_programming", "compose": false, "has_solution": true, "oracle": null, "docker_image": "", "taskset": "usaco", "tags": ["python", "programming", "usaco"]}, "runs": []}