{"id":343264,"date":"2022-12-27T21:00:17","date_gmt":"2022-12-27T21:00:17","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=343264"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=343264","title":{"rendered":"<span>\u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0435\u0440\u0430 (TSP) \u0442\u043e\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043c\u0435\u0442\u043e\u0434 \u0432\u0435\u0442\u0432\u0435\u0439 \u0438 \u0433\u0440\u0430\u043d\u0438\u0446<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/592\/454\/ca0\/592454ca03b8381d59084d2e72685653.png\" width=\"780\" height=\"440\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/592\/454\/ca0\/592454ca03b8381d59084d2e72685653.png\"\/><figcaption><\/figcaption><\/figure>\n<blockquote>\n<p><em>\u041f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u0432 \u0442\u044b\u0441\u044f\u0447\u0443 \u043b\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u0448\u0430\u0433\u0430. (\u041b\u0430\u043e-\u0426\u0437\u044b)<\/em><\/p>\n<\/blockquote>\n<p>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u0445\u043e\u0440\u043e\u0448\u0438\u043c? \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u043e\u0442\u0432\u0435\u0442\u044f\u0442: \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043a\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d, \u043b\u0435\u0433\u043a\u043e \u0447\u0438\u0442\u0430\u0435\u043c \u0438 \u043f\u043e\u043d\u044f\u0442\u0435\u043d. \u041d\u043e \u0442\u0430\u043a \u043b\u0438 \u0432\u0430\u0436\u043d\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439? \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u043d\u0435 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u0430, \u0445\u043e\u0442\u044f \u0438 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u0430. \u041d\u043e \u0435\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438, \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u043e\u043b\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u043e, \u0447\u0442\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u043c\u0438\u043d\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0434 \u0432\u0441\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>\u042f \u0433\u043e\u0432\u043e\u0440\u044e \u043f\u0440\u043e NP-\u0442\u0440\u0443\u0434\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 (NP-\u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044c &#8212; \u043d\u0435\u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438) \u0438 \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0445\u043e\u0447\u0443 \u0430\u043a\u0446\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435. \u0417\u0430\u0434\u0430\u0447\u0435 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0435\u0440\u0430.<\/p>\n<p>\u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0433\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u043e\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u0432 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u0437\u0430 \u0447\u0438\u0441\u043b\u043e \u0448\u0430\u0433\u043e\u0432 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u043e\u043b\u0438\u043d\u043e\u043c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/701458\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435<\/a> \u043c\u044b \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0435\u0440\u0430 \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041c\u0435\u0442\u043e\u0434 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043d\u043e \u043e\u043d \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u043e\u0431\u044a\u0451\u043c\u043e\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0423\u0436\u0435 \u043f\u0440\u0438 n = 28 \u0432\u0435\u0440\u0448\u0438\u043d, 16 \u0413\u0431 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u0436\u0451\u0441\u0442\u043a\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u0430 \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0445\u0438\u0442\u0440\u043e\u0443\u043c\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0441\u0436\u0430\u0442\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043d\u043e \u043d\u0435\u043d\u0430\u043c\u043d\u043e\u0433\u043e. \u041d\u0443\u0436\u0435\u043d \u0438\u043d\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 \u0432\u0435\u0442\u0432\u0435\u0439 \u0438 \u0433\u0440\u0430\u043d\u0438\u0446, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0441\u0430\u043c\u044b\u0439 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430. \u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u0442\u0443\u0442 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438, \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0445 \u043c\u0430\u043d\u0443\u0430\u043b\u043e\u0432\u00a0\u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438. \u0414\u043b\u044f \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e <a href=\"http:\/\/galyautdinov.ru\/post\/zadacha-kommivoyazhera\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u0433\u0434\u0435, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0432\u0441\u0451 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c. <\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u0432 \u0441\u0432\u043e\u0451 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044f\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043c\u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/246437\/\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0431\u043e\u0442\u0430<\/a>. \u041a\u0430\u043a \u0438 \u0435\u0451 \u0430\u0432\u0442\u043e\u0440, \u044f \u043f\u0440\u043e\u0448\u0451\u043b \u0442\u043e\u0442 \u0436\u0435 \u043f\u0443\u0442\u044c, \u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u043b \u0440\u043e\u0432\u043d\u043e \u0442\u0435 \u0436\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043d\u0430\u0447\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0438. \u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0439 <a href=\"https:\/\/habr.com\/ru\/post\/332208\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0434\u0445\u043e\u0434<\/a>.<\/p>\n<hr\/>\n<p>\u0425\u043e\u0447\u0443 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430 \u0432\u0435\u0442\u0432\u0435\u0439 \u0438 \u0433\u0440\u0430\u043d\u0438\u0446, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u0430\u043b\u043e \u043a\u0442\u043e \u043e\u0441\u0432\u0435\u0449\u0430\u0435\u0442: <\/p>\n<p>\u041d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u0434\u0432\u0430 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1 (\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0440\u0435\u0431\u0440\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0448\u0442\u0440\u0430\u0444\u043e\u043c) \u0438 M2 (\u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0435\u0431\u0440\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0448\u0442\u0440\u0430\u0444\u043e\u043c), \u043f\u0440\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1 \u0432\u044b\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u0435\u043c \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0438\u0435\u0441\u044f \u043a \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043a\u043b\u0435\u0442\u043a\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0441\u0442\u043e\u043b\u0431\u0435\u0446, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u043d\u0430 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u041d\u043e \u0432\u043e\u0442 \u0447\u0442\u043e \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u043f\u043e\u043d\u044f\u0442\u0438\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430? \u0412\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445, \u0447\u0442\u043e \u044f \u0432\u0438\u0434\u0435\u043b, \u0441\u043c\u044b\u0441\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d \u043d\u0435 \u0432\u0435\u0440\u043d\u043e, \u043f\u0440\u043e\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7fa\/7ae\/ed6\/7fa7aeed65e29fd94eff360455c91d34.png\" width=\"454\" height=\"442\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7fa\/7ae\/ed6\/7fa7aeed65e29fd94eff360455c91d34.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u0433\u0440\u0430\u0444, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u044d\u0442\u0430\u043f\u0430\u0445 \u043c\u044b \u0443\u0436\u0435 \u043d\u0430\u0448\u043b\u0438 \u0440\u0451\u0431\u0440\u0430 [0, 3], [3, 5], [6, 7], [7, 1] \u0438 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0440\u0435\u0431\u0440\u043e [5, 6] \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1. <\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0434\u043b\u044f \u0440\u0435\u0431\u0440\u0430 [5, 6], \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0440\u0435\u0431\u0440\u043e [6, 5] (\u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c), \u0430 \u0440\u0435\u0431\u0440\u043e [1, 0]. \u0418 \u0432\u044b\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0431\u0440\u043e \u0437\u0430\u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0432 \u0433\u0440\u0430\u0444\u0435 \u043f\u043e\u0434\u0446\u0438\u043a\u043b. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u044b \u0442\u0430\u043a \u0436\u0435 \u0432\u044b\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0434\u0443\u0433\u0438, \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0438\u0437 [5] (\u0432\u044b\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438) \u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432 [6] (\u0432\u044b\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0430).<\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442, \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0433\u043e\u043b\u043e\u0432\u0443 \u0438 \u0445\u0432\u043e\u0441\u0442 \u043f\u0443\u0442\u0438, \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0431\u0440\u043e \u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0435\u0434\u0438\u043d\u0443\u044e \u0432\u0435\u0442\u0432\u044c \u0438 \u0443\u0436\u0435 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u0432\u0437\u044f\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<p>\u0418\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0433\u043e \u0444\u0430\u043a\u0442\u0430 \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u0432\u043e\u0434\u0438\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0431\u043e\u0440 \u0432 \u0442\u0443\u043f\u0438\u043a, \u043f\u0440\u043e \u0442\u043e\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u043e\u043b\u0447\u0443.<\/p>\n<hr\/>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u043e \u0445\u043e\u0434\u0443 \u0442\u0435\u043a\u0441\u0442\u0430 \u044f \u0431\u0443\u0434\u0443 \u0432\u044b\u0434\u0432\u0438\u0433\u0430\u0442\u044c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043e\u043c\u0443-\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u043f\u043e\u0440\u043d\u044b\u043c\u0438, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0435 \u0437\u0430 \u0444\u0430\u043a\u0442.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0433\u0440\u0430\u043d\u0438\u0446 \u043f\u0440\u0438 \u043f\u043e\u043b\u043d\u043e\u043c \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0435 \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043d\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0447\u0435\u0440\u0442\u0430: \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f. \u041c\u044b \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0434\u0435\u043b\u0438\u043c \u0434\u0435\u0440\u0435\u0432\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043d\u0430 \u0434\u0432\u0430 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430, \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u043f\u043b\u044e\u0441 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u044e\u0434\u0430 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e \u0438 \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u0445 \u0434\u0435\u0440\u0435\u0432\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0439 \u044d\u0442\u043e \u043e\u0433\u0440\u043e\u043c\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u041c\u0430\u043b\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0442\u044c, \u0442\u0430\u043a \u0435\u0449\u0451 \u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0440\u0430\u0437\u043d\u044b\u043c \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u0435\u0448\u0451\u0432\u043e\u0435 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435.<\/p>\n<p>\u0410\u0432\u0442\u043e\u0440\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u043d\u0435 \u043a\u0430\u043a \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e, \u0430 \u043a\u0430\u043a \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u0443\u044e.<\/p>\n<p>\u0412\u0441\u044f \u0441\u0443\u0442\u044c \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043a\u043b\u043e\u043d\u044f\u0435\u043c\u0441\u044f \u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u041b\u0438\u0442\u043b\u043e\u043c, \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0448\u0430\u0433\u043e\u0432 \u043f\u0440\u0438 \u043e\u0431\u0445\u043e\u0434\u0435 \u0434\u0435\u0440\u0435\u0432\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0439, \u043d\u043e \u0437\u0430\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u044f \u0438\u0437-\u0437\u0430 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u0438\u0445 \u0448\u0430\u0433\u043e\u0432.<\/p>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0442\u0440\u0451\u0445 \u043c\u0435\u0442\u0430 \u0448\u0430\u0433\u043e\u0432: <\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b (\u0440\u0435\u0434\u0443\u043a\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a, \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432), \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0446\u0435\u043d\u043a\u043e\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1 \u0438\u043b\u0438 M2, <strong>\u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0432 M1<\/strong>, \u043f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u043c \u0434\u043d\u0430. \u0412 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043d\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u043f\u043e\u0440\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043b\u0443\u0447\u0448\u0435\u0435 \u0441 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0435\u0433\u043e, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u043a\u043e\u0440\u043e\u0447\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u044b\u0448\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e M2 \u0438 \u0432\u044b\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u0435\u043c \u043a\u043b\u0435\u0442\u043a\u0443. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0448\u0430\u0433\u0443 1.<\/p>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u044e\u0441\u044c \u043d\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0441\u0440\u043e\u0447\u043d\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u043e\u0431\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0435\u0442\u0432\u0438 \u0434\u0435\u0440\u0435\u0432\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0439, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0432 \u043e\u0431\u044a\u0451\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.<\/p>\n<ul>\n<li>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0448\u0430\u0433\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u0432 \u043a\u0430\u043a\u0443\u044e-\u043b\u0438\u0431\u043e \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0438\u043b\u0438 \u0438\u0437 \u043d\u0435\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430;<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c \u0448\u0430\u0433\u0435, \u0435\u0441\u043b\u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u0438\u0437 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u043a\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u043c\u0435\u043d\u044c\u0448\u0435 \u043d\u0438\u0436\u043d\u0435\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u044b;<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u0448\u0430\u0433\u0435, \u0435\u0441\u043b\u0438 \u043b\u0443\u0447\u0448\u0438\u0439 \u0438\u0437 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u043a\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u043c\u0435\u043d\u044c\u0448\u0435 \u0441\u0443\u043c\u043c\u044b \u043d\u0438\u0436\u043d\u0435\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0446\u0435\u043d\u043a\u0438 \u043d\u0430 \u0448\u0430\u0433\u0435;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0ae\/623\/138\/0ae6231387f7330b104eb5e4a4dd208a.png\" alt=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1\" title=\"\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1\" width=\"461\" height=\"692\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0ae\/623\/138\/0ae6231387f7330b104eb5e4a4dd208a.png\"\/><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1<\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0441\u0435\u0431\u044f \u043d\u0430\u0437\u0432\u0430\u043b \u043f\u043e\u0434\u0445\u043e\u0434 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u043d\u044b\u0440\u044f\u043b\u044c\u0449\u0438\u043a\u0430. \u0423\u0436 \u0431\u043e\u043b\u044c\u043d\u043e \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043c\u043d\u0435, \u043a\u0430\u043a \u043e\u0445\u043e\u0442\u043d\u0438\u043a \u0437\u0430 \u0436\u0435\u043c\u0447\u0443\u0433\u043e\u043c \u043d\u044b\u0440\u044f\u0435\u0442 \u043d\u0430 \u0434\u043d\u043e, \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0440\u0430\u043a\u043e\u0432\u0438\u043d\u0443, \u043e\u0442\u043f\u043b\u044b\u0432\u0430\u0435\u0442 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443, \u0441\u043d\u043e\u0432\u0430 \u043d\u044b\u0440\u044f\u0435\u0442. \u0414\u043d\u043e \u0432\u043e\u0434\u043e\u0451\u043c\u0430 \u043d\u0435 \u0440\u043e\u0432\u043d\u043e\u0435, \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f. \u0423 \u043f\u043b\u043e\u0432\u0446\u0430 \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u0451\u0432\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442 \u0434\u043e \u043d\u0430\u0442\u044f\u0436\u0435\u043d\u0438\u044f, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u0430\u043a \u043d\u044b\u0440\u044f\u043b\u044c\u0449\u0438\u043a \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 \u0434\u043d\u0430. \u0418 \u0442\u0430\u043a \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043e\u043d \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0442\u044c \u0434\u043d\u0430, \u043a\u0440\u043e\u043c\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430, \u0447\u0442\u043e \u0438 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c, \u043a \u0447\u0435\u043c\u0443 \u044d\u0442\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438? \u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u043c\u044b \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f \u043e\u0442 \u0445\u0432\u043e\u0441\u0442\u043e\u0432\u043e\u0439 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u043f\u0440\u0438 \u0440\u0430\u0441\u0447\u0451\u0442\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u041c2 \u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e \u0433\u043b\u0443\u0431\u0438\u043d\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0434\u043b\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0441\u0438\u0442 n. <\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0449\u0451 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0444\u043e\u043a\u0443\u0441 \u0441 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0441\u0442\u0435\u043a\u0435, \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u043a\u0443\u0447\u0435 (\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u0443 \u041e\u0421 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u0440\u043e\u0433\u043e), \u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0438\u0434\u0430\u0442\u044c \u0441\u0432\u0435\u0440\u0445\u0431\u044b\u0441\u0442\u0440\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c L1 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0430\u0441\u043d\u0443\u044e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c, \u043d\u0443 \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 \u041e\u0421.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 n = 33 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 63\u041a\u0411 \u0441\u0442\u0435\u043a\u0430, \u043f\u0440\u0438 \u043b\u044e\u0431\u044b\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0418\u0437 \u043f\u0440\u043e\u0447\u0438\u0445 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439: <\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043e\u0434\u043d\u0438\u043c \u043a\u0443\u0441\u043a\u043e\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u044d\u0442\u043e \u0437\u0434\u043e\u0440\u043e\u0432\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u0440\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e 32 \u0431\u0438\u0442\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e, \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 (\u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435);<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u0432 inf = 2147483647 (0x7fffffff), \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c);<\/p>\n<\/li>\n<li>\n<p>\u0423\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u043a\u0430\u0437 \u043e\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u0435\u043b\u0435\u043d\u0438\u044f (\u043e\u0447\u0435\u043d\u044c \u0434\u043e\u0440\u043e\u0433\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f);<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u044e\u0442 \u0431\u044b\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u044d\u0442\u0430\u043f \u0440\u0435\u0434\u0443\u043a\u0446\u0438\u0438 \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f, \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0435;<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0437\u0430 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0445\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430: \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0440\u0435\u0434\u0443\u043a\u0446\u0438\u0438 \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0435 \u0438 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u043e \u0442\u043e\u0439 \u0436\u0435 \u0441\u0442\u0440\u043e\u043a\u0435 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043d\u0443\u043b\u0435\u0439.\u00a0 \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e two_lows, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0434\u0432\u0430 \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0430 \u0437\u0430 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0445\u043e\u0434, \u0447\u0442\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u0432\u0434\u0432\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438 \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b\u0441\u044f \u043d\u0430 Pascal, \u0437\u0430\u0442\u0435\u043c \u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u043d\u0430 \u0421\u0438 \u0438 \u0432\u043d\u0451\u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u041f\u0430\u0441\u043a\u0430\u043b\u044e, \u0434\u043e\u0431\u0438\u0432\u0448\u0438\u0441\u044c \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0434\u0432\u0443\u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0448\u0430\u0433. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0432 Pathon \u043e\u0431\u0435\u0440\u043d\u0443\u043b \u0432 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u0436\u0435 \u043d\u0430 \u043d\u0435\u0439.<\/p>\n<details class=\"spoiler\">\n<summary>\u0414\u043b\u044f \u0441\u0430\u043c\u044b\u0445 \u043b\u044e\u0431\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041a\u043e\u0434 \u0432\u043d\u0435\u0448\u043d\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0438 \u043d\u0430 \u0421\u0438<\/p>\n<pre><code class=\"cpp\">\/\/======================================================================= \/\/ \u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0435\u0440\u0430 (TSP) \u0442\u043e\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043c\u0435\u0442\u043e\u0434 \u0432\u0435\u0442\u0432\u0435\u0439 \u0438 \u0433\u0440\u0430\u043d\u0438\u0446 (by ReBuilder) \/\/ https:\/\/habr.com\/ru\/post\/708072\/ \/\/======================================================================= const unsigned int inf = 0x7fffffff;  \/\/ 2147483647  typedef struct TVector {     unsigned int src;     unsigned int dest; } TVector;  typedef struct TMatrixObj {     unsigned int global_min;  \/\/ \u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0440\u0430\u0441\u0447\u0451\u0442\u0430     unsigned int n;           \/\/ \u0420\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0442\u0440\u0438\u0446\u044b     unsigned int step;        \/\/ \u0428\u0430\u0433 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430     TVector *v;               \/\/ \u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u0440\u0451\u0431\u0435\u0440 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435 [\u043e\u0442\u043a\u0443\u0434\u0430, \u043a\u0443\u0434\u0430]     TVector *v_best;          \/\/ \u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432, \u043b\u0443\u0447\u0448\u0438\u0439 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 [\u043e\u0442\u043a\u0443\u0434\u0430, \u043a\u0443\u0434\u0430] } TMatrixObj;  void matrix_evaluation(struct TMatrixObj *m, unsigned int *pm, unsigned int index, unsigned int n); \/\/======================================================================= \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0434\u0432\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e void two_lows(unsigned int *a, unsigned int *b, unsigned int c) {     if (c &lt;= *a)     {         *b = *a;         *a = c;     }     else         if (c &lt; *b)             *b = c; } \/\/======================================================================= void matrix_reduction(unsigned int *pm, unsigned int n, unsigned int *max_sum, unsigned int *max_i, unsigned int *max_j) {     unsigned int sum = 0;      \/\/ \u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u043c \u043a\u0435\u0448 \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0447\u0451\u0442\u0430 \u0432\u0435\u0441\u0430 \u0441\u0442\u0440\u043e\u043a\u0438     unsigned int line_cache[n + 1];      \/\/ \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043c\u0438\u043d\u0438\u043c\u0443\u043c     for (unsigned int i = 1; i &lt; n; i++)     {         unsigned int min1 = pm[i * n + 1];         unsigned int min2 = inf;         two_lows(&amp;min1, &amp;min2, pm[i * n + 2]);          for (unsigned int j = 3; j &lt; n; j++)             two_lows(&amp;min1, &amp;min2, pm[i * n + j]);          \/\/ \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u044c \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u043e\u0432 \u0442\u043e \u043e\u0431\u0440\u044b\u0432\u0430\u0435\u043c \u0440\u0430\u0441\u0447\u0451\u0442         if (min1 == inf)         {             pm[0] = inf;             return;         }          \/\/ \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 (\u0420\u0435\u0434\u0443\u043a\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a)         if (min1 > 0)         {             if (min2 &lt; inf)                 min2 -= min1;              for (unsigned int j = 1; j &lt; n; j++)             if (pm[i * n + j] &lt; inf)                 pm[i * n + j] -= min1;             \/\/ \u041f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043a \u043d\u0438\u0436\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u0435             sum += min1;         }         line_cache[i] = min2;     }      *max_sum = 0;     *max_i = inf;      \/\/ \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043c\u0438\u043d\u0438\u043c\u0443\u043c     for (unsigned int i = 1; i &lt; n; i++)     {         unsigned int min1 = pm[1 * n + i];         unsigned int min2 = inf;         two_lows(&amp;min1, &amp;min2, pm[2 * n + i]);          for (unsigned int j = 3; j &lt; n; j++)             two_lows(&amp;min1, &amp;min2, pm[j * n + i]);          \/\/ \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u044c \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0432\u0445\u043e\u0434\u043e\u0432 \u0442\u043e \u043e\u0431\u0440\u044b\u0432\u0430\u0435\u043c \u0440\u0430\u0441\u0447\u0451\u0442         if (min1 == inf)         {             pm[0] = inf;             return;         }          if (min1 > 0)         {             if (min2 &lt; inf)                 min2 -= min1;              \/\/ \u0412\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430 (\u0420\u0435\u0434\u0443\u043a\u0446\u0438\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432)             \/\/ \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f, \u0438 \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u043e\u0446\u0435\u043d\u043a\u0443             unsigned int temp_val;             for (unsigned int j = 1; j &lt; n; j++)             {                 temp_val = pm[j * n + i];                 if (temp_val &lt; inf)                 {                     temp_val -= min1;                     pm[j * n + i] = temp_val;                     if (temp_val == 0)                     {                         temp_val = line_cache[j] + min2;                         if (temp_val >= *max_sum)                         {                             *max_sum = temp_val;                             *max_i = j;                             *max_j = i;                         }                     }                 }             }              \/\/ \u041f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u043a \u043d\u0438\u0436\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u0435             sum += min1;          }         else         {             \/\/ \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f, \u0438 \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u043e\u0446\u0435\u043d\u043a\u0443             unsigned int temp_val;             for (unsigned int j = 1; j &lt; n; j++)                 if (pm[j * n + i] == 0)                 {                     temp_val = line_cache[j] + min2;                     \/\/ \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u043e\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u043e\u0432 \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0435 \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0443                     if (temp_val >= *max_sum)                     {                         *max_sum = temp_val;                         *max_i = j;                         *max_j = i;                     }                 }         }     }      \/\/ \u041d\u0438\u0436\u043d\u044f\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 - \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043c\u0430\u0440\u0448\u0440\u0443\u0442     \/\/ \u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f, \u0442\u043e \u0431\u043b\u043e\u0447\u0438\u043c \u0432\u0435\u0442\u043a\u0443     if (*max_i == inf)         pm[0] = inf;     else         pm[0] += sum; } \/\/======================================================================= int head_search(unsigned int *pm, struct TVector *v, unsigned int n, unsigned int index, unsigned int dj) {     unsigned int l = 0;     do     {         if (v[l].src == dj)         {             dj = v[l].dest;             l = 0;             continue;         }         l++;     } while (l &lt; index);      for (l = 1; l &lt; n; l++)         if (pm[l * n + 0] == dj)             break;     return l; } \/\/======================================================================= int tail_search(unsigned int *pm, struct TVector *v, unsigned int n, unsigned int index, unsigned int di) {     unsigned int l = 0;     do     {         if (v[l].dest == di)         {             di = v[l].src;             l = 0;             continue;         }         l++;     } while (l &lt; index);      for (l = 1; l &lt; n; l++)         if (pm[0 * n + l] == di)             break;     return l; } \/\/======================================================================= void martix_in_depth(struct TMatrixObj *m, unsigned int *pm, unsigned int n, unsigned int index, unsigned int di, unsigned int dj) {     unsigned int new_matrix[n * n];     \/\/ \u041a\u043e\u043f\u0438\u0440\u0443\u0435\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430     {         unsigned int *src = pm;         unsigned int *dest = new_matrix;         for (unsigned int i = 0; i &lt;= n; i++)         {             if (i == di)             {                 src += n + 1;                 continue;             }             for (unsigned int j = 0; j &lt;= n; j++)             {                 if (j == dj)                 {                     src++;                     continue;                 }                 *dest++ = *src++;             }         }     }          if (n > 3)     {         \/\/ \u0417\u0430\u043f\u0440\u0435\u0449\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u0432 \u0443\u0436\u0435 \u043f\u0440\u043e\u0439\u0434\u0435\u043d\u043d\u044b\u0435 \u0443\u0437\u043b\u044b \u0433\u0440\u0430\u0444\u0430.         \/\/ \u0427\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u043e\u0434\u0446\u0438\u043a\u043b\u044b \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u044b\u0445 \u0440\u0451\u0431\u0435\u0440 \u0438\u0449\u0435\u043c \u0433\u043e\u043b\u043e\u0432\u0443 \u0438 \u0445\u0432\u043e\u0441\u0442 \u0446\u0435\u043f\u043e\u0447\u0435\u043a,         \/\/ \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0431\u0440\u043e \u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0435\u0434\u0438\u043d\u0443\u044e \u0432\u0435\u0442\u0432\u044c.         \/\/ \u0414\u043b\u044f \u043d\u0430\u0439\u0434\u0435\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0438\u0449\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0435 \u0438\u043d\u0434\u0435\u043a\u0441\u044b         unsigned int i = head_search(new_matrix, m->v, n, index, m->v[index].dest);         unsigned int j = tail_search(new_matrix, m->v, n, index, m->v[index].src);         \/\/ \u0417\u0430\u043d\u0443\u043b\u044f\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430.         \/\/ \u0414\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u0433\u0434\u0430!!!         new_matrix[i * n + j] = inf;     }     else if (n == 2)     {         \/\/ \u0415\u0441\u043b\u0438 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442         new_matrix[0] += new_matrix[3];          \/\/ \u0415\u0441\u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0448\u0435\u0435 \u0438\u0437 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445, \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0435\u0433\u043e         if (new_matrix[0] &lt; m->global_min)         {             m->global_min = new_matrix[0];             for (unsigned int i = 0; i &lt;= index; i++)             {                m->v_best[i].src = m->v[i].src;                m->v_best[i].dest = m->v[i].dest;             }             \/\/memcpy(m->v_best, m->v, (m->n-1) * sizeof(TVector));             m->v_best[index + 1].src = new_matrix[1 * n + 0];             m->v_best[index + 1].dest = new_matrix[0 * n + 1];         }         return;     }     \/\/ \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u0440\u0430c\u0447\u0451\u0442 \u0434\u043b\u044f \u0441\u043b\u043e\u044f \u043d\u0438\u0436\u0435     matrix_evaluation(m, new_matrix, index + 1, n); } \/\/======================================================================= void matrix_evaluation(struct TMatrixObj *m, unsigned int *pm, unsigned int index, unsigned int n) {     unsigned int max_sum, max_i, max_j;     do     {         m->step++;         \/\/ \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f, \u0438 \u0432\u0435\u0440\u0445\u043d\u044e\u044e \u043e\u0446\u0435\u043d\u043a\u0443         matrix_reduction(pm, n, &amp;max_sum, &amp;max_i, &amp;max_j);         \/\/ \u0415\u0441\u043b\u0438 \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0433\u043e \u043f\u0443\u0442\u0438, \u0442\u043e \u0431\u043b\u043e\u0447\u0438\u043c \u0432\u0435\u0442\u043a\u0443         if (pm[0] >= inf)             return;          \/\/ \u0420\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u041c1         \/\/ \u0415\u0441\u043b\u0438 \u043b\u0443\u0447\u0448\u0438\u0439 \u0438\u0437 \u043d\u0430\u0439\u0434\u0435\u043d\u044b\u0445 \u043f\u043e\u043a\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u0436\u043d\u0435\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u044b,         \/\/ \u0442\u043e \u0432\u044b\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435         if (m->global_min > pm[0])         {             \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u0432 \u0432\u0435\u043a\u0442\u043e\u0440 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430             m->v[index].src = pm[max_i * n + 0];             m->v[index].dest = pm[0 * n + max_j];             \/\/ \u041f\u043e\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0441\u043b\u043e\u0439 \u043d\u0438\u0436\u0435             martix_in_depth(m, pm, n - 1, index, max_i, max_j);         }         \/\/ \u0420\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u041c2         \/\/ \u0418\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0443\u043d\u043a\u0442 \u0438\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430         pm[max_i * n + max_j] = inf;         \/\/ \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u0443\u044e \u043e\u0446\u0435\u043d\u043a\u0443 \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0447\u0435\u0440\u043a\u0430 \u0432\u0435\u0440\u0448\u0438\u043d\u044b (\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u041c2)         \/\/ \u0422\u0430\u043a \u043a\u0430\u043a \u0445\u0432\u043e\u0441\u0442\u043e\u0432\u0430\u044f \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f \u0434\u043e\u0440\u043e\u0436\u0435 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0438, \u043e\u0444\u043e\u0440\u043c\u043b\u044f\u0435\u043c \u0446\u0438\u043a\u043b     }     while (m->global_min >= pm[0] + max_sum); } \/\/=======================================================================   #ifdef __cplusplus extern \"C\" { #endif     int tsp_branch(unsigned int n, int *p)     {         if ((n &lt; 2) || (n > 64))            return 0;          struct TMatrixObj m;         m.n = n;         struct TVector v_best[n];         struct TVector v[n - 1];         m.v = v;         m.v_best = v_best;         unsigned int work_matrix[(n + 1) * (n + 1)];          \/\/-----------------------------------------------------------------------         \/\/ \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043f\u0435\u0440\u0432\u0438\u0447\u043d\u0443\u044e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0440\u0430\u0431\u043e\u0447\u0435\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u044b         m.global_min = inf;         m.step = 0;         work_matrix[0] = 0;         for (unsigned int i = 1; i &lt; m.n + 1; i++)         {             work_matrix[i * (m.n + 1) + 0] = i;             work_matrix[0 * (m.n + 1) + i] = i;         }         {             int *src = p;             for (unsigned int i = 1; i &lt; m.n + 1; i++)                 for (unsigned int j = 1; j &lt; m.n + 1; j++, src++)                     if ((i != j)&amp;&amp;(*src >= 0))                         work_matrix[i * (m.n + 1) + j] = *src;                     else                         work_matrix[i * (m.n + 1) + j] = inf;         }         \/\/-----------------------------------------------------------------------         \/\/ \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0440\u0430\u0441\u0447\u0451\u0442         matrix_evaluation(&amp;m, work_matrix, 0, m.n + 1);         \/\/-----------------------------------------------------------------------         \/\/ \u0412\u044b\u0432\u043e\u0434 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430         if (m.global_min &lt; inf)         {             p[0] = m.global_min;             p[1] = m.step;             unsigned int v_result[n];               for (unsigned int i = 0; i &lt; n; i++)             {                 v_result[v_best[i].src - 1] = v_best[i].dest;             }              unsigned int j = 0;             for (unsigned int i = 2; i &lt; m.n + 1; i++)             {                 p[i] =  v_result[j] - 1;                 j = v_result[j] - 1;             }             p[n + 1] = 0;             return n + 2;         }         else         {             return 0;         }         \/\/-----------------------------------------------------------------------     } #ifdef __cplusplus } #endif<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 \u043d\u0430 Python<\/p>\n<pre><code class=\"python\">from ctypes import * import numpy as np import random import matplotlib.pyplot as plt import networkx as nx from datetime import datetime #------------------------------------------------------------------------------------ def distance(x1, y1, x2, y2):     return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5 #------------------------------------------------------------------------------------ def tsp_branch(n, py_arr, lib):     if n &lt; 2:         return {}     flatten_arr =  list(np.concatenate(py_arr).flat)     l = [-1] * (n * n - len(flatten_arr))     flatten_arr = (flatten_arr + l)[:n * n:]     int_arr =  (c_int  * (n * n))(*flatten_arr)           res = lib.tsp_branch(n, byref(int_arr))     if res > 0:         l = list(int_arr)[:res:]         return {'len' : l.pop(0), 'steps' : l.pop(0), 'path' : l}     else:         return {} #------------------------------------------------------------------------------------ lib_c = cdll.LoadLibrary(r\"tsp_branch.dll\") lib_c.tsp_branch.argtypes = [c_int, c_void_p] lib_c.tsp_branch.restype = c_int #------------------------------------------------------------------------------------ INF = -1  #random.seed(1)  n = 26  v1 = [] points = {} for i in range(n):     points[i] = (random.randint(1, 10000), random.randint(1, 10000))  input_matrix = [] for i, vi in points.items():      m1 = []     for j, vj in points.items():         if i == j:              m1.append(INF)         else:             m1.append(int(distance(vi[0], vi[1], vj[0], vj[1])))             v1.append([i, j, int(distance(vi[0], vi[1], vj[0], vj[1]))])     input_matrix.append(m1.copy())   plt.figure(figsize=(6, 6))  graph = nx.Graph() graph.add_nodes_from(points)   # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0443\u0433\u0438 \u0432 \u0433\u0440\u0430\u0444 for i in v1:     graph.add_edge(i[0], i[1], weight=i[2]) #----------------------------------------------------------------- start_time = datetime.now() res1 = tsp_branch(n, input_matrix, lib_c) print(datetime.now() - start_time)  print('min_len =', res1['len'], ', steps =', res1['steps'], res1['path'])  if 'path' in res1:     d1 = []     for i, v in enumerate(res1['path']):         d1.append([res1['path'][i-1], res1['path'][i]]) #----------------------------------------------------------------- # \u0420\u0438\u0441\u0443\u0435\u043c \u0432\u0441\u0451 \u0434\u0440\u0435\u0432\u043e nx.draw(graph, points, width=0.5, edge_color=\"#C0C0C0\", with_labels=True) nx.draw(graph, points, width=3, edge_color=\"red\", edgelist=d1, style=\"-\")<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043c\u0435\u0442\u043e\u0434 \u0432\u0435\u0442\u0432\u0435\u0439 \u0438 \u0433\u0440\u0430\u043d\u0438\u0446 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u043e\u0445\u0430\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c, \u0438 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0447\u0435\u043d\u044c \u0441\u0438\u043b\u044c\u043d\u043e \u0432\u0430\u0440\u044c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0442 \u043d\u0430\u0431\u043e\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0411\u044b\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0434\u0435\u043d\u0430 \u0441\u0435\u0440\u0438\u044f \u0438\u0441\u043f\u044b\u0442\u0430\u043d\u0438\u0439 \u043d\u0430 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0435 \u0442\u043e\u0447\u0435\u043a \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432\u0435\u0440\u0448\u0438\u043d \u0433\u0440\u0430\u0444\u0430. \u041a\u0430\u0436\u0434\u0430\u044f \u0441\u0435\u0440\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043b\u0430 \u0438\u0437 \u0442\u044b\u0441\u044f\u0447\u0438 \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0431\u043e\u0440\u043e\u0432.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b6d\/cb7\/0c2\/b6dcb70c2319753e6708e38e25bd7ce4.png\" alt=\"\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u0441\u0435\u043a) \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b - \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0448\u043a\u0430\u043b\u0430\" title=\"\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u0441\u0435\u043a) \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b - \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0448\u043a\u0430\u043b\u0430\" width=\"674\" height=\"390\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b6d\/cb7\/0c2\/b6dcb70c2319753e6708e38e25bd7ce4.png\"\/><figcaption>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f (\u0441\u0435\u043a) \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b &#8212; \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0448\u043a\u0430\u043b\u0430<\/figcaption><\/figure>\n<p>\u0413\u0440\u0430\u0444\u0438\u043a\u0438 \u0431\u044b\u043b\u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u044b \u043f\u043e 99, 98, 95 \u0438 90 \u043f\u0435\u0440\u0446\u0435\u043d\u0442\u0438\u043b\u044f\u043c \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0433\u0440\u0430\u0444\u0430 \u0438 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445. 99 \u043f\u0435\u0440\u0446\u0435\u043d\u0442\u0438\u043b\u044c \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u0439\u0434\u0451\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u0432 99 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0438\u0437 \u0441\u0442\u0430, \u0437\u0430 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0434\u043b\u044f \u043f\u043e\u0445\u043e\u0436\u0435\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041a\u0430\u043a \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u043e\u0434\u0445\u043e\u0434 \u043d\u0435 \u043f\u0430\u043d\u0430\u0446\u0435\u044f, \u043d\u043e \u043f\u0440\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0434\u0430\u0451\u0442 \u0432\u0435\u0441\u044c\u043c\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b.<\/p>\n<p>\u041a\u0430\u043a \u0431\u043e\u043d\u0443\u0441 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0441\u0435\u0431\u044f \u0447\u0443\u0432\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0430 \u043d\u0435 \u043f\u043e\u043b\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u0445 (\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0441\u0432\u044f\u0437\u0438 \u0437\u0430\u0434\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0438\u043b\u0438 inf), \u0430 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430 \u043d\u0435 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0445 \u043c\u0430\u0442\u0440\u0438\u0446\u0430\u0445. \u041f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u043e\u0441\u043e\u0431\u043e \u0432\u0430\u0436\u043d\u043e \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u0447 \u0442\u0440\u0430\u043d\u0441\u043f\u043e\u0440\u0442\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u043a\u0438, \u0433\u0434\u0435 \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u0442\u043e\u0447\u043a\u0443 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u043d\u0435 \u0440\u0430\u0432\u043d\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438, \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0434\u043e\u0440\u043e\u0433\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043e\u0434\u043d\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/6a2\/bb4\/f37\/6a2bb4f37ac9653e7afcfb6d3cbb1b0f.png\" alt=\"\u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\" title=\"\u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\" width=\"519\" height=\"451\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/6a2\/bb4\/f37\/6a2bb4f37ac9653e7afcfb6d3cbb1b0f.png\"\/><figcaption>\u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c<\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e \u043c\u0438\u043d\u0443\u0441\u0430\u0445, \u0445\u043e\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u0435\u0440\u0435\u0432\u0430\u0440\u0438\u0432\u0430\u0435\u0442 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043b\u044e\u0431\u044b\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043d\u043e \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u0445 \u0434\u0435\u043b\u0430\u0435\u0442 \u044d\u0442\u043e \u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0442\u0430\u043a\u0438\u0445 \u044d\u0442\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9a9\/eb6\/e6e\/9a9eb6e6ef50791e30e8b335268405ac.png\" alt=\"\u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\" title=\"\u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\" width=\"677\" height=\"402\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9a9\/eb6\/e6e\/9a9eb6e6ef50791e30e8b335268405ac.png\"\/><figcaption>\u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c<\/figcaption><\/figure>\n<details class=\"spoiler\">\n<summary>\u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c <\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import random import matplotlib.pyplot as plt import networkx as nx import numpy as np import copy  from ctypes import * from datetime import datetime #-----------------------------------------------------------------  def distance(x1, y1, x2, y2):     return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5 #-----------------------------------------------------------------      def tsp_branch(n, py_arr, lib):     if n &lt; 2:         return {}     flatten_arr =  list(np.concatenate(py_arr).flat)     l = [-1] * (n * n - len(flatten_arr))     flatten_arr = (flatten_arr + l)[:n * n:]     int_arr =  (c_int  * (n * n))(*flatten_arr)           res = lib.tsp_branch(n, byref(int_arr))     if res > 0:         l = list(int_arr)[:res:]         return {'len' : l.pop(0), 'steps' : l.pop(0), 'path' : l}     else:         return {} #-----------------------------------------------------------------  #random.seed(1) n = 7 INF = -1 #-----------------------------------------------------------------  v1 = [] points = {} for i in range(n):     points[i] = (random.randint(1,1000), random.randint(1,1000))  input_matrix = [] for i, vi in points.items():      m1 = []     for j, vj in points.items():         if i==j:              m1.append(INF)         else:             m1.append(round(distance(vi[0], vi[1], vj[0], vj[1])))             v1.append([i,j,round(distance(vi[0], vi[1], vj[0], vj[1]))])     input_matrix.append(m1.copy())  #-----------------------------------------------------------------  lib = cdll.LoadLibrary(r\"tsp_branch.dll\") lib.tsp_branch.argtypes = [c_int, c_void_p] lib.tsp_branch.restype = c_int  plt.figure(figsize=(5, 5)) graph = nx.Graph() graph.add_nodes_from(points)   # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0443\u0433\u0438 \u0432 \u0433\u0440\u0430\u0444 for i in v1:     graph.add_edge(i[0], i[1], weight=i[2]) #-----------------------------------------------------------------   # \u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u043e\u0440\u0430 \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0443\u043c start_time = datetime.now() res1 = tsp_branch(n, input_matrix, lib) date_diff = (datetime.now() - start_time).total_seconds() print(date_diff)  print(res1['len'], res1['steps'], res1['path']) if 'path' in res1:     d1 = []     for i, v in enumerate(res1['path']):         d1.append([res1['path'][i-1], res1['path'][i]])                 #----------------------------------------------------------------- # \u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u043e\u0440\u0430 \u043d\u0430 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c input_matrix_max = copy.deepcopy(input_matrix) for i in range(len(input_matrix_max)):     for j in range(len(input_matrix_max)):         if i != j:             input_matrix_max[i][j] = 1000 - input_matrix_max[i][j]  start_time = datetime.now()                                                   res2 = tsp_branch(n, input_matrix_max, lib) date_diff = (datetime.now() - start_time).total_seconds() print(date_diff)  res2['len'] = 0 for i, val in enumerate(res2['path']):     res2['len'] += input_matrix[res2['path'][i-1]][res2['path'][i]]    print(res2['len'], res2['steps'], res2['path'])   if 'path' in res2:     d2 = []     for i, v in enumerate(res2['path']):         d2.append([res2['path'][i-1], res2['path'][i]]) # -----------------------------------------------------------------         nx.draw(graph, points, width=1, edge_color=\"#C0C0C0\", with_labels=True) nx.draw(graph, points, width=2, edge_color=\"blue\", edgelist=d1, style=\"-\")  nx.draw(graph, points, width=2, edge_color=\"red\", edgelist=d2, style=\"-\")<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0425\u043e\u0442\u044c \u044f \u0438 \u043e\u0431\u043e\u0436\u0430\u044e Python, \u043d\u043e \u0434\u043b\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0451\u043c\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447 \u043e\u043d \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e, \u0434\u0430\u0436\u0435 \u0441 numpy. \u041f\u0440\u0438\u0432\u043e\u0436\u0443 \u043f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u043d\u043d\u0435\u0439 \u043d\u0430\u0438\u0432\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 pandas \u0447\u0438\u0441\u0442\u043e \u0432 \u0446\u0435\u043b\u044f\u0445 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432, \u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043a\u043e\u0433\u043e-\u0442\u043e \u043f\u043e\u0434\u0432\u0438\u0433\u043d\u0435\u0442 \u043d\u0430 \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435.<\/p>\n<details class=\"spoiler\">\n<summary>Python<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"python\">import pandas as pd import numpy as np import random import matplotlib.pyplot as plt import networkx as nx  import sys if not sys.warnoptions:     import warnings     warnings.simplefilter(\"ignore\")  pd.set_option('display.max_rows', 500) pd.set_option('display.max_columns', 500) pd.set_option('display.width', 1000) #------------------------------------------------------------------------------------ def distance(x1, y1, x2, y2):     return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5 #------------------------------------------------------------------------------------ def in_deep_matrix(p, y, x):     # \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043d\u043e\u0432\u0443\u044e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0437\u0430 \u0432\u044b\u0447\u0438\u0442\u043e\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430     return p.drop([y], axis = 0).drop([x], axis = 1) #------------------------------------------------------------------------------------ def reduction_matrix(p):     # \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0434\u0443\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043d\u0438\u0436\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443     bottom_line = 0          # \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u0435\u0433\u043e     for index, row in p.iterrows():         min = row.min()               if np.isinf(min):             return np.inf                 bottom_line += min         for key, value in row.iteritems():              p[key][index] -= min      # \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u0443 \u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u0435\u0433\u043e     for key, value in p.iteritems():          min = value.min()         if np.isinf(min):             return np.inf              bottom_line += min         for index, row in value.iteritems():             p[key][index] -= min      return bottom_line #------------------------------------------------------------------------------------ def partition_matrix(p):     # \u0418\u0449\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043d\u0430 m1 \u0438 m2     # \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043e\u0446\u0435\u043d\u043a\u0443 \u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u044b     max_sum = 0     index_i = None     index_j = None     for index, row in p.iterrows():         for key, value in p.iteritems():             if p[key][index] == 0:                 min_i = np.inf                 min_j = np.inf                  for k, v in p[key].items():  # \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0435\u0446\u0443                     if k != index and v &lt; min_i:                         min_i = v                  for k, v in p.loc[index].items():                     if k != key and v &lt; min_j:                         min_j = v                                          l = min_i + min_j                 if l > max_sum:                     max_sum = l                     index_i = index                     index_j = key                      return [index_i, index_j, max_sum] #------------------------------------------------------------------------------------ def reverse_index(l, i, j):     # \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u043e\u0431\u0440\u044b\u0442\u043d\u044b\u0439 \u0438\u043d\u0434\u0435\u043a\u0441 \u0434\u043b\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b         def in_dict(d, v):         while v in d:             v = d[v]         return v          ln = len(l)     d1 = {l[k][0]: l[k][1] for k in range(0, ln, 1)}     d2 = {l[k][1]: l[k][0] for k in range(0, ln, 1)}     return [in_dict(d1, i), in_dict(d2, j)]  #------------------------------------------------------------------------------------ def evaluation_matrix(p, res, bottom_line):     # \u041e\u0446\u0435\u043d\u043a\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u043f\u043e\u0438\u0441\u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044f     if len(p) == 1:               res['steps'] += 1         bottom_line += p.iat[0, 0]           # \u0415\u0441\u043b\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0448\u0435, \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0435\u0433\u043e         if bottom_line &lt; res['global_min']:             res['global_min'] = bottom_line             res['local_result'].append([p.index[0], p.columns[0]])                    res['best_result'] = res['local_result'].copy()             print('\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0448\u0435:', bottom_line, res['best_result'], '\u0448\u0430\u0433: ', res['steps'])                  return          # \u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u0440\u0435\u0434\u0443\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u0443\u044e \u043d\u0438\u0436\u043d\u044e\u044e \u0433\u0440\u0430\u043d\u0438\u0446\u0443     bottom_line += reduction_matrix(p)     if np.isinf(bottom_line):         return          max_sum = 0     while True:         res['steps'] += 1         # \u041d\u0430\u0445\u043e\u0434\u0438\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 m1 \u0438 m2         i, j, max_sum = partition_matrix(p)          # \u0411\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0442 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f         if i is None:             return          v_len = len(res['local_result'])         # \u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c m1 (\u0441\u043e\u0433\u043b\u0430\u0448\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0435 \u043f\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443)         if bottom_line &lt; res['global_min']:             res['local_result'].append([i, j])             p1 = in_deep_matrix(p, i, j)             # \u0412\u044b\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0435\u043c 2\u04452, \u0447\u0442\u043e\u0431 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c inf             if len(p1) > 2:                  i_reverse, j_reverse = reverse_index(res['local_result'], i, j)                          p1[j_reverse][i_reverse] = np.inf             evaluation_matrix(p1, res, bottom_line)          # \u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c m2          if res['global_min'] &lt; bottom_line + max_sum:             return         p[j][i] = np.inf  # \u0418\u0441\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442         res['local_result'] = res['local_result'][:v_len]  # \u041e\u0431\u0440\u0435\u0437\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0443\u0442\u0438          #------------------------------------------------------------------------------------       def return_res(res):     l = res['best_result']     if l:         d = {l[k][0]: l[k][1] for k in range(len(l))}         li =[]         a = l[0][0]         for v in range(len(l)):             li.append(a)             a = d[a]         return li     else:         return [] #------------------------------------------------------------------------------------ #random.seed(1) n = 13  v1 = [] points = {} for i in range(n):     points[i] = (random.randint(1,1000), random.randint(1,1000))  input_matrix = [] for i, vi in points.items():      m1 = []     for j, vj in points.items():         if i==j:              m1.append(np.inf)         else:             m1.append(int(distance(vi[0], vi[1], vj[0], vj[1])))             v1.append([i,j,int(distance(vi[0], vi[1], vj[0], vj[1]))])     input_matrix.append(m1.copy())       plt.figure(figsize=(6, 6)) graph = nx.Graph() graph.add_nodes_from(points)   # \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0443\u0433\u0438 \u0432 \u0433\u0440\u0430\u0444 for i in v1:     graph.add_edge(i[0], i[1], weight=i[2])  f1 = pd.DataFrame(input_matrix)  print(f1) # \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 res = {'global_min':np.inf, 'best_result': [], 'local_result':[], 'steps':0} # \u0417\u0430\u043f\u0443\u0441\u043a \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f evaluation_matrix(f1, res, 0)  print('\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:', res['global_min'], return_res(res), '\u0432\u0441\u0435\u0433\u043e \u0448\u0430\u0433\u043e\u0432:', res['steps'])  # \u0420\u0438\u0441\u0443\u0435\u043c \u0432\u0441\u0451 \u0434\u0440\u0435\u0432\u043e nx.draw(graph, points, width=1, edge_color=\"#C0C0C0\") # \u0420\u0438\u0441\u0443\u0435\u043c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0443\u0442\u044c nx.draw_networkx(graph, points, with_labels=True, edgelist=res['best_result'], arrows=True, edge_color=\"blue\", width=5)<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u042f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u043d\u0430\u0434 \u0434\u0430\u043d\u043d\u044b\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u0431\u043e\u043b\u0435\u0435 \u0442\u0440\u0451\u0445 \u043b\u0435\u0442 \u043d\u0430\u0435\u0437\u0434\u0430\u043c\u0438. \u041f\u0440\u043e\u0435\u043a\u0442, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0430\u043b\u0441\u044f \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0432 \u0434\u0430\u043b\u0451\u043a\u043e\u043c \u043f\u0440\u043e\u0448\u043b\u043e\u043c, \u043d\u043e \u043c\u043d\u0435 \u0434\u0443\u043c\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0443\u0442 \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b \u043c\u043e\u0438 \u043d\u0430\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u043e\u043f\u0440\u0438\u0449\u0435.<\/p>\n<p>\u0411\u0443\u0434\u0443 \u0440\u0430\u0437 \u043e\u0442\u043a\u043b\u0438\u043a\u0430\u043c, \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f\u043c, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f\u043c, \u0432\u043e\u0437\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c.<\/p>\n<p>\u041a\u043e\u0434, \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u043a \u0441\u0442\u0430\u0442\u044c\u0435, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u043d \u0432\u0430\u0448\u0438\u043c \u043f\u043e\u043a\u043e\u0440\u043d\u044b\u043c \u0441\u043b\u0443\u0433\u043e\u0439 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432\u0430\u043c\u0438 \u043f\u043e\u0434 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0435\u0439 GNU GPL.<\/p>\n<p>P.S. C \u041d\u0430\u0441\u0442\u0443\u043f\u0430\u044e\u0449\u0438\u043c \u041d\u043e\u0432\u044b\u043c \u0433\u043e\u0434\u043e\u043c!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/708072\/\"> https:\/\/habr.com\/ru\/post\/708072\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<blockquote>\n<p><em>\u041f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u0435 \u0432 \u0442\u044b\u0441\u044f\u0447\u0443 \u043b\u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u0448\u0430\u0433\u0430. (\u041b\u0430\u043e-\u0426\u0437\u044b)<\/em><\/p>\n<\/blockquote>\n<p>\u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u0445\u043e\u0440\u043e\u0448\u0438\u043c? \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u0432 \u043e\u0442\u0432\u0435\u0442\u044f\u0442: \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u043a\u043e\u0434 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d, \u043b\u0435\u0433\u043a\u043e \u0447\u0438\u0442\u0430\u0435\u043c \u0438 \u043f\u043e\u043d\u044f\u0442\u0435\u043d. \u041d\u043e \u0442\u0430\u043a \u043b\u0438 \u0432\u0430\u0436\u043d\u043e \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u0434\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0439? \u0412 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0435 \u0437\u0430\u0434\u0430\u0447 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u043d\u0435 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u0430, \u0445\u043e\u0442\u044f \u0438 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u0430. \u041d\u043e \u0435\u0441\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0438, \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0442\u043e\u043b\u044c \u043e\u0433\u0440\u043e\u043c\u043d\u043e, \u0447\u0442\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0448 \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0434\u043e\u043c\u0438\u043d\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0434 \u0432\u0441\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c.<\/p>\n<p>\u042f \u0433\u043e\u0432\u043e\u0440\u044e \u043f\u0440\u043e NP-\u0442\u0440\u0443\u0434\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 (NP-\u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044c &#8212; \u043d\u0435\u0434\u0435\u0442\u0435\u0440\u043c\u0438\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0442\u0440\u0443\u0434\u043d\u043e\u0441\u0442\u044c \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438) \u0438 \u043d\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u0445\u043e\u0447\u0443 \u0430\u043a\u0446\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435. \u0417\u0430\u0434\u0430\u0447\u0435 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0435\u0440\u0430.<\/p>\n<p>\u041c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0433\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u043e\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u0432 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u0437\u0430 \u0447\u0438\u0441\u043b\u043e \u0448\u0430\u0433\u043e\u0432 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u043e\u043b\u0438\u043d\u043e\u043c \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440\u0430 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/post\/701458\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435<\/a> \u043c\u044b \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0438\u0441\u044c \u0441 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0435\u0440\u0430 \u043d\u0430 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041c\u0435\u0442\u043e\u0434 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439, \u043d\u043e \u043e\u043d \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d \u043e\u0431\u044a\u0451\u043c\u043e\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0423\u0436\u0435 \u043f\u0440\u0438 n = 28 \u0432\u0435\u0440\u0448\u0438\u043d, 16 \u0413\u0431 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u0436\u0451\u0441\u0442\u043a\u043e\u0433\u043e \u0434\u0438\u0441\u043a\u0430 \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0445\u0438\u0442\u0440\u043e\u0443\u043c\u043d\u044b\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044b \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0441\u0436\u0430\u0442\u0438\u044f \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c, \u043d\u043e \u043d\u0435\u043d\u0430\u043c\u043d\u043e\u0433\u043e. \u041d\u0443\u0436\u0435\u043d \u0438\u043d\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434, \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0431\u043e\u043b\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 \u0432\u0435\u0442\u0432\u0435\u0439 \u0438 \u0433\u0440\u0430\u043d\u0438\u0446, \u043f\u043e\u0436\u0430\u043b\u0443\u0439, \u0441\u0430\u043c\u044b\u0439 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0439 \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430. \u041d\u0435 \u0431\u0443\u0434\u0435\u043c \u0442\u0443\u0442 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0435\u0433\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438, \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u044b\u0445 \u043c\u0430\u043d\u0443\u0430\u043b\u043e\u0432\u00a0\u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438. \u0414\u043b\u044f \u043d\u043e\u0432\u0438\u0447\u043a\u043e\u0432 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e <a href=\"http:\/\/galyautdinov.ru\/post\/zadacha-kommivoyazhera\" rel=\"noopener noreferrer nofollow\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u0433\u0434\u0435, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0432\u0441\u0451 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u043c \u044f\u0437\u044b\u043a\u043e\u043c. <\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u0432 \u0441\u0432\u043e\u0451 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044f\u043c\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043c\u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u0430 <a href=\"https:\/\/habr.com\/ru\/post\/246437\/\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0431\u043e\u0442\u0430<\/a>. \u041a\u0430\u043a \u0438 \u0435\u0451 \u0430\u0432\u0442\u043e\u0440, \u044f \u043f\u0440\u043e\u0448\u0451\u043b \u0442\u043e\u0442 \u0436\u0435 \u043f\u0443\u0442\u044c, \u0438 \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u043b \u0440\u043e\u0432\u043d\u043e \u0442\u0435 \u0436\u0435 \u043e\u0448\u0438\u0431\u043a\u0438, \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u043b\u0430\u0441\u044c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u043d\u0430\u0447\u0430\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u0438. \u0415\u0449\u0451 \u043e\u0434\u0438\u043d \u043b\u044e\u0431\u043e\u043f\u044b\u0442\u043d\u044b\u0439 <a href=\"https:\/\/habr.com\/ru\/post\/332208\/\" rel=\"noopener noreferrer nofollow\">\u043f\u043e\u0434\u0445\u043e\u0434<\/a>.<\/p>\n<hr\/>\n<p>\u0425\u043e\u0447\u0443 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \u0442\u043e\u043d\u043a\u043e\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430 \u0432\u0435\u0442\u0432\u0435\u0439 \u0438 \u0433\u0440\u0430\u043d\u0438\u0446, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u0430\u043b\u043e \u043a\u0442\u043e \u043e\u0441\u0432\u0435\u0449\u0430\u0435\u0442: <\/p>\n<p>\u041d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0432\u044b\u0431\u043e\u0440\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 \u0434\u0432\u0430 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1 (\u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0440\u0435\u0431\u0440\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0448\u0442\u0440\u0430\u0444\u043e\u043c) \u0438 M2 (\u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0440\u0435\u0431\u0440\u043e \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0448\u0442\u0440\u0430\u0444\u043e\u043c), \u043f\u0440\u0438 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1 \u0432\u044b\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u0435\u043c \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0438\u0435\u0441\u044f \u043a \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u043a\u043b\u0435\u0442\u043a\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 \u0438 \u0441\u0442\u043e\u043b\u0431\u0435\u0446, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438 \u043d\u0430 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u044c.<\/p>\n<p>\u041d\u043e \u0432\u043e\u0442 \u0447\u0442\u043e \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0434 \u043f\u043e\u043d\u044f\u0442\u0438\u0435\u043c \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430? \u0412\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445, \u0447\u0442\u043e \u044f \u0432\u0438\u0434\u0435\u043b, \u0441\u043c\u044b\u0441\u043b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0440\u0430\u0436\u0435\u043d \u043d\u0435 \u0432\u0435\u0440\u043d\u043e, \u043f\u0440\u043e\u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c.<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u0442\u044c \u043d\u0435\u043a\u0438\u0439 \u0433\u0440\u0430\u0444, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u044d\u0442\u0430\u043f\u0430\u0445 \u043c\u044b \u0443\u0436\u0435 \u043d\u0430\u0448\u043b\u0438 \u0440\u0451\u0431\u0440\u0430 [0, 3], [3, 5], [6, 7], [7, 1] \u0438 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435 \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0435\u043c \u0440\u0435\u0431\u0440\u043e [5, 6] \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1. <\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u0434\u043b\u044f \u0440\u0435\u0431\u0440\u0430 [5, 6], \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0440\u0435\u0431\u0440\u043e [6, 5] (\u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c), \u0430 \u0440\u0435\u0431\u0440\u043e [1, 0]. \u0418 \u0432\u044b\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0431\u0440\u043e \u0437\u0430\u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0432 \u0433\u0440\u0430\u0444\u0435 \u043f\u043e\u0434\u0446\u0438\u043a\u043b. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043c\u044b \u0442\u0430\u043a \u0436\u0435 \u0432\u044b\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0434\u0443\u0433\u0438, \u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0438\u0437 [5] (\u0432\u044b\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438) \u0438 \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u0432 [6] (\u0432\u044b\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u0430).<\/p>\n<p>\u0422\u0430\u043a \u0432\u043e\u0442, \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0433\u043e\u043b\u043e\u0432\u0443 \u0438 \u0445\u0432\u043e\u0441\u0442 \u043f\u0443\u0442\u0438, \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0431\u0440\u043e \u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0435\u0434\u0438\u043d\u0443\u044e \u0432\u0435\u0442\u0432\u044c \u0438 \u0443\u0436\u0435 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u0443\u0442\u0438 \u0432\u0437\u044f\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442.<\/p>\n<p>\u0418\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0433\u043e \u0444\u0430\u043a\u0442\u0430 \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0437\u0430\u0432\u043e\u0434\u0438\u0442 \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0435\u0440\u0435\u0431\u043e\u0440 \u0432 \u0442\u0443\u043f\u0438\u043a, \u043f\u0440\u043e \u0442\u043e\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u043c\u043e\u043b\u0447\u0443.<\/p>\n<hr\/>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u043e \u0445\u043e\u0434\u0443 \u0442\u0435\u043a\u0441\u0442\u0430 \u044f \u0431\u0443\u0434\u0443 \u0432\u044b\u0434\u0432\u0438\u0433\u0430\u0442\u044c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043e\u043c\u0443-\u0442\u043e \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u043f\u043e\u0440\u043d\u044b\u043c\u0438, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u043c\u0438\u0442\u0435 \u0437\u0430 \u0444\u0430\u043a\u0442.<\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u0433\u0440\u0430\u043d\u0438\u0446 \u043f\u0440\u0438 \u043f\u043e\u043b\u043d\u043e\u043c \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0435 \u043e\u0447\u0435\u043d\u044c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u043d\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043e\u0442\u0432\u0440\u0430\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0447\u0435\u0440\u0442\u0430: \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044f. \u041c\u044b \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0434\u0435\u043b\u0438\u043c \u0434\u0435\u0440\u0435\u0432\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043d\u0430 \u0434\u0432\u0430 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430, \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438, \u043f\u043b\u044e\u0441 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u044e\u0434\u0430 \u0440\u0430\u0441\u0445\u043e\u0434\u044b \u043d\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u044e \u0438 \u0441\u043b\u0443\u0436\u0435\u0431\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435, \u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440\u0430\u0445 \u0434\u0435\u0440\u0435\u0432\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0439 \u044d\u0442\u043e \u043e\u0433\u0440\u043e\u043c\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u041c\u0430\u043b\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0442\u044c, \u0442\u0430\u043a \u0435\u0449\u0451 \u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0440\u0430\u0437\u043d\u044b\u043c \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u0435\u0448\u0451\u0432\u043e\u0435 \u0443\u0434\u043e\u0432\u043e\u043b\u044c\u0441\u0442\u0432\u0438\u0435.<\/p>\n<p>\u0410\u0432\u0442\u043e\u0440\u0441\u043a\u0438\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u0442\u044c \u0437\u0430\u0434\u0430\u0447\u0443 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0451\u0440\u0430 \u043d\u0435 \u043a\u0430\u043a \u0430\u043a\u0430\u0434\u0435\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e, \u0430 \u043a\u0430\u043a \u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043d\u0443\u044e.<\/p>\n<p>\u0412\u0441\u044f \u0441\u0443\u0442\u044c \u0441\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043c\u044b \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043a\u043b\u043e\u043d\u044f\u0435\u043c\u0441\u044f \u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u0433\u043e \u041b\u0438\u0442\u043b\u043e\u043c, \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0448\u0430\u0433\u043e\u0432 \u043f\u0440\u0438 \u043e\u0431\u0445\u043e\u0434\u0435 \u0434\u0435\u0440\u0435\u0432\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0439, \u043d\u043e \u0437\u0430\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0438\u0433\u0440\u044b\u0432\u0430\u044f \u0438\u0437-\u0437\u0430 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0430\u043a\u0438\u0445 \u0448\u0430\u0433\u043e\u0432.<\/p>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0442\u0440\u0451\u0445 \u043c\u0435\u0442\u0430 \u0448\u0430\u0433\u043e\u0432: <\/p>\n<ol>\n<li>\n<p>\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043c \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u0430\u0442\u0440\u0438\u0446\u044b (\u0440\u0435\u0434\u0443\u043a\u0446\u0438\u044f \u0441\u0442\u0440\u043e\u043a, \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432), \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0441 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0446\u0435\u043d\u043a\u043e\u0439 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0438 \u043c\u0435\u0436\u0434\u0443 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1 \u0438\u043b\u0438 M2, <strong>\u0432\u0441\u0435\u0433\u0434\u0430 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0432 M1<\/strong>, \u043f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0435\u043c \u0434\u043d\u0430. \u0412 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043d\u0435 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0449\u0438\u0439 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u043f\u043e\u0440\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043b\u0443\u0447\u0448\u0435\u0435 \u0441 \u0442\u0435\u043a\u0443\u0449\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c \u0435\u0433\u043e, \u0435\u0441\u043b\u0438 \u043e\u043d\u043e \u043a\u043e\u0440\u043e\u0447\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0432\u044b\u0448\u0435, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0434\u043b\u044f \u043d\u0435\u0433\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e M2 \u0438 \u0432\u044b\u0447\u0451\u0440\u043a\u0438\u0432\u0430\u0435\u043c \u043a\u043b\u0435\u0442\u043a\u0443. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0448\u0430\u0433\u0443 1.<\/p>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u044e\u0441\u044c \u043d\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0441\u0440\u043e\u0447\u043d\u043e \u043f\u0440\u0435\u043a\u0440\u0430\u0442\u0438\u0442\u044c \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0435 \u043e\u0431\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0435\u0442\u0432\u0438 \u0434\u0435\u0440\u0435\u0432\u0430 \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u0439, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u0432 \u043e\u0431\u044a\u0451\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.<\/p>\n<ul>\n<li>\n<p>\u041d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u0448\u0430\u0433\u0435, \u0435\u0441\u043b\u0438 \u043c\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u043c, \u0447\u0442\u043e \u0432 \u043a\u0430\u043a\u0443\u044e-\u043b\u0438\u0431\u043e \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0438\u043b\u0438 \u0438\u0437 \u043d\u0435\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430;<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c \u0448\u0430\u0433\u0435, \u0435\u0441\u043b\u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0438\u0439 \u0438\u0437 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u043a\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u043c\u0435\u043d\u044c\u0448\u0435 \u043d\u0438\u0436\u043d\u0435\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u044b;<\/p>\n<\/li>\n<li>\n<p>\u041d\u0430 \u0442\u0440\u0435\u0442\u044c\u0435\u043c \u0448\u0430\u0433\u0435, \u0435\u0441\u043b\u0438 \u043b\u0443\u0447\u0448\u0438\u0439 \u0438\u0437 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u043f\u043e\u043a\u0430 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u043e\u0432 \u043c\u0435\u043d\u044c\u0448\u0435 \u0441\u0443\u043c\u043c\u044b \u043d\u0438\u0436\u043d\u0435\u0439 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0433\u0440\u0430\u043d\u0438\u0446\u044b \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439 \u043e\u0446\u0435\u043d\u043a\u0438 \u043d\u0430 \u0448\u0430\u0433\u0435;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<figure class=\"\"><figcaption>\u041f\u0440\u0438\u043c\u0435\u0440 \u0440\u0430\u0441\u0447\u0451\u0442\u0430 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1<\/figcaption><\/figure>\n<p>\u0414\u043b\u044f \u0441\u0435\u0431\u044f \u043d\u0430\u0437\u0432\u0430\u043b \u043f\u043e\u0434\u0445\u043e\u0434 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u043d\u044b\u0440\u044f\u043b\u044c\u0449\u0438\u043a\u0430. \u0423\u0436 \u0431\u043e\u043b\u044c\u043d\u043e \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043c\u043d\u0435, \u043a\u0430\u043a \u043e\u0445\u043e\u0442\u043d\u0438\u043a \u0437\u0430 \u0436\u0435\u043c\u0447\u0443\u0433\u043e\u043c \u043d\u044b\u0440\u044f\u0435\u0442 \u043d\u0430 \u0434\u043d\u043e, \u0445\u0432\u0430\u0442\u0430\u0435\u0442 \u0440\u0430\u043a\u043e\u0432\u0438\u043d\u0443, \u043e\u0442\u043f\u043b\u044b\u0432\u0430\u0435\u0442 \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443, \u0441\u043d\u043e\u0432\u0430 \u043d\u044b\u0440\u044f\u0435\u0442. \u0414\u043d\u043e \u0432\u043e\u0434\u043e\u0451\u043c\u0430 \u043d\u0435 \u0440\u043e\u0432\u043d\u043e\u0435, \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u0434\u0435\u0440\u0435\u0432\u043e \u0432\u0435\u0442\u0432\u043b\u0435\u043d\u0438\u044f. \u0423 \u043f\u043b\u043e\u0432\u0446\u0430 \u0435\u0441\u0442\u044c \u0432\u0435\u0440\u0451\u0432\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442 \u0434\u043e \u043d\u0430\u0442\u044f\u0436\u0435\u043d\u0438\u044f, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043a\u0430\u043a \u043d\u044b\u0440\u044f\u043b\u044c\u0449\u0438\u043a \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442 \u0434\u043d\u0430. \u0418 \u0442\u0430\u043a \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043e\u043d \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0442\u044c \u0434\u043d\u0430, \u043a\u0440\u043e\u043c\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u043c\u0435\u0441\u0442\u0430, \u0447\u0442\u043e \u0438 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u043f\u0440\u043e\u0441\u0438\u0442\u044c, \u043a \u0447\u0435\u043c\u0443 \u044d\u0442\u0438 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438? \u0418\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a \u043c\u044b \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0435\u043c\u0441\u044f \u043e\u0442 \u0445\u0432\u043e\u0441\u0442\u043e\u0432\u043e\u0439 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u043f\u0440\u0438 \u0440\u0430\u0441\u0447\u0451\u0442\u0435 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u041c2 \u0438 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u043c, \u0447\u0442\u043e \u0433\u043b\u0443\u0431\u0438\u043d\u0430 \u0440\u0435\u043a\u0443\u0440\u0441\u0438\u0438 \u0434\u043b\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 M1 \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0441\u0438\u0442 n. <\/p>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0449\u0451 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0444\u043e\u043a\u0443\u0441 \u0441 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u043f\u0430\u043c\u044f\u0442\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0441\u0442\u0435\u043a\u0435, \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u043a\u0443\u0447\u0435 (\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u0443 \u041e\u0421 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u0440\u043e\u0433\u043e), \u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0438\u0434\u0430\u0442\u044c \u0441\u0432\u0435\u0440\u0445\u0431\u044b\u0441\u0442\u0440\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c L1 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u0430. \u0422\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u0438 \u0442\u0430\u043a\u043e\u043c \u043f\u043e\u0434\u0445\u043e\u0434\u0435 \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0430\u0441\u043d\u0443\u044e \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0443\u044e \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0443\u044e \u043f\u0430\u043c\u044f\u0442\u044c, \u043d\u0443 \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0432 \u041e\u0421.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 n = 33 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 63\u041a\u0411 \u0441\u0442\u0435\u043a\u0430, \u043f\u0440\u0438 \u043b\u044e\u0431\u044b\u0445 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u0418\u0437 \u043f\u0440\u043e\u0447\u0438\u0445 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0445 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0439: <\/p>\n<ul>\n<li>\n<p>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043e\u0434\u043d\u0438\u043c \u043a\u0443\u0441\u043a\u043e\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u044d\u0442\u043e \u0437\u0434\u043e\u0440\u043e\u0432\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u0440\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043c\u0435\u043d\u044c\u0448\u0435\u0433\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0430, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e\u0432\u044b\u0448\u0430\u0435\u0442 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445;<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e 32 \u0431\u0438\u0442\u043d\u044b\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e, \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 (\u0432\u044b\u0440\u043e\u0432\u043d\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435);<\/p>\n<\/li>\n<li>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0434\u043b\u044f \u0440\u0430\u0441\u0447\u0451\u0442\u043e\u0432 inf = 2147483647 (0x7fffffff), \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0434\u0432\u0443\u0445 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u0435\u0439 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 (\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c);<\/p>\n<\/li>\n<li>\n<p>\u0423\u043c\u044b\u0448\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0442\u043a\u0430\u0437 \u043e\u0442 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u0435\u043b\u0435\u043d\u0438\u044f (\u043e\u0447\u0435\u043d\u044c \u0434\u043e\u0440\u043e\u0433\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f);<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432\u044b\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443, \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u044e\u0442 \u0431\u044b\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u041e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u044d\u0442\u0430\u043f \u0440\u0435\u0434\u0443\u043a\u0446\u0438\u0438 \u0441 \u0432\u044b\u0431\u043e\u0440\u043e\u043c \u043d\u0443\u043b\u0435\u0432\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0434\u043b\u044f \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u044f, \u0434\u043b\u044f \u0443\u043c\u0435\u043d\u044c\u0448\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0435;<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0437\u0430 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0445\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0440\u0430\u0437\u0443 \u0434\u0432\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430: \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0440\u0435\u0434\u0443\u043a\u0446\u0438\u0438 \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0435 \u0438 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u043f\u043e \u0442\u043e\u0439 \u0436\u0435 \u0441\u0442\u0440\u043e\u043a\u0435 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043d\u0443\u043b\u0435\u0439.\u00a0 \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e two_lows, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u0434\u0432\u0430 \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0430 \u0437\u0430 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0445\u043e\u0434, \u0447\u0442\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442 \u043f\u043e\u0447\u0442\u0438 \u0432\u0434\u0432\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043a \u043c\u0430\u0442\u0440\u0438\u0446\u0435 \u043d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435. \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438 \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u043b\u0441\u044f \u043d\u0430 Pascal, \u0437\u0430\u0442\u0435\u043c \u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u0435\u0433\u043e \u043d\u0430 \u0421\u0438 \u0438 \u0432\u043d\u0451\u0441 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043d\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u041f\u0430\u0441\u043a\u0430\u043b\u044e, \u0434\u043e\u0431\u0438\u0432\u0448\u0438\u0441\u044c \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0434\u0432\u0443\u043a\u0440\u0430\u0442\u043d\u043e\u0433\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0448\u0430\u0433. \u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0432 Pathon \u043e\u0431\u0435\u0440\u043d\u0443\u043b \u0432 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0443\u0436\u0435 \u043d\u0430 \u043d\u0435\u0439.<\/p>\n<details class=\"spoiler\">\n<summary>\u0414\u043b\u044f \u0441\u0430\u043c\u044b\u0445 \u043b\u044e\u0431\u043e\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445<\/summary>\n<div class=\"spoiler__content\">\n<p>\u041a\u043e\u0434 \u0432\u043d\u0435\u0448\u043d\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0438 \u043d\u0430 \u0421\u0438<\/p>\n<pre><code class=\"cpp\">\/\/======================================================================= \/\/ \u0417\u0430\u0434\u0430\u0447\u0430 \u043a\u043e\u043c\u043c\u0438\u0432\u043e\u044f\u0436\u0435\u0440\u0430 (TSP) \u0442\u043e\u0447\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043c\u0435\u0442\u043e\u0434 \u0432\u0435\u0442\u0432\u0435\u0439 \u0438 \u0433\u0440\u0430\u043d\u0438\u0446 (by ReBuilder) \/\/ https:\/\/habr.com\/ru\/post\/708072\/ \/\/======================================================================= const unsigned int inf = 0x7fffffff;  \/\/ 2147483647  typedef struct TVector {     unsigned int src;     unsigned int dest; } TVector;  typedef struct TMatrixObj {     unsigned int global_min;  \/\/ \u0413\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0440\u0430\u0441\u0447\u0451\u0442\u0430     unsigned int n;           \/\/ \u0420\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0442\u0440\u0438\u0446\u044b     unsigned int step;        \/\/ \u0428\u0430\u0433 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430     TVector *v;               \/\/ \u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432 \u0441\u043e\u0445\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0445 \u0440\u0451\u0431\u0435\u0440 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u043c \u0448\u0430\u0433\u0435 [\u043e\u0442\u043a\u0443\u0434\u0430, \u043a\u0443\u0434\u0430]     TVector *v_best;          \/\/ \u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u043c\u0430\u0441\u0441\u0438\u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u0432, \u043b\u0443\u0447\u0448\u0438\u0439 \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 [\u043e\u0442\u043a\u0443\u0434\u0430, \u043a\u0443\u0434\u0430] } TMatrixObj;  void matrix_evaluation(struct TMatrixObj *m, unsigned int *pm, unsigned int index, unsigned int n); \/\/======================================================================= \/\/ \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442 \u0434\u0432\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e void two_lows(unsigned int *a, unsigned int *b, unsigned int c) {     if (c &lt;= *a)     {         *b = *a;         *a = c;     }     else         if (c &lt; *b)             *b = c; } \/\/======================================================================= void matrix_reduction(unsigned int *pm, unsigned int n, unsigned int *max_sum, unsigned int *max_i, unsigned int *max_j) {     unsigned int sum = 0;      \/\/ \u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u043c \u043a\u0435\u0448 \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0447\u0451\u0442\u0430 \u0432\u0435\u0441\u0430 \u0441\u0442\u0440\u043e\u043a\u0438     unsigned int line_cache[n + 1];      \/\/ \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u043c\u0438\u043d\u0438\u043c\u0443\u043c     for (unsigned int i = 1; i &lt; n; i++)     {         unsigned int min1 = pm[i * n + 1];         unsigned int min2 = inf;         two_lows(&amp;min1, &amp;min2, pm[i * n + 2]);          for (unsigned int j = 3; j &lt; n; j++)             two_lows(&amp;min1, &amp;min2, pm[i * n + j]);          \/\/ \u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u044c \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u043e\u0432 \u0442\u043e \u043e\u0431\u0440\u044b\u0432\u0430\u0435\u043c \u0440\u0430\u0441\u0447\u0451\u0442         if (min1 == inf)         {             pm[0] = inf;             return;<\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-343264","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/343264","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=343264"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/343264\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343264"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=343264"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=343264"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}