{"id":4545,"date":"2018-12-26T23:00:50","date_gmt":"2018-12-26T20:00:50","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=4545"},"modified":"2018-12-27T18:14:13","modified_gmt":"2018-12-27T15:14:13","slug":"e-olymp-2812-%d1%83%d0%b3%d0%be%d0%bb%d0%be%d0%ba","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=4545","title":{"rendered":"e-olymp 2812. \u0423\u0433\u043e\u043b\u043e\u043a"},"content":{"rendered":"<h1>\u0417\u0430\u0434\u0430\u0447\u0430<\/h1>\n<p>\u0414\u0430\u043d\u0430 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u0441\u043a\u0430 [latex]M\u00d7N[\/latex], \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043b\u0435\u0442\u043a\u0438 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u0440\u0435\u0437\u0430\u043d\u044b. \u0421\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u043d\u0435\u0451 &#171;\u0443\u0433\u043e\u043b\u043e\u043a&#187; \u0438\u0437 \u0442\u0440\u0451\u0445 \u043a\u043b\u0435\u0442\u043e\u043a \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0442\u0440\u0438 \u043a\u043b\u0435\u0442\u043a\u0438 \u0443\u0433\u043e\u043b\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u043e\u0441\u043a\u0438 \u0438 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0432\u044b\u0440\u0435\u0437\u0430\u043d\u044b?<\/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 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0434\u0430\u043d\u044b \u0434\u0432\u0430 \u0447\u0438\u0441\u043b\u0430 [latex]M[\/latex] \u0438 [latex]N[\/latex] [latex](1 \\leq M, N \\leq 100)[\/latex], \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u043c. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 [latex]M[\/latex] \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043f\u043e [latex]N[\/latex] \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439; [latex]i[\/latex]-\u044b\u0439 \u0441\u0438\u043c\u0432\u043e\u043b [latex]j[\/latex]-\u043e\u0439 \u0438\u0437 \u044d\u0442\u0438\u0445 \u0441\u0442\u0440\u043e\u043a \u0440\u0430\u0432\u0435\u043d &#8216;X&#8217; (\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0431\u0443\u043a\u0432\u0430 \u0438\u043a\u0441), \u0435\u0441\u043b\u0438 \u043a\u043b\u0435\u0442\u043a\u0430 \u0432\u044b\u0440\u0435\u0437\u0430\u043d\u0430, \u0438 &#8216;.&#8217; (\u0442\u043e\u0447\u043a\u0430) \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435.<\/p>\n<h1>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h1>\n<p>\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e &#8212; \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0443\u0433\u043e\u043b\u043e\u043a \u043d\u0430 \u0434\u0430\u043d\u043d\u0443\u044e \u0434\u043e\u0441\u043a\u0443.<\/p>\n<h1>\u0422\u0435\u0441\u0442\u044b<\/h1>\n<table>\n<tbody>\n<tr>\n<th>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/th>\n<th>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/th>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">2 2<br \/>\n..<br \/>\n..<\/td>\n<td style=\"text-align: center\">4<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">2 3<br \/>\n..X<br \/>\n.X.<\/td>\n<td style=\"text-align: center\">1<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">5 4<br \/>\n&#8230;.<br \/>\nX.XX<br \/>\n&#8230;.<br \/>\nX..X<br \/>\n..XX<\/td>\n<td style=\"text-align: center\">12<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h1>\n<pre class=\"lang:java decode:true \" title=\"\u0423\u0433\u043e\u043b\u043e\u043a\">import java.io.BufferedReader;\r\nimport java.io.InputStreamReader;\r\n \r\nclass Main\r\n{\r\n\tpublic static void main (String[] args) throws java.lang.Exception\r\n\t{\r\n\t\tBufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));\r\n\t\tString[] params1 = bufferedReader.readLine().split(\" \");\r\n\t\tint x, y;\r\n        x = Integer.parseInt(params1[0]);\r\n        y = Integer.parseInt(params1[1]);\r\n        boolean mas[][] = new boolean[x][y];\r\n        for (int i = 0; i &lt; x; ++i){\r\n            String[] params2 = bufferedReader.readLine().split(\" \");\r\n            for (int j = 0; j &lt; y; ++j){\r\n                char buff;\r\n                buff = params2[0].charAt(j);\r\n                if (buff == '.') mas[i][j] = true; \r\n                else mas[i][j] = false;\r\n            }\r\n            System.out.print(\"\\n\");\r\n        }\r\n        int sum = 0;\r\n        for (int i = 0; i &lt; x; ++i){\r\n            for (int j = 0; j &lt; y; ++j){\r\n                if (mas[i][j]){\r\n                    if (i - 1 &gt;= 0 &amp;&amp; j - 1 &gt;= 0) if (mas[i - 1][j] &amp;&amp; mas[i][j - 1])  ++sum;\r\n                    if (i - 1 &gt;= 0 &amp;&amp; j + 1 &lt; y) if (mas[i - 1][j] &amp;&amp; mas[i][j + 1])  ++sum; \r\n                    if (i + 1 &lt; x &amp;&amp; j + 1 &lt; y) if (mas[i + 1][j] &amp;&amp; mas[i][j + 1])  ++sum; \r\n                    if (i + 1 &lt; x &amp;&amp; j - 1 &gt;= 0) if (mas[i + 1][j] &amp;&amp; mas[i][j - 1])  ++sum; \r\n                }\r\n            }\r\n        }\r\n        System.out.print(sum);\r\n\t}\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 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0442\u0438\u043f\u0430 [latex]bool[\/latex] [latex]x[\/latex] \u043d\u0430 [latex]y[\/latex]. \u0417\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c [latex]true[\/latex], \u043a\u043e\u0433\u0434\u0430 \u0432\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u00ab.\u00bb \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c [latex]false[\/latex] \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435. \u0414\u0430\u043b\u0435\u0435 \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0443\u0433\u043e\u043b\u043a\u043e\u0432 \u043d\u0430 , \u0435\u0441\u043b\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043d\u0435 \u043f\u0443\u0441\u0442\u044b\u0435 \u043a\u043b\u0435\u0442\u043a\u0438.<\/p>\n<h1>\u0421\u0441\u044b\u043b\u043a\u0438<\/h1>\n<p><a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/2812\">e-olymp<\/a><br \/>\n<a href=\"https:\/\/ideone.com\/dUMGuN\">Ideone<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0414\u0430\u043d\u0430 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0430\u044f \u0434\u043e\u0441\u043a\u0430 [latex]M\u00d7N[\/latex], \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043a\u043b\u0435\u0442\u043a\u0438 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u044b\u0440\u0435\u0437\u0430\u043d\u044b. \u0421\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430 \u043d\u0435\u0451 &#171;\u0443\u0433\u043e\u043b\u043e\u043a&#187; \u0438\u0437 \u0442\u0440\u0451\u0445 \u043a\u043b\u0435\u0442\u043e\u043a \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0442\u0440\u0438 \u043a\u043b\u0435\u0442\u043a\u0438 \u0443\u0433\u043e\u043b\u043a\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0438\u0441\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u0434\u043e\u0441\u043a\u0438 \u0438 \u043d\u0435 \u0431\u044b\u043b\u0438 \u0432\u044b\u0440\u0435\u0437\u0430\u043d\u044b? \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 \u0432\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0434\u0430\u043d\u044b \u0434\u0432\u0430 \u0447\u0438\u0441\u043b\u0430 [latex]M[\/latex] \u0438 [latex]N[\/latex] [latex](1 \\leq M, N \\leq 100)[\/latex], \u0440\u0430\u0437\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u043c. \u0412 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=4545\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":127,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[326,627,75],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4545"}],"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\/127"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4545"}],"version-history":[{"count":2,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4545\/revisions"}],"predecessor-version":[{"id":4547,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4545\/revisions\/4547"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}