{"id":4654,"date":"2019-01-03T20:06:10","date_gmt":"2019-01-03T17:06:10","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=4654"},"modified":"2019-01-03T20:08:20","modified_gmt":"2019-01-03T17:08:20","slug":"e-olymp-5071-%d0%bf%d1%80%d0%be%d0%b2%d0%b5%d1%80%d0%ba%d0%b0-%d0%bd%d0%b0-%d0%bd%d0%b5%d0%be%d1%80%d0%b8%d0%b5%d0%bd%d0%b8%d1%82%d1%80%d0%be%d0%b2%d0%b0%d0%bd%d0%bd%d0%be%d1%81%d1%82%d1%8c","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=4654","title":{"rendered":"e-olymp 5071. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0438\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c"},"content":{"rendered":"<h1>\u0417\u0430\u0434\u0430\u0447\u0430. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0438\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c<\/h1>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<br \/>\n\u041f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 $n\\times n$ \u0438\u0437 \u043d\u0443\u043b\u0435\u0439 \u0438 \u0435\u0434\u0438\u043d\u0438\u0446 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435, \u043c\u043e\u0436\u0435\u0442 \u043b\u0438 \u0434\u0430\u043d\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0431\u044b\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430.<\/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 \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \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 \u0441\u0430\u043c\u0443 \u043c\u0430\u0442\u0440\u0438\u0446\u0443.<\/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 YES \u0435\u0441\u043b\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430 \u0438 NO \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<tbody>\n<tr>\n<td>\u0412\u0425\u041e\u0414\u041d\u042b\u0415 \u0414\u0410\u041d\u041d\u042b\u0415<\/td>\n<td>\u0412\u042b\u0425\u041e\u0414\u041d\u042b\u0415 \u0414\u0410\u041d\u041d\u042b\u0415<\/td>\n<\/tr>\n<tr>\n<td>3<br \/>\n0 1 1<br \/>\n1 0 1<br \/>\n1 1 0<\/td>\n<td>YES<\/td>\n<\/tr>\n<tr>\n<td>3<br \/>\n0 1 0<br \/>\n1 0 1<br \/>\n1 1 0<\/td>\n<td>NO<\/td>\n<\/tr>\n<tr>\n<td>3<br \/>\n0 1 0<br \/>\n1 1 1<br \/>\n0 1 0<\/td>\n<td>NO<\/td>\n<\/tr>\n<tr>\n<td>4<br \/>\n0 1 0 0<br \/>\n1 0 1 1<br \/>\n1 1 0 1<br \/>\n0 1 1 1<\/td>\n<td>NO<\/td>\n<\/tr>\n<\/table>\n<h2>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h2>\n<pre class=\"lang:java decode:true \">import java.util.*;\r\nimport java.lang.*;\r\nimport java.io.*;\r\nimport java.util.Scanner;\r\nclass Main {\r\n\tpublic static void main (String[] args) throws java.lang.Exception {\r\n\t\tScanner in = new Scanner(System.in);\r\n\t\tint n = in.nextInt();\r\n\t\tint k = n*n;\r\n\t\tint [] G = new int [k];\r\n\t\tfor (int i = 0; i &lt; G.length; i++) {\r\n\t\t\tG[i] = in.nextInt();\r\n\t\t}\r\n\t\tint j = 0, c = 0, s = 0;\r\n\t\tboolean f = true;\r\n\t\tfor (int i = 0; i &lt; k; i++) {\r\n\t\t\tif (G[i] != G[j]) {\r\n\t\t\t\tf=false;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tif (c == n - 1) {\r\n\t\t\t\tc = 0;\r\n\t\t\t\ts++;\r\n\t\t\t\tj = s;\r\n\t\t\t} else {\r\n\t\t\t\tj = j + n;\r\n\t\t\t\tc++;\r\n\t\t\t}\r\n\t\t}\r\n\t\tfor (int i = 0; i &lt; k; i = i + n + 1) {\r\n\t\t\tif (G[i] != 0) {\r\n\t\t\t\tf = false;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (f) System.out.print(\"YES\"); else System.out.print(\"NO\");\r\n\t}\r\n}<\/pre>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u0427\u0442\u043e\u0431\u044b \u0432\u0432\u0435\u0434\u0451\u043d\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0431\u044b\u043b\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430, \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430, \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0431\u044b\u0442\u044c \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0439, \u0442\u043e \u0435\u0441\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043d\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043f\u043e\u0437\u0438\u0446\u0438\u044f\u0445 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u044b \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439: $a[i] = a[j]$. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u0440\u0430\u0432\u043d\u044f\u043b\u0438\u0441\u044c \u043d\u0443\u043b\u044e. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f.<br \/>\n\u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e  <span class=\"lang:java decode:true crayon-inline\">f<\/span> \u0442\u0438\u043f\u0430 <span class=\"lang:java decode:true crayon-inline\">bool<\/span>. \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e <span class=\"lang:java decode:true crayon-inline\">f=true<\/span>. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u043d\u0430 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e\u0441\u0442\u044c \u0438 \u0440\u0430\u0432\u0435\u043d\u0441\u0442\u0432\u043e \u043d\u0443\u043b\u044e \u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438 \u0445\u043e\u0442\u044c \u043e\u0434\u043d\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u044b \u043d\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u0435\u0442 \u0443\u0441\u043b\u043e\u0432\u0438\u044e, \u0444\u043b\u0430\u0433 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u00ab\u043b\u043e\u0436\u044c\u00bb \u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0445\u043e\u0434 \u0438\u0437 \u0446\u0438\u043a\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0447\u0442\u043e \u0432\u0432\u0435\u0434\u0451\u043d\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430, \u2014 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u00abNO\u00bb. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043e\u0431\u0430 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f, \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u2014 \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438. \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u00abYES\u00bb.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430. \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430 \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0438\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u041f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043d\u043e\u0439 \u043c\u0430\u0442\u0440\u0438\u0446\u0435 $n\\times n$ \u0438\u0437 \u043d\u0443\u043b\u0435\u0439 \u0438 \u0435\u0434\u0438\u043d\u0438\u0446 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435, \u043c\u043e\u0436\u0435\u0442 \u043b\u0438 \u0434\u0430\u043d\u043d\u0430\u044f \u043c\u0430\u0442\u0440\u0438\u0446\u0430 \u0431\u044b\u0442\u044c \u043c\u0430\u0442\u0440\u0438\u0446\u0435\u0439 \u0441\u043c\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043d\u0435\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \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 \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0430\u0442\u0440\u0438\u0446\u044b, \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 \u0441\u0430\u043c\u0443 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=4654\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":116,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[278,684,112,142,331],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4654"}],"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\/116"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4654"}],"version-history":[{"count":10,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4654\/revisions"}],"predecessor-version":[{"id":4827,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4654\/revisions\/4827"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}