=== Поля і каміння — пошук довгого простого шляху
Введіть кількість рядків N (1..100): Введіть кількість стовпців M (1..100): Ймовірність каменю в клітинці (0..1), наприклад 0.25: Часовий ліміт пошуку в секундах (наприклад 1.5): Якщо потрібно — згенерувати поле заново, якщо шляху немає? (т/н) [т]:
Згенероване поле (вирівняне):
# # # # . . . . . . . . . . . . . # . # . # . . .
. . # # . . . . . . . # . . . . # . # . # . . # .
. . . . . . . . . . . . . . . . . . . # . . . . .
# . . . . . # # . . . . . . # # . # # . . . . . #
. # . . . . . # . . . . . . . . . . . # # . . . #
. . . . # . . . . # . . . . . . . # # . . . . . .
. # # . # . . . # # . . . . . . # # . . . . . . .
# . . # . # . # . . . # . . . . . . . . . # . . .
. . . . . . # . . . . . . . # . . # # # . # . . .
. . . . . . . # . # . . . . # . . . # . . # . # .
. . . . . . . . . . . . . . # . # . . . . . . . .
. . . . . # # . . . # # . . . . . . . . # . # . .
. . . . . . # . . # # . # . . . . . # . . . . . .
. . . . # . . . # . # . . # . . # . . . . . . . .
# . # . . . # . . . . . . # # . # # . . . . . . .
. . . . . . . . . . . . # # . . . . # . . # . # .
. . . . . . . . # . # . . . . . . . . . . . # # .
. . . . . . . # # # . # . . . . . # . . . # . . .
. . . # . . . . . # . # . . # # . . . . . . . # .
. . . . . . # . . . . # . . . . . . # . . . . # .
. # # . . . # . . . . # . . . . . . # . . . # . .
. . . # . # . . . . # # . . # . # # # . . # . . .
. . . . . . # . . . . . . . . # . . . . # . . . .
. . . . . . . . # # . # . . . . . . # . . . . # .
. . . . # . . . # . . . . # . . # # # . . # . # .
Починаємо пошук найдовшого простого шляху (таймаут = 1.5 сек)...
Знайдений шлях довжиною 343 (0 = старт).
Карта з пронумерованим шляхом:
# # # # 240 241 . . . . . . . . . . . # . # . # . . 342
. . # # 239 242 243 246 247 252 253 # . . . . # . # . # 334 335 # 341
. 231 232 233 238 237 244 245 248 251 254 . 258 259 . . . . . # 332 333 336 339 340
# 230 229 234 235 236 # # 249 250 255 256 257 260 # # . # # . 331 330 337 338 #
. # 228 225 224 223 . # 218 217 216 215 214 261 . . . . . # # 329 328 327 #
. . 227 226 # 222 221 220 219 # 211 212 213 262 . . . # # . . 300 301 326 325
. # # . # . . . # # 210 209 208 263 264 . # # 294 295 298 299 302 323 324
# . . # . # . # 197 198 . # 207 206 265 266 291 292 293 296 297 # 303 322 .
. . . . . . # . 196 199 200 . 204 205 # 267 290 # # # . # 304 321 320
57 58 . . . . . # 195 # 201 202 203 . # 268 289 288 # . . # 305 # 319
56 59 60 87 88 89 90 91 194 191 190 189 188 . # 269 # 287 286 285 284 283 306 307 318
55 54 61 86 . # # 92 193 192 # # 187 186 . 270 271 272 273 274 # 282 # 308 317
52 53 62 85 84 83 # 93 . # # . # 185 184 181 180 179 # 275 . 281 310 309 316
51 50 63 64 # 82 . 94 # . # . . # 183 182 # 178 177 276 277 280 311 314 315
# 49 # 65 80 81 # 95 96 . . . . # # . # # 176 175 278 279 312 313 .
47 48 . 66 79 78 77 76 97 98 99 100 # # . 164 165 . # 174 . # . # .
46 45 44 67 70 71 74 75 # . # 101 102 159 160 163 166 167 168 173 172 . # # .
39 40 43 68 69 72 73 # # # . # 103 158 161 162 . # 169 170 171 # 143 142 141
38 41 42 # . 29 28 27 . # . # 104 157 # # . 151 150 149 . 145 144 # 140
37 36 35 34 31 30 # 26 25 . . # 105 156 155 154 153 152 # 148 147 146 . # 139
. # # 33 32 . # 23 24 . . # 106 . . . . . # . . . # 137 138
. . . # . # . 22 21 20 # # 107 . # . # # # . . # . 136 .
4 5 6 . . . # 17 18 19 110 109 108 117 118 # 124 125 126 127 # 133 134 135 .
3 2 7 10 11 12 15 16 # # 111 # 115 116 119 122 123 . # 128 131 132 . # .
0 1 8 9 # 13 14 . # . 112 113 114 # 120 121 # # # 129 130 # . # .
Кроки шляху (1-based координати):
[(25, 1), (25, 2), (24, 2), (24, 1), (23, 1), (23, 2), (23, 3), (24, 3), (25, 3), (25, 4), (24, 4), (24, 5), (24, 6), (25, 6), (25, 7), (24, 7), (24, 8), (23, 8), (23, 9), (23, 10), (22, 10), (22, 9), (22, 8), (21, 8), (21, 9), (20, 9), (20, 8), (19, 8), (19, 7), (19, 6), (20, 6), (20, 5), (21, 5), (21, 4), (20, 4), (20, 3), (20, 2), (20, 1), (19, 1), (18, 1), (18, 2), (19, 2), (19, 3), (18, 3), (17, 3), (17, 2), (17, 1), (16, 1), (16, 2), (15, 2), (14, 2), (14, 1), (13, 1), (13, 2), (12, 2), (12, 1), (11, 1), (10, 1), (10, 2), (11, 2), (11, 3), (12, 3), (13, 3), (14, 3), (14, 4), (15, 4), (16, 4), (17, 4), (18, 4), (18, 5), (17, 5), (17, 6), (18, 6), (18, 7), (17, 7), (17, 8), (16, 8), (16, 7), (16, 6), (16, 5), (15, 5), (15, 6), (14, 6), (13, 6), (13, 5), (13, 4), (12, 4), (11, 4), (11, 5), (11, 6), (11, 7), (11, 8), (12, 8), (13, 8), (14, 8), (15, 8), (15, 9), (16, 9), (16, 10), (16, 11), (16, 12), (17, 12), (17, 13), (18, 13), (19, 13), (20, 13), (21, 13), (22, 13), (23, 13), (23, 12), (23, 11), (24, 11), (25, 11), (25, 12), (25, 13), (24, 13), (24, 14), (23, 14), (23, 15), (24, 15), (25, 15), (25, 16), (24, 16), (24, 17), (23, 17), (23, 18), (23, 19), (23, 20), (24, 20), (25, 20), (25, 21), (24, 21), (24, 22), (23, 22), (23, 23), (23, 24), (22, 24), (21, 24), (21, 25), (20, 25), (19, 25), (18, 25), (18, 24), (18, 23), (19, 23), (19, 22), (20, 22), (20, 21), (20, 20), (19, 20), (19, 19), (19, 18), (20, 18), (20, 17), (20, 16), (20, 15), (20, 14), (19, 14), (18, 14), (17, 14), (17, 15), (18, 15), (18, 16), (17, 16), (16, 16), (16, 17), (17, 17), (17, 18), (17, 19), (18, 19), (18, 20), (18, 21), (17, 21), (17, 20), (16, 20), (15, 20), (15, 19), (14, 19), (14, 18), (13, 18), (13, 17), (13, 16), (14, 16), (14, 15), (13, 15), (13, 14), (12, 14), (12, 13), (11, 13), (11, 12), (11, 11), (11, 10), (12, 10), (12, 9), (11, 9), (10, 9), (9, 9), (8, 9), (8, 10), (9, 10), (9, 11), (10, 11), (10, 12), (10, 13), (9, 13), (9, 14), (8, 14), (8, 13), (7, 13), (7, 12), (7, 11), (6, 11), (6, 12), (6, 13), (5, 13), (5, 12), (5, 11), (5, 10), (5, 9), (6, 9), (6, 8), (6, 7), (6, 6), (5, 6), (5, 5), (5, 4), (6, 4), (6, 3), (5, 3), (4, 3), (4, 2), (3, 2), (3, 3), (3, 4), (4, 4), (4, 5), (4, 6), (3, 6), (3, 5), (2, 5), (1, 5), (1, 6), (2, 6), (2, 7), (3, 7), (3, 8), (2, 8), (2, 9), (3, 9), (4, 9), (4, 10), (3, 10), (2, 10), (2, 11), (3, 11), (4, 11), (4, 12), (4, 13), (3, 13), (3, 14), (4, 14), (5, 14), (6, 14), (7, 14), (7, 15), (8, 15), (8, 16), (9, 16), (10, 16), (11, 16), (12, 16), (12, 17), (12, 18), (12, 19), (12, 20), (13, 20), (14, 20), (14, 21), (15, 21), (15, 22), (14, 22), (13, 22), (12, 22), (11, 22), (11, 21), (11, 20), (11, 19), (11, 18), (10, 18), (10, 17), (9, 17), (8, 17), (8, 18), (8, 19), (7, 19), (7, 20), (8, 20), (8, 21), (7, 21), (7, 22), (6, 22), (6, 23), (7, 23), (8, 23), (9, 23), (10, 23), (11, 23), (11, 24), (12, 24), (13, 24), (13, 23), (14, 23), (15, 23), (15, 24), (14, 24), (14, 25), (13, 25), (12, 25), (11, 25), (10, 25), (9, 25), (9, 24), (8, 24), (7, 24), (7, 25), (6, 25), (6, 24), (5, 24), (5, 23), (5, 22), (4, 22), (4, 21), (3, 21), (3, 22), (2, 22), (2, 23), (3, 23), (4, 23), (4, 24), (3, 24), (3, 25), (2, 25), (1, 25)]