Bomberman


Submit solution

Points: 10
Time limit: 5.0s
Memory limit: 256M

Author:
Problem types
Allowed languages
C#, Go, Java

Al joc Bomberman, quan explota una bomba, totes les caselles que estan a la mateixa fila o la mateixa columna exploten.

Si la bomba explota a la casella 6, exploten totes les casellas a la mateixa fila o columna:

Input Format

La entrada consta en primer lloc del tamany del tauler: \(N\) files i \(M\) columnes.

A continuació ve el tauler: cada nombre indica l'identificador de la casella.

L'últim nombre \(X\) és l'identificador de la casella en la què explota la bomba.

Constraints

-

Output Format

S'haurà de mostrar el tauler resultant en explotar les caselles.

Les caselles que no han explotat es marcaran amb un # i les que han explotat amb una @

Seguint l'exemple proposat, el tauler resultant quedaria així:

##@#
##@#
@@@@
##@#

Test Case 1

Input
3  3
  6  7  4
  5  1  3
  2  8  9
4
Output
@@@
##@
##@

Test Case 2

Input
3  3
  2  5  3
  9  6  1
  8  7  4
6
Output
#@#
@@@
#@#

Test Case 3

Input
4  4
 10 15 12  7
  4  9 16 11
  8 13  5  6
  1  2  3 14
3
Output
##@#
##@#
##@#
@@@@

Test Case 4

Input
4  4
 10  1  2 15
  5 13 16  4
  8  7  3 11
  6 12 14  9
3
Output
##@#
##@#
@@@@
##@#

Test Case 5

Input
5  5
  8  5 22 20 16
  9  3 25  6 18
 17 24  4 10 15
  2 21 13 19 23
 12  1 14  7 11
25
Output
##@##
@@@@@
##@##
##@##
##@##

Test Case 6

Input
7  7
 39 40 37 29 20 18 26
 45 17 38 13 23 33 27
 34 31 35 36 42 49 22
 48  5 12 11 43  9 14
  1  7 16  4  6 44 41
 10 25  3 46  8 32 19
 47 24 30 28 15 21  2
25
Output
#@#####
#@#####
#@#####
#@#####
#@#####
@@@@@@@
#@#####

Test Case 7

Input
12  12
  28   2  35 116 123 125 102  73 141  46 142  60
  76 128  69  15  23 109  51 138  20  29 103  39
  21 106  74  27 130  72 113  87  40  77 110 140
 108  81  95  41 105  66  45  58 139 101  17   7
  43  63  65  33  83 127  82 104  16 126  62 136
 144 119  55 129 143  37  56  78  24 114  36  84
 134 107  18  54  11 135 117  59   9  19 120  57
 121  34  96  75   6   1  90 131  48  80  42  67
   8  14   4  88   3  71  94 118  98  52  32  50
  22  53  70  31  99 111  91 112 124  10 100 132
  13 133  30  97  38  49  26 115   5 122  86  92
  93  64  25  47  61  89 137  44  79  85  12  68
26
Output
######@#####
######@#####
######@#####
######@#####
######@#####
######@#####
######@#####
######@#####
######@#####
######@#####
@@@@@@@@@@@@
######@#####

Test Case 8

Input
15  15
  53  34 117 150  57  15 188 111  60 223 204 196 225   7  61
 127 148 128 116 172 178  94 152 174 164 121  36  66 144  50
  87  68  83 191 184  26 221 139 107  71  86  48 130 203 187
 176  95 126  58 115  29  92  76  44 213  88 162  14 177 132
  19 151 207 157 222   6 198 179 105  65  59 171   9  39 149
 193 131  52  17 217  98 158 160 129 100  63 212 120  23  32
  99  82 145 125  77 210  28 119   2 173 118  55  37 189 103
 161 206  62 136 142  78 154 194 124  49  25  47  91 165 214
 166  43  54 218 134 122  69 141  74   8  79 202  73  41 109
 146 216 133 147  10 114  21 156 163 183 201 135 170  80   5
  56 186 106  40  85  84 104 169  30 195 185 200 197  11   3
 123 155 112  46 140 199 137 209   1  16 215  20  93  27  33
  81  38  51  96 182 192  72  13 208  42 180  45 138  75  89
 205 113 219 153  18   4  90  35 224 168 211 181 108  67  22
  97 175  31 220 159 101 190  64  70 102  24  12 143 167 110
204
Output
@@@@@@@@@@@@@@@
##########@####
##########@####
##########@####
##########@####
##########@####
##########@####
##########@####
##########@####
##########@####
##########@####
##########@####
##########@####
##########@####
##########@####

Test Case 9

Input
20  20
  89 381 342 173  14 388 197 214  36 351 307 304 275  87 209 125 331 391  10  28
 300  16 112  44  33 233 113 249 375 263 185 132  76 181  64  51 227 192 292 178
 355 322 177 324 143  41 205 202 259  48  63 191 296  17 317 271  67 140 279  46
 270 166  13 218  83  47 264   7 278 199 281 124 282  42 318 213 145 361 228 184
 226   5 120 290 133 262 287 396 103 111 325 305 126 115 168 360 158 379 377 170
 301  66 272  57 138 366  55 332  39 284 251 222 389 349 245  34 219 386   8 220
 150 109 210 373 267 161   9 293 229  84 303 344  62 254 314 394 242 260 280  70
 368  81 155  22 291  85 174 319  11 239  68 142 385  43  24 130  97 253  99 372
 243 122 104 364 189 286  27 393 100  61  26 354  75 208 206 110 171 146 234  96
 248 252 316 235 117 346 238 356  40 308 183 362 384 250  82 400 343 321  71 144
 190  92 157  54 134  18 241 306 370 196 337 141 320  15 390 256  65  56   6 357
  72  58 295 247  21 246 382 397 398 365 221 162 119 273 294  73 383  86 328 330
  37 165  59  32 336 310  80 288 266 151 289 123   2  60 268 193 399 309  29  94
 327  49 129 179 255 347 108 139 299  45 180 367 156 211 186 153 277 149 207 244
 315 198 334 159  20 374 371 326 201  88 323 380 224 387 127 182  69 225 333 114
 203 363 353 172 359 340 136 154 369 352 285 236 276 169  93  30 376 195  90  53
  25  98   4 200 237 223 231 269 329 358 230 338 131 232 339  78 175 107 298 378
 265 101 160 163  12  31 176 341 152 297 102  95 137 395 188 187 261 128 106 311
 350 335 348 283 121 204 212 274 257 148 258 147  50 167  74 216 215 105 313  19
  52 240 345 135  38  35 302 116   3 217  77  79 312 164  91 118 194  23   1 392
269
Output
#######@############
#######@############
#######@############
#######@############
#######@############
#######@############
#######@############
#######@############
#######@############
#######@############
#######@############
#######@############
#######@############
#######@############
#######@############
#######@############
@@@@@@@@@@@@@@@@@@@@
#######@############
#######@############
#######@############

Test Case 10

Input
1  1
   1
1
Output
@

Test Case 11

Input
11  17
 182 116   5  64  32  42   9  60  94  57  21 173   2  46   3  44  59
 124  84  34  95  62 100  69 176 126  67 146 139 112  12 127 166 147
  30  86 159 144 145  88 123 104 149 128  26 157 134 143  68 151 142
  78 136 158  54 140 154  81 171  36 185  10  53 153  87 178  98  90
  27  16  33 107  91 141  48  85  15  55 125  65 163  23 135  38 115
  97 132 111 122 184  49  31 169 155  13  40  56  39 186 161  74 105
 118 117  66 102 120 160 130 174 131 152 150 114  47 170  45  29  17
  70  99 106 172 113 175  92  73  93 168   7 137  75  19  35 103 187
 101  58 181  89 177 133  82  11 164  51  50  79   8 167  20   1   6
  22  72 110 121  18  28 109 129  96  41 108 162  76 156  24  80  83
  63 148 165   4  61 119  71  37  25  14 180 179  77 183  43 138  52
10
Output
##########@######
##########@######
##########@######
@@@@@@@@@@@@@@@@@
##########@######
##########@######
##########@######
##########@######
##########@######
##########@######
##########@######

Test Case 12

Input
2  2
   4   1
   2   3
4
Output
@@
@#

Authorship: Gerard Falcó

CC BY-NC-SA 4.0