codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

965B.md (2248B)


      1 Source: https://codeforces.com/problemset/problem/965/B
      2 
      3 B. Battleship
      4 
      5 time limit per test
      6 
      7 1.5 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Arkady is playing Battleship. The rules of this game aren't really important.
     22 
     23 There is a field of $n \times n$ cells. There should be exactly one $k$-decker on the field, i. e. a ship that is $k$ cells long oriented either horizontally or vertically. However, Arkady doesn't know where it is located. For each cell Arkady knows if it is definitely empty or can contain a part of the ship.
     24 
     25 Consider all possible locations of the ship. Find such a cell that belongs to the maximum possible number of different locations of the ship.
     26 
     27 Input
     28 
     29 The first line contains two integers $n$ and $k$ ($1 \le k \le n \le 100$) — the size of the field and the size of the ship.
     30 
     31 The next $n$ lines contain the field. Each line contains $n$ characters, each of which is either '#' (denotes a definitely empty cell) or '.' (denotes a cell that can belong to the ship).
     32 
     33 Output
     34 
     35 Output two integers — the row and the column of a cell that belongs to the maximum possible number of different locations of the ship.
     36 
     37 If there are multiple answers, output any of them. In particular, if no ship can be placed on the field, you can output any cell.
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 4 3  
     45 #..#  
     46 #.#.  
     47 ....  
     48 .###
     49 ```
     50 
     51 Output
     52 
     53 ```
     54 3 2
     55 ```
     56 
     57 Input
     58 
     59 ```
     60 10 4  
     61 #....##...  
     62 .#...#....  
     63 ..#..#..#.  
     64 ...#.#....  
     65 .#..##.#..  
     66 .....#...#  
     67 ...#.##...  
     68 .#...#.#..  
     69 .....#..#.  
     70 ...#.#...#
     71 ```
     72 
     73 Output
     74 
     75 ```
     76 6 1
     77 ```
     78 
     79 Input
     80 
     81 ```
     82 19 6  
     83 ##..............###  
     84 #......#####.....##  
     85 .....#########.....  
     86 ....###########....  
     87 ...#############...  
     88 ..###############..  
     89 .#################.  
     90 .#################.  
     91 .#################.  
     92 .#################.  
     93 #####....##....####  
     94 ####............###  
     95 ####............###  
     96 #####...####...####  
     97 .#####..####..#####  
     98 ...###........###..  
     99 ....###########....  
    100 .........##........  
    101 #.................#
    102 ```
    103 
    104 Output
    105 
    106 ```
    107 1 8
    108 ```
    109 
    110 Note
    111 
    112 The picture below shows the three possible locations of the ship that contain the cell $(3, 2)$ in the first sample.
    113 
    114  ![](https://espresso.codeforces.com/05652ce3070abad78e4e07145851e9af67b548cb.png)