{"id":4412,"date":"2018-12-25T17:36:55","date_gmt":"2018-12-25T14:36:55","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=4412"},"modified":"2018-12-25T21:11:54","modified_gmt":"2018-12-25T18:11:54","slug":"e-olimp-5079-%d1%82%d1%80%d0%b0%d0%bd%d0%b7%d0%b8%d1%82%d0%b8%d0%b2%d0%bd%d0%be%d1%81%d1%82%d1%8c-%d0%be%d1%80%d0%b8%d0%b5%d0%bd%d1%82%d0%b8%d1%80%d0%be%d0%b2%d0%b0%d0%bd%d0%bd%d0%be%d0%b3%d0%be","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=4412","title":{"rendered":"e-olimp 5079. \u0422\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430"},"content":{"rendered":"<h1>\u0423\u0441\u043b\u043e\u0432\u0438\u0435<\/h1>\n<p>\u041d\u0430\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <em>\u0442\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u043c<\/em>, \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u0442\u0440\u0435\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0432\u0435\u0440\u0448\u0438\u043d $u$, $v$ \u0438 $w$ \u0438\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0438\u0437 $u$ \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 $v$ \u0432\u0435\u0434\u0435\u0442 \u0440\u0435\u0431\u0440\u043e \u0438 \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d\u044b $v$ \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 $w$ \u0432\u0435\u0434\u0435\u0442 \u0440\u0435\u0431\u0440\u043e, \u0441\u043b\u0435\u0434\u0443\u0435\u0442, \u0447\u0442\u043e \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d\u044b $u$ \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 $w$ \u0432\u0435\u0434\u0435\u0442 \u0440\u0435\u0431\u0440\u043e.<br \/>\n\u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u0430\u043d\u0438\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u043c.<\/p>\n<h2>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0412\u0445\u043e\u0434\u043d\u043e\u0439 \u0444\u0430\u0439\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0447\u0438\u0441\u043b\u043e $n (1 \\leq n \\leq 100)$ \u2014 \u0447\u0438\u0441\u043b\u043e \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u0433\u0440\u0430\u0444\u0435, \u0438 \u0437\u0430\u0442\u0435\u043c $n$ \u0441\u0442\u0440\u043e\u043a \u043f\u043e $n$ \u0447\u0438\u0441\u0435\u043b, \u043a\u0430\u0436\u0434\u043e\u0435 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0432\u043d\u043e $0$ \u0438\u043b\u0438 $1$ \u2014 \u0435\u0433\u043e \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h2>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0432 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u0439 \u0444\u0430\u0439\u043b <strong>YES<\/strong>, \u0435\u0441\u043b\u0438 \u0433\u0440\u0430\u0444 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u043c, \u0438 <strong>NO<\/strong> &#8212; \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u044b<\/h2>\n<table>\n<tr>\n<td><strong> \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 <\/strong> <\/td>\n<td> <strong> \u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 <\/strong> <\/td>\n<\/tr>\n<tr>\n<td> $3$<br \/>\n$0$ $1$ $1$<br \/>\n$0$ $0$ $1$<br \/>\n$0$ $0$ $0$<\/td>\n<td> <strong>YES<\/strong> <\/td>\n<\/tr>\n<tr>\n<td> $3$<br \/>\n$0$ $1$ $1$<br \/>\n$1$ $0$ $0$<br \/>\n$0$ $1$ $0$<\/td>\n<td> <strong>NO<\/strong> <\/td>\n<\/tr>\n<\/table>\n<h2>\u041a\u043e\u0434 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<pre class=\"lang:java decode:true \">import java.util.*;\r\npublic class Main {\r\n    public static void main(String[] args) {\r\n        Scanner sc = new Scanner(System.in);\r\n        int n = sc.nextInt();\r\n        String answer = \"YES\";\r\n        short[][] graph = new short [n][n];\r\n        for (int i = 0; i &lt; n; i++) {\r\n            for( int j = 0; j &lt; n; j++) {\r\n                graph[i][j] = sc.nextShort();\r\n            }\r\n        }\r\n        for(int i = 0; i &lt; n; i++){\r\n            for(int j = 0; j &lt; n; j++){\r\n                if (graph[i][j] == 1){ \r\n                    for (int z = 0; z &lt; n; z++){\r\n                        if (graph[j][z] == 1 &amp;&amp; graph[i][z] == 0) { \r\n                            answer = \"NO\";\r\n                            break;\r\n                        }   \r\n                    }   \r\n                }\r\n            }\r\n        }\r\n    System.out.print(answer);\r\n    }\r\n}\r\n<\/pre>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u0433\u0440\u0430\u0444\u0430 \u0432 \u0432\u0438\u0434\u0435 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0422\u043e\u0433\u0434\u0430, \u0435\u0441\u043b\u0438 $graph[i][j]=1$, \u0442\u043e \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d\u044b $i$ \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 $j$ \u0432\u0435\u0434\u0451\u0442 \u0440\u0435\u0431\u0440\u043e. \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0446\u0438\u043a\u043b\u043e\u0432 \u0442\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0433\u0440\u0430\u0444\u0430, \u0442\u043e \u0435\u0441\u0442\u044c \u0435\u0441\u043b\u0438 \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d\u044b  $i$ \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 $j$ \u0432\u0435\u0434\u0451\u0442 \u0440\u0435\u0431\u0440\u043e \u0438 \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d\u044b $j$ \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 $z$, \u0442\u043e \u0433\u0440\u0430\u0444 \u0442\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u0435\u043d, \u0435\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0440\u0435\u0431\u0440\u043e $graph[i][z]$.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p><a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/5079\">\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 e-olymp<\/a><br \/>\n<a href=\"https:\/\/ideone.com\/o37b5g\">\u041a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 ideone.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u041d\u0430\u043f\u043e\u043c\u043d\u0438\u043c, \u0447\u0442\u043e \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u0440\u0430\u043d\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u0434\u043b\u044f \u043b\u044e\u0431\u044b\u0445 \u0442\u0440\u0435\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0432\u0435\u0440\u0448\u0438\u043d $u$, $v$ \u0438 $w$ \u0438\u0437 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0438\u0437 $u$ \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 $v$ \u0432\u0435\u0434\u0435\u0442 \u0440\u0435\u0431\u0440\u043e \u0438 \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d\u044b $v$ \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 $w$ \u0432\u0435\u0434\u0435\u0442 \u0440\u0435\u0431\u0440\u043e, \u0441\u043b\u0435\u0434\u0443\u0435\u0442, \u0447\u0442\u043e \u0438\u0437 \u0432\u0435\u0440\u0448\u0438\u043d\u044b $u$ \u0432 \u0432\u0435\u0440\u0448\u0438\u043d\u0443 $w$ \u0432\u0435\u0434\u0435\u0442 \u0440\u0435\u0431\u0440\u043e. \u041f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435, \u0447\u0442\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0440\u0430\u043d\u0438\u0437\u0438\u0442\u0438\u0432\u043d\u044b\u043c. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=4412\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":118,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[109],"tags":[278,593],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4412"}],"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\/118"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4412"}],"version-history":[{"count":3,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4412\/revisions"}],"predecessor-version":[{"id":4416,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4412\/revisions\/4416"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4412"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4412"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}