{"id":5326,"date":"2020-12-02T17:49:10","date_gmt":"2020-12-02T14:49:10","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=5326"},"modified":"2020-12-06T16:04:40","modified_gmt":"2020-12-06T13:04:40","slug":"e-olymp-2270-%d0%bf%d0%be%d0%b8%d1%81%d0%ba-%d1%86%d0%b8%d0%ba%d0%bb%d0%b0","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=5326","title":{"rendered":"e-olymp 2270. \u041f\u043e\u0438\u0441\u043a \u0446\u0438\u043a\u043b\u0430"},"content":{"rendered":"<h1>\u0417\u0430\u0434\u0430\u0447\u0430<\/h1>\n<p>\u0414\u0430\u043d \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0435\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0441\u0442\u044c \u043b\u0438 \u0432 \u043d\u0451\u043c \u0446\u0438\u043a\u043b\u044b, \u0438 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c, \u0442\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445.<\/p>\n<h1>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h1>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0434\u0432\u0430 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 $n$ \u0438 $m$ $($$1$ $\\leqslant$ $n$ $\\leqslant$ $10$<sup>$5$<\/sup>$, $$1$ $\\leqslant$ $m$ $\\leqslant$ $10$<sup>$5$<\/sup>$)$ &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0435\u0440\u0448\u0438\u043d \u0438 \u0440\u0435\u0431\u0435\u0440 \u0432 \u0433\u0440\u0430\u0444\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0414\u0430\u043b\u0435\u0435 \u0432 $m$ \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b \u0440\u0451\u0431\u0440\u0430 \u0433\u0440\u0430\u0444\u0430. \u041a\u0430\u0436\u0434\u043e\u0435 \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u043f\u0430\u0440\u043e\u0439 \u0447\u0438\u0441\u0435\u043b &#8212; \u043d\u043e\u043c\u0435\u0440\u0430\u043c\u0438 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0438 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<h1>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h1>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u0433\u0440\u0430\u0444\u0435 \u043d\u0435\u0442 \u0446\u0438\u043a\u043b\u0430, \u0442\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 &#171;NO&#187;, \u0438\u043d\u0430\u0447\u0435 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 &#171;YES&#187; \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435 \u043e\u0431\u0445\u043e\u0434\u0430 \u0446\u0438\u043a\u043b\u0430.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-5328 size-full\" src=\"http:\/\/java.mazurok.com\/wp-content\/uploads\/\u0413\u0440\u0430\u0444.png\" alt=\"\" width=\"654\" height=\"187\" srcset=\"https:\/\/java.mazurok.com\/wp-content\/uploads\/\u0413\u0440\u0430\u0444.png 654w, https:\/\/java.mazurok.com\/wp-content\/uploads\/\u0413\u0440\u0430\u0444-300x86.png 300w\" sizes=\"(max-width: 654px) 100vw, 654px\" \/><\/p>\n<h1>\u0422\u0435\u0441\u0442\u044b<\/h1>\n<table style=\"height: 354px\" width=\"1311\">\n<tbody>\n<tr>\n<td style=\"text-align: center\" width=\"40\">\n<h4>\u2116<\/h4>\n<\/td>\n<td style=\"text-align: center\" width=\"350\">\n<h4>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h4>\n<\/td>\n<td style=\"text-align: center\" width=\"350\">\n<h4>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h4>\n<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">1<\/td>\n<td style=\"text-align: center\">\n<div class=\"mdl-cell mdl-cell--6-col\">2 2<\/div>\n<div>1 2<\/div>\n<div>1 2<\/div>\n<\/td>\n<td style=\"text-align: center\">NO<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">2<\/td>\n<td style=\"text-align: center\">2 2<br \/>\n1 2<br \/>\n2 1<\/td>\n<td style=\"text-align: center\">YES<br \/>\n1 2<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">3<\/td>\n<td style=\"text-align: center\">6 7<br \/>\n1 2<br \/>\n1 5<br \/>\n2 3<br \/>\n2 4<br \/>\n4 6<br \/>\n6 5<br \/>\n5 2<\/td>\n<td style=\"text-align: center\">YES<br \/>\n2 4 6 5<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">4<\/td>\n<td style=\"text-align: center\">6 6<br \/>\n1 3<br \/>\n2 4<br \/>\n3 4<br \/>\n1 2<br \/>\n3 5<br \/>\n3 6<\/td>\n<td style=\"text-align: center\">NO<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">5<\/td>\n<td style=\"text-align: center\">4 4<br \/>\n1 3<br \/>\n4 2<br \/>\n2 3<br \/>\n3 4<\/td>\n<td style=\"text-align: center\">YES<br \/>\n3 4 2<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre class=\"lang:java decode:true \">import java.util.*;\r\npublic class Main {\r\n    public static int n, m, flag = 0;\r\n    public static ArrayList&lt;ArrayList&lt;Integer&gt;&gt; graph = new ArrayList&lt;ArrayList&lt;Integer&gt;&gt;();\r\n    public static ArrayList&lt;Integer&gt; used = new ArrayList&lt;Integer&gt;();\r\n    public static ArrayList&lt;Integer&gt; path = new ArrayList&lt;Integer&gt;();\r\n    \/\/ \u043f\u043e\u0438\u0441\u043a \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b\r\n    static void dfs(int v) {\r\n        if (flag == 1) return; \/\/ \u0435\u0441\u043b\u0438 \u0443\u0436\u0435 \u043d\u0430\u0448\u043b\u0438 \u0446\u0438\u043a\u043b, \u0442\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f\r\n        else {\r\n            used.set(v, 1); \/\/ \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u0443\r\n            path.add(v); \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0435 \u0432 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0431\u0445\u043e\u0434\u0430 \u0433\u0440\u0430\u0444\u0430\r\n            for (int i = 0; i &lt; graph.get(v).size(); i++) {\r\n                int to = graph.get(v).get(i); \/\/ \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0430\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u0433\u0440\u0430\u0444\u0430\r\n                if (used.get(to) == 1) { \/\/ \u0435\u0441\u043b\u0438 \u043c\u044b \u0435\u0435 \u043f\u043e\u0441\u0435\u0442\u0438\u043b\u0438, \u043d\u043e \u043d\u0435 \u0432\u044b\u0448\u043b\u0438 \u0438\u0437 \u043d\u0435\u0435, \u0437\u043d\u0430\u0447\u0438\u0442 \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u0446\u0438\u043a\u043b\r\n                    path.add(to); \/\/ \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0432 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0431\u0445\u043e\u0434\u0430 \u0433\u0440\u0430\u0444\u0430\r\n                    flag = 1; \/\/ \u0441\u0442\u0430\u0432\u0438\u043c \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440, \u0447\u0442\u043e \u043c\u044b \u043d\u0430\u0448\u043b\u0438 \u0446\u0438\u043a\u043b \u0438 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f\r\n                    return;\r\n                }\r\n                else dfs(to); \/\/ \u0435\u0441\u043b\u0438 \u043d\u0435 \u043f\u043e\u0441\u0435\u0442\u0438\u043b\u0438, \u0442\u043e \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u043c\r\n                if (flag == 1) return; \/\/ \u0435\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0446\u0438\u043a\u043b, \u0442\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f\r\n            }\r\n            used.set(v, 2); \/\/ \u0435\u0441\u043b\u0438 \u043d\u0435 \u043d\u0430\u0448\u043b\u0438 \u0446\u0438\u043a\u043b, \u0442\u043e \u0432\u044b\u0445\u043e\u0434\u0438\u043c \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d\u044b\r\n            path.remove(path.size() - 1);\r\n        }\r\n    }\r\n    \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0446\u0438\u043a\u043b\u0430\r\n    static void checkNodes() {\r\n        for (int i = 0; i &lt;= n; i++) {\r\n            if (used.get(i) == 0) { \/\/ \u0435\u0441\u043b\u0438 \u043d\u0435 \u043f\u043e\u0441\u0435\u0449\u0430\u043b\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u0443, \u0442\u043e \u043f\u043e\u0441\u0435\u0449\u0430\u0435\u043c \u0435\u0435\r\n                dfs(i);\r\n                if (flag == 1) return; \/\/ \u0435\u0441\u043b\u0438 \u043d\u0430\u0448\u043b\u0438 \u0446\u0438\u043a\u043b, \u0442\u043e \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c\u0441\u044f\r\n            }\r\n        }\r\n    }\r\n    public static void main (String[] args) {\r\n        Scanner s = new Scanner(System.in);\r\n        \/\/ \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0435\u0440\u0448\u0438\u043d \u0438 \u0440\u0435\u0431\u0435\u0440\r\n        n = s.nextInt();\r\n        m = s.nextInt();\r\n        for (int i = 0; i &lt;= n; i++) {\r\n            used.add(0);\r\n            graph.add(new ArrayList&lt;&gt;());\r\n        }\r\n        for (int i = 0; i &lt; m; i++) {\r\n            \/\/ \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0440\u0435\u0431\u0440\u0430 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0433\u0440\u0430\u0444\r\n            int v1 = s.nextInt();\r\n            int v2 = s.nextInt();\r\n            graph.get(v1).add(v2);\r\n        }\r\n        checkNodes(); \/\/ \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0446\u0438\u043a\u043b\u0430\r\n        if (flag == 1) { \/\/ \u0435\u0441\u043b\u0438 \u0446\u0438\u043a\u043b \u043d\u0430\u0439\u0434\u0435\u043d\r\n            int i = path.size() - 2; \/\/ \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u0446\u0438\u043a\u043b\u0430\r\n            int to = path.get(path.size() - 1); \/\/ \u0432\u0435\u0440\u0448\u0438\u043d\u0430 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u043b\u0438\u0441\u044c\r\n            while (path.get(i) != to) { \/\/ \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0434\u0435\u043a\u0441 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0446\u0438\u043a\u043b\u0438\u043b\u0438\u0441\u044c\r\n                i--;\r\n            }\r\n            System.out.println(\"YES\");\r\n            while (i &lt; path.size() - 1) {  \/\/ \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u0430\u043c \u0446\u0438\u043a\u043b\r\n                System.out.print(path.get(i) + \" \");\r\n                i++;\r\n            }\r\n            System.out.println();\r\n        }\r\n        else\r\n            System.out.print(\"NO\");\r\n    }\r\n}\r\n<\/pre>\n<h1>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h1>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0432 \u0433\u043b\u0443\u0431\u0438\u043d\u0443. \u0422\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u043c\u0435\u0447\u0430\u0442\u044c \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0446\u0432\u0435\u0442\u0430\u043c\u0438 ($0$ (<em>\u0431\u0435\u043b\u044b\u0439<\/em>) &#8212; \u043c\u044b \u0435\u0449\u0435 \u043d\u0435 \u043f\u043e\u0441\u0435\u0449\u0430\u043b\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u0443, $1$ (<em>\u0441\u0435\u0440\u044b\u0439<\/em>) &#8212; \u043f\u043e\u0441\u0435\u0442\u0438\u043b\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0438 \u043d\u0435 \u0432\u044b\u0448\u043b\u0438 \u0438\u0437 \u043d\u0435\u0435 (\u0437\u0430\u0446\u0438\u043a\u043b\u0438\u043b\u0438\u0441\u044c), $2$ (<em>\u0447\u0435\u0440\u043d\u044b\u0439<\/em>) &#8212; \u043f\u043e\u0441\u0435\u0442\u0438\u043b\u0438 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0438 \u0432\u044b\u0448\u043b\u0438 \u0438\u0437 \u043d\u0435\u0451).<\/p>\n<p>\u0412 \u0432\u0435\u043a\u0442\u043e\u0440\u0435 $graph$ \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0430\u043c \u0433\u0440\u0430\u0444, \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u0446\u0438\u043a\u043b\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c $visited$, \u0442\u0430\u043a \u0436\u0435 \u0431\u0443\u0434\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0431\u0445\u043e\u0434\u0430 \u0433\u0440\u0430\u0444\u0430 \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0435 $path$. \u0422\u0430\u043a \u043a\u0430\u043a \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0446\u0438\u043a\u043b\u043e\u0432, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043b\u044e\u0431\u043e\u0439, \u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0439 \u0438 \u043d\u0430 \u044d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c\u0441\u044f, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0432\u0435\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e $flag$, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0440\u0430\u0432\u043d\u0430 1, \u0435\u0441\u043b\u0438 \u0446\u0438\u043a\u043b \u0443\u0436\u0435 \u043d\u0430\u0439\u0434\u0435\u043d, \u0438 \u0440\u0430\u0432\u043d\u0430 0, \u0435\u0441\u043b\u0438 \u0446\u0438\u043a\u043b \u0435\u0449\u0435 \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d. \u0412 \u0432\u0435\u043a\u0442\u043e\u0440\u0435 $visited$ \u0431\u0443\u0434\u0435\u043c \u043e\u043a\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0432\u0435\u0440\u0448\u0438\u043d\u0443 \u0432 \u043e\u0434\u0438\u043d \u0438\u0437 \u0446\u0432\u0435\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0441\u0435\u0442\u0438\u0442\u044c $1$ (<em>\u0441\u0435\u0440\u0443\u044e<\/em>) \u0432\u0435\u0440\u0448\u0438\u043d\u0443, \u0442\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c, \u0447\u0442\u043e \u043c\u044b \u043e\u0442\u044b\u0441\u043a\u0430\u043b\u0438 \u0446\u0438\u043a\u043b \u0432 \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u0435, \u0442\u043e\u0433\u0434\u0430 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c $flag = 1$.<\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0435\u0433\u043e \u043d\u0430 \u044d\u043a\u0440\u0430\u043d. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c $path$, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 &#8212; \u0432\u0435\u0440\u0448\u0438\u043d\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0446\u0438\u043a\u043b. \u0418\u0449\u0435\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0448\u0438\u043d\u044b \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0435 $path$ \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u0430\u043c \u0446\u0438\u043a\u043b.<\/p>\n<h1>\u0421\u0441\u044b\u043b\u043a\u0438<\/h1>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 <a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/2270\" target=\"_blank\" rel=\"noopener noreferrer\">e-olymp<\/a><\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 <a href=\"https:\/\/ideone.com\/IDuI36\">ideone<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0414\u0430\u043d \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0435\u0432\u0437\u0432\u0435\u0448\u0435\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0441\u0442\u044c \u043b\u0438 \u0432 \u043d\u0451\u043c \u0446\u0438\u043a\u043b\u044b, \u0438 \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c, \u0442\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0434\u0432\u0430 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 $n$ \u0438 $m$ $($$1$ $\\leqslant$ $n$ $\\leqslant$ $10$$5$$, $$1$ $\\leqslant$ $m$ $\\leqslant$ $10$$5$$)$ &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0435\u0440\u0448\u0438\u043d \u0438 \u0440\u0435\u0431\u0435\u0440 \u0432 \u0433\u0440\u0430\u0444\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u0414\u0430\u043b\u0435\u0435 \u0432 $m$ \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u044b &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=5326\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":169,"featured_media":5333,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[109,106],"tags":[425,316,746,745,427,744],"jetpack_featured_media_url":"https:\/\/java.mazurok.com\/wp-content\/uploads\/1-1.jpg","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/5326"}],"collection":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/users\/169"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5326"}],"version-history":[{"count":5,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/5326\/revisions"}],"predecessor-version":[{"id":5332,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/5326\/revisions\/5332"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/media\/5333"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}