Forgot Password ?
New password will be sent to following email id
Problem Code : BOLT
2 5 8 --O-- -O--- O-O-- -OOO- --O-- 3 9 -O- -O- --O
14 14 4 16
Time Limit :
C , C++ , Java , Python 2
Login to submit your response.
<center> <span style="font-size: 48pt;">A Tale of Change</span> <br> <a class="atag" href="https://codebuddy.co.in/problems/COGS">Previous</a> • <b>Chapter 2</b> • <a class="atag" href="https://codebuddy.co.in/problems/MYSTERY">Next</a> <hr> <span style="font-size: 8pt;"> This problem is part of the series <b><i>A Tale of Change</i></b>. For feedback, you can message <a class="atag" href="https://codebuddy.co.in/users/Martijn">Martijn</a>. For new readers, it is recommended you start from <a class="atag" href="https://codebuddy.co.in/problems/COGS">Chapter 1</a>. </span> <hr> </center> <br><br> While the sun set, the wind slowly took up pace, and the clear sky radiated with dashes of deep orange and purple. As Keene pushed the wheelbarrow and felt the air move around his ears, he was thinking of nothing else than his crossbow. While it was not in perfect shape yet, he had secured and tested the lever the day before, and he was looking forward to testing it out tonight.<br>  "You can go ahead of me. Just pick something out of the crate for dinner, I'll catch up with you later."<br>  At the crossing to their home and the village center, Horick turned and took the other road. Looking at the large figure slowly disappearing over the hill, Keene put the wheelbarrow down and yawned. His father often wandered off after work, returning later in the night. It was likely he was going to the graveyard to visit his mother's grave. It had not been an easy year since she passed away, and Horick had been spending his evenings away more and more. Having dinner cooked properly became a rare occurence, and 'the crate', in which their bread, milk, eggs and cabbage was dropped off in the morning by their neighbour, was the place to grab food more often than not. <br><br> Keene took up the wheelbarrow and slowly strolled homeward. It had gotten dark by the time he reached their little wooden house, and after dropping the wheelbarrow by the steps at the door, he took the oil lamp hanging from a small pole in the front and walked around the house, over the dry grass, to the forge. He opened the wide door with a loud crack, grabbed a match from the slanted desk sitting against the wall, and lit the lantern after a quick stroke over the rough metal. The fire filled up the large room with light, highlighting the tool-filled walls and a square table with a crossbow lying in the middle. <br><br> Keene picked up the crossbow, letting the wooden grip rest on the palm of his hand comfortably.<br>  "WHAM!"<br>  A loud crack made Keene jump into the air.<br>  "Are you finally done with that?"<br>  That sharp voice was unmistakeable. Keene looked at the door that was just slammed open by a short but fierce silhouette. Amber, the village mayor's daughter, had just barged in. While she had clearly inherited her long golden hair from her parents, the same could not be said about her attitude. Water would be flowing upstream before Amber were ever as calm and composed as they were.<br>  "Let me try!", she commanded, and promptly grabbed the crossbow from Keene's hands.<br>  "Hey, careful, don't point that at me!", Keene objected while pushing the crossbow down. "You can aim it at the target over there", he said, pointing at a large piece of cloth hanging from the ceiling. "You call that a target?" Amber laughed. She had a point, Keene had merely drawn a number of rectangles around each other. "Alright, let's give a shot", she said as she pulled the lever and raised the crossbow to her shoulder. Amber then eagerly pulled the trigger and shot several rapid bolts at the cloth, which they pierce right through. "Wooh!" she exclaimed in euphoria. "How did I do?" <hr> The bolts went right through the cloth, so multiple bolts that hit at the same place only cause a single gap. Given the number of bolts Amber fired, and the places that they hit, can you determine her minimum and maximum score? <br><br> The number of points per bolt are determined by the maximum distance per dimension to the middle, where the border of the target has a score of 1. A bolt may also have missed, which gives a score of 0. For example, these are the scores for shooting the various places of a 7x7 cloth: <br><br> <table> <tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr> <tr><td>1</td><td>2</td><td>2</td><td>2</td><td>2</td><td>2</td><td>1</td></tr> <tr><td>1</td><td>2</td><td>3</td><td>3</td><td>3</td><td>2</td><td>1</td></tr> <tr><td>1</td><td>2</td><td>3</td><td>4</td><td>3</td><td>2</td><td>1</td></tr> <tr><td>1</td><td>2</td><td>3</td><td>3</td><td>3</td><td>2</td><td>1</td></tr> <tr><td>1</td><td>2</td><td>2</td><td>2</td><td>2</td><td>2</td><td>1</td></tr> <tr><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td><td>1</td></tr> </table> <br> The final score is the sum of scores of each bolt fired.
The first line contains a number <b>T</b>, the number of test cases. After that, <b>T</b> test cases follow. <br><br> Each test case begins with a line containing two space-separated integers <b>S</b>, the length of the sides of the target, and <b>N</b>, the number of bolts fired by Amber. Then, <b>S</b> lines follow, each containing a string of <b>S</b> characters, where each character is either '-', denoting an intact piece of cloth, or 'O' at spots where a bolt hit.
For each test case, print on a line two space-separated integers: the minimum and maximum score Amber could have gotten.
<ul> <li>1 ≤ <b>T</b> ≤ 10<sup>2</sup></li> <li>1 ≤ <b>S</b>, <b>N</b> ≤ 10<sup>2</sup></li> <li><b>S</b> is always odd</li> </ul>