{"id":271,"date":"2012-06-23T11:54:35","date_gmt":"2012-06-23T03:54:35","guid":{"rendered":"http:\/\/www.shuizilong.com\/house\/?p=271"},"modified":"2012-06-30T13:12:32","modified_gmt":"2012-06-30T05:12:32","slug":"codeforces-round-125","status":"publish","type":"post","link":"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-125\/","title":{"rendered":"Codeforces Round #125"},"content":{"rendered":"<h3>Brief description: <\/h3>\n<p>Problem A. About Bacteria<br \/>\n&#8230; \u57f9\u517b\u76bf\u4e2d\u7684 x \u53ea\u7ec6\u83cc\u4e0b\u4e00\u79d2\u4f1a\u7e41\u884d\u51fa kx+b \u53ea\u7ec6\u83cc\u3002\u3002\uff08\u3002\u3002\u3002<br \/>\n\u95ee\u5982\u679c\u521d\u59cb\u57f9\u517b\u76bf\u4e2d\u6709 t \u53ea\u7ec6\u83cc\uff0c\u81f3\u5c11\u591a\u5c11\u79d2\u624d\u53ef\u4ee5\u7e41\u884d\u51fa\u4e0d\u5c11\u4e8e z \u53ea\u7ec6\u83cc\u3002<br \/>\n\u3002\u3002\u3002z \u4e3a\u521d\u59cb\u4e3a\u4e00\u53ea\u7ec6\u83cc\u65f6\uff0c\u7e41\u884d n \u79d2\u7684\u7ec6\u83cc\u603b\u6570\u3002\u3002\u3002\uff08\u3002\u3002\u3002<br \/>\n(\u7565\uff0c\u7b97\u672f\u9898\u3002\u3002\u4e0d\u8981\u628a z \u771f\u7ed9\u7b97\u51fa\u6765\u5373\u53ef\u3002\u3002<\/p>\n<p>Problem B. Jumping on Walls<br \/>\n\u4e00\u4e2a\u5fcd\u8005\u5728\u4e00\u4e2a\u5751\u91cc\uff0c \u5de6\u53f3\u5404\u6709\u4e00\u9762\u5899\uff0c\u5899\u4e0a\u6709\u4e00\u4e9b\u969c\u788d\uff0c\u521d\u59cb\u5728\u6700\u4e0b\u89d2\u3002<br \/>\n\u6bcf\u79d2\u949f\u53ef\u4ee5\u4e0a\u4e0b\u79fb\u52a8\u4e00\u683c\uff0c\u6216\u8005\u8df3\u5230\u5bf9\u9762\u5899\u7684\u6070\u597d +k \u4f4d\u7f6e\u3002\u3002<br \/>\n\u3002\u3002\u95ee\u6700\u7ec8\u80fd\u51fa\u8df3\u51fa\u8fd9\u4e2a\u5751\u3002\u3002<br \/>\n\uff08\u7565\uff0c Hash Dp \u6216\u8005 BFS() \u90fd\u884c\u3002\u3002\u3002\u3002<\/p>\n<p>Problem C. Delivering Carcinogen<br \/>\n\u7ed9\u5b9a\u4e00\u9897\u884c\u661f\u5750\u6807 (xp, yp)\uff0c\u8f68\u9053\u534a\u5f84 R\uff0c\u56f4\u7ed5\u6052\u5fc3\u8fd0\u8f6c\u7684\u7ebf\u901f\u5ea6 vp\uff0c<br \/>\n\u4ee5\u53ca\u4e00\u4e2a\u98de\u8239\u5750\u6807 (x, y)\uff0c\u98de\u8239\u901f\u5ea6 v\u3002\u3002\u95ee\u5230\u8fbe p \u661f\u7403\u7684\u6700\u5c11\u65f6\u95f4\u3002\u3002<br \/>\n\u3002\u3002\u98de\u8239\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u8ddd\u6052\u661f\u7684\u8ddd\u79bb\u4e0d\u5f97\u4f4e\u4e8e r\u3002\u3002(r \u2264 R) &#8230;<\/p>\n<p>Problem D. Cube Snake<br \/>\n\u7ed9\u5b9a\u4e00\u4e2a n \u9636\u7acb\u65b9\u4f53\uff0c\u8981\u6c42\u6784\u9020\u6ee1\u8db3\u4e0b\u5217\u6027\u8d28\u7684\u8def\u5f84\uff1a<br \/>\n\u5bf9\u4efb\u610f\u7684 k < n, \u5b58\u5728\u81f3\u5c11 2 \u4e2a k \u9636\u5b50\u7acb\u65b9\u4f53, \u6ee1\u8db3\u5176\u4e2d\u7684\u6570\u5b57\u53d6\u81ea\u4e00\u6bb5\u8fde\u7eed\u533a\u95f4\u3002\n\nProblem E. Gripping Story\n\u7a7a\u95f4\u4e2d\u6709\u4e00\u5806\u5438\u76d8\u3002\n\u3002\u3002\u6bcf\u4e2a\u5438\u76d8\u7528 (xi, yi, mi, pi, ri) \u8868\u793a\u3002\u3002\u3002\n\u3002\u3002\u81ea\u8eab\u5750\u6807\uff0c\u91cd\u91cf\u3002\u3002\u3002\u80fd\u6293\u8d77\u6765\u7684\u6700\u5927\u7269\u54c1\u7684\u91cd\u91cf\uff0c\u4ee5\u53ca\u4f5c\u7528\u8303\u56f4\u3002\u3002\u3002\u3002\n\u3002\u3002\u73b0\u7ed9\u5b9a\u98de\u8239\u521d\u59cb\u5750\u6807\u3002\u3002(x0, y0)\u3002\u3002\u521d\u59cb\u5438\u76d8\uff08p0, r0)...\n\u95ee\u6700\u591a\u53ef\u4ee5\u6536\u96c6\u591a\u5c11\u4e2a\u5438\u76d8\u3002\u3002\u3002\n\uff08\u3002\u3002\u4e00\u65e6\u5f97\u5230\u4e00\u4e2a\u5438\u76d8\u4ee5\u540e\u4ee5\u540e\u5c31\u53ef\u4ee5\u65e0\u9650\u66f4\u6362\u4f7f\u7528\u3002\u3002\n\uff08\u3002\u3002\u3002\u6ce8\u610f\u6ce8\u610f\u98de\u8239\u672c\u8eab\u4e0d\u52a8\u4e0d\u52a8\u4e0d\u52a8\uff01\u3002\u3002\u5e76\u4e14\u5438\u76d8\u5438\u5230\u98de\u8239\u91cc\u624d\u80fd\u4f7f\u7528\u3002\u3002\u3002OOrz\u3002\u3002\n\n\n<!--more--><\/p>\n<h3>Analysis: <\/h3>\n<p>Problem C. Delivering Carcinogen<br \/>\n\u5148\u907f\u514d\u8ba8\u8bba\u65cb\u8f6c\u8fc7\u7a0b\u3002\u3002\u3002\u4e8c\u5206\u7b54\u6848 x \u3002\u3002\u7136\u540e\u884c\u661f p \u76f4\u63a5\u77ac\u79fb\u5230\u5b83\u8be5\u51fa\u73b0\u7684\u4f4d\u7f6e\u3002\u3002\u3002\u7136\u540e\u5224\u65ad d(p&#8217;) <= x*v .. \n\u7136\u540e\u5b50\u95ee\u9898 d(p') \u5c31\u662f\u6784\u9020\u98de\u8239\u7ed5\u9053\u8fd9\u4e2a\u4f4d\u7f6e\u7684\u6700\u77ed\u8def\u5f84\u3002\u3002\u6839\u636e\u4e24\u6761\u5207\u7ebf\u4ea7\u751f\u7684\u5939\u89d2\u5206\u60c5\u51b5\u8ba8\u8bba\u3002\u3002\uff08\n\u5927\u6982\u67092\u79cd\u60c5\u51b5\u3002\u3002\u4e00\u79cd\u662f\u76f4\u7ebf\u3002\u3002\u7b2c\u4e8c\u79cd\u662f 2 \u6761\u5207\u7ebf + 1\u6bb5\u5706\u5f27\u3002\u3002\u3002\n\n<a href=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2012\/06\/figure1.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"275\" data-permalink=\"https:\/\/www.shuizilong.com\/house\/archives\/codeforces-round-125\/figure1\/\" data-orig-file=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2012\/06\/figure1.png\" data-orig-size=\"738,505\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"figure1\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2012\/06\/figure1-300x205.png\" data-large-file=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2012\/06\/figure1.png\" src=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2012\/06\/figure1.png\" alt=\"\" title=\"figure1\" width=\"738\" height=\"505\" class=\"aligncenter size-full wp-image-275\" srcset=\"https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2012\/06\/figure1.png 738w, https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2012\/06\/figure1-300x205.png 300w, https:\/\/www.shuizilong.com\/house\/wp-content\/uploads\/2012\/06\/figure1-438x300.png 438w\" sizes=\"auto, (max-width: 738px) 100vw, 738px\" \/><\/a><\/p>\n<p>\u3002\u3002\u3002\u5148\u65cb\u8f6c s \u70b9\u5230 x \u8f74\u4e0a\u3002\u3002\u3002\u8003\u8651\u8fb9\u754c\u60c5\u51b5\u3001\u628a p \u70b9\u79fb\u52a8\u5230\u8ddd\u79bb s \u70b9\u6700\u8fdc\u7684\u4ecd\u53ef\u76f4\u7ebf\u8bbf\u95ee\u7684\u4f4d\u7f6e\u3002\u3002\uff08\u79f0\u4e3a\u4e34\u754c\u60c5\u51b5\u3002<br \/>\n\u90a3\u4e48\u8fd9\u91cc\u7684 \u2220sOp \u662f\u4e00\u4e2a\u91cd\u8981\u7684\u5e38\u6570\u3002\u3002\uff08p \u70b9\u5728\u66f4\u9760\u5de6\u4f4d\u7f6e\u7684\u8bdd\u5c31\u662f 2\u6761\u5207\u7ebf + 1\u6bb5\u5706\u5f27\u7684\u60c5\u51b5\u4e86\u3002\u3002<br \/>\n\u53ef\u4ee5\u89e3 \u25b3pOm \u548c \u25b3sOm \u8fd9\u4e24\u7ec4\u76f4\u89d2\u4e09\u89d2\u5f62\u5f97\u5230\u3002\u3002\u3002\uff08m \u662f\u5207\u70b9\u3002\u3002<br \/>\n\u3002\u3002\uff08\u540c\u65f6\u6ce8\u610f\u5230 2\u6761\u5207\u7ebf + 1\u6bb5\u5706\u5f27\u60c5\u51b5\u65f6 2\u6761\u5207\u7ebf \u7684\u957f\u5ea6\u56fa\u5b9a\u4e0d\u53d8\uff0c\u5c31\u662f\u56fe\u4e2d\u7684 pm + ms \u3002<\/p>\n<p>\uff08\u4ee3\u7801\u4e2d\u7684 alpha \u662f\u521d\u59cb\u65cb\u8f6c\u89d2\uff0cbeta \u662f\u4e34\u754c\u60c5\u51b5\u65f6\u7684 \u2220sOp \u3002\u3002<br \/>\n\u3002\u3002 theta \u662f\u5f53\u524d p \u70b9\u5177\u4f53\u6240\u5728\u4f4d\u7f6e\u3002\u3002\u3002delta \u662f\u6247\u5f62\u7684\u5f27\u5ea6\u3002\u3002\uff09<\/p>\n<pre class=\"brush: cpp; collapse: true; first-line: 1; light: false; title: Problem C. Delivering Carcinogen.cpp; toolbar: true; notranslate\" title=\"Problem C. Delivering Carcinogen.cpp\">\r\nconst int N = 100009;\r\n\r\nPo s, p, o;\r\nDB R_, R, r, ss, vs, vp;\r\nDB alpha, beta, theta, delta;\r\n\r\ninline void _R(DB &amp;x){\r\n    x = fmod(x, 2*PI); if (x &lt; 0) x += 2*PI;\r\n}\r\n\r\nDB d(){\r\n    if(theta &lt;= beta || theta &gt;= 2*PI - beta) return sqrt(sqr(R_) + sqr(R) - 2*R_*R*cos(theta));\r\n    else{\r\n        delta = PI - beta - fabs(PI - theta);\r\n        return ss + delta * r;\r\n    }\r\n}\r\n\r\nbool f(DB x){\r\n    \/\/cout &lt;&lt; x &lt;&lt; endl;\r\n    theta = x * vp + alpha, _R(theta);\r\n    return d() &lt;= vs * x;\r\n}\r\n\r\n\r\nint main(){\r\n\r\n#ifndef ONLINE_JUDGE\r\n    freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\r\n#endif\r\n\r\n    p.input(), RD(vp), s.input(), RD(vs, r);\r\n\r\n    R_ = s.length(), R = p.length(), vp \/= R;\r\n    ss = sqrt(sqr(R_) - sqr(r)) + sqrt(sqr(R) - sqr(r));\r\n    alpha = p.atan() - s.atan(), _R(alpha);\r\n    beta = acos(r \/ R_) + acos(r \/ R), _R(beta);\r\n\r\n    DB ll = 0, rr = (ss + PI*R) * vs;\r\n    REP(i, 100){\r\n        DB m = (ll + rr) \/ 2;\r\n        if (f(m)) rr = m; else ll = m;\r\n    }\r\n    OT(ll);\r\n}\r\n<\/pre>\n<p>Problem D. Cube Snake<br \/>\n\u7ed9\u5b9a\u4e00\u4e2a n \u9636\u7acb\u65b9\u4f53\uff0c\u8981\u6c42\u6784\u9020\u6ee1\u8db3\u4e0b\u5217\u6027\u8d28\u7684\u8def\u5f84\uff1a<br \/>\n\u5bf9\u4efb\u610f\u7684 k < n, \u5b58\u5728\u81f3\u5c11 2 \u4e2a k \u9636\u5b50\u7acb\u65b9\u4f53, \u6ee1\u8db3\u5176\u4e2d\u7684\u6570\u5b57\u53d6\u81ea\u4e00\u6bb5\u8fde\u7eed\u533a\u95f4\u3002\n\n\u4e2a\u4eba\u8ba4\u4e3a\u662f\u8fd9\u5957\u9898\u91cc\u9762\u601d\u7ef4\u590d\u6742\u5ea6\u6700\u9ad8\u7684\u4e00\u9053\u3002\u3002\u561b\u3002\u3002\uff08\u867d\u7136\u9898\u76ee\u4e00\u8bfb\u5c31\u660e\u767d\u3002\u3002\u3002\n\n\u9996\u5148\u5bf9\u89e3\u505a\u4e00\u5b9a\u7684\u731c\u6d4b\uff1a\n\u3002\u3002\u6700\u7ec8\u89e3\u662f\u7f8e\u7684\u3002\u3002(\u3002\u3002\u5927\u6982\u81f3\u5c11\u4e5f\u8981\u662f\u9012\u5f52\u7684\u3001\u5bf9\u79f0\u7684\u8fd9\u6837\u3002\u3002)\u3002\u3002\n\u3002\u3002\u53ef\u80fd\u8981\u5947\u5076\u8ba8\u8bba\u3002(\u3002\u751a\u81f3\u66f4\u590d\u6742\u7684\u8ba8\u8bba\u3002\u3002\u603b\u4e4b\u6bd4\u8f83\u7406\u60f3\u7684\u6784\u9020\u65b9\u6848\u53ef\u4ee5\u5c3d\u91cf\u907f\u514d\u8ba8\u8bba\u3002\u6216\u8005\u8ba8\u8bba\u524d\u540e\u5171\u540c\u7684\u90e8\u5206\u6bd4\u8f83\u591a\u3002)\u3002\u3002\n\n\u5927\u6982\u5c31\u662f\u8fd9\u7c7b\u9898\u7684\u4e00\u4e2a\u65b9\u5411\u3002\u3002\u9700\u8981\u8ba8\u8bba\u7684\u5730\u65b9\u8d8a\u591a\u3002\u3002\u751a\u81f3\u6700\u7ec8\u89e3\u4e0d\u662f\u5bf9\u79f0\u7684\u8bdd\u8fd9\u7c7b\u9898\u7684\u96be\u5ea6\u5c31\u4f1a\u5927\u5927\u589e\u52a0\u3002\u3002\u3002\n\n\u6bd4\u8f83\u79d1\u5b66\u7684\u65b9\u6cd5\u8fd8\u662f\u5f52\u7eb3\u4e8c\u7ef4\u60c5\u51b5\u3002\u3002\n\n\u5b9a\u4e49\u7ea2\u7ebf\u548c\u84dd\u7ebf\u3002\u5206\u522b\u4e3a\u4e24\u4e2a\u6d3b\u52a8\u7aef\u70b9\u3002\uff08\u4e00\u4e2a\u9012\u589e\u4e00\u4e2a\u9012\u51cf\u3002\u3002\n\u5047\u8bbe\u73b0\u5728\u524d\u9762\u5c0f\u4e8e\u7b49\u4e8e k \u9636\u60c5\u51b5\u5df2\u7ecf\u5168\u90e8\u6ee1\u8db3\uff0c\u73b0\u5728\u5f97\u5230\u4e00\u4e2a k*(k+1) \u7684\u77e9\u5f62\uff0c\u5e76\u4e14\u6d3b\u52a8\u7aef\u70b9\u5904\u5728\u5bf9\u89d2\u4f4d\u7f6e\u3002\n\u90a3\u4e48\u4e92\u76f8\u5411\u76f8\u53cd\u65b9\u5411\u7ed8\u4e00\u6bb5\u7ebf\u5373\u53ef\u5f97\u5230 (k+1) \u9636\u7684\u60c5\u51b5\u3002\u3002\u3002\u3001\n\u6700\u540e\u5230 n \u4ee5\u540e\u968f\u4fbf\u780d\u6389\u4e00\u6b21\u5c31\u80fd\u5f97\u5230\u7ed3\u679c\u3002\u3002\u3002\n\n\u4e8c\u7ef4\u7684\u4ee3\u7801\u597d\u50cf\u4e0d\u592a\u96be\u5b9e\u73b0\u3002\u30020w0\u3002\n\n[cpp collapse=\"true\" firstline=\"1\" highlight=\"\" title=\"\u6211\u662f\u2468\u6211\u53ea\u80fd\u7406\u89e3\u4f4e\u7ef4\u4e16\u754c.cpp\"]\nconst int N = 109;\nint A[N][N], ox, oy;\nint n, p, q;\n\nconst int Red = 0, Blue = 1;\nconst int Right = 0, Down = 1, Left = 2, Up = 3;\n\nvoid spin(int n, int c, int d){\n    if (c == Red){\n        switch (d){\n            case Right:\n                REP(i, n) A[ox][oy + i] = q--;\n                break;\n            case Down:\n                REP(i, n) A[ox + i][oy + n] = q--;\n                break;\n            case Left:\n                DWN(i, n, 0) A[ox + n][oy + i] = q--;\n                break;\n            default:\n                DWN(i, n, 0) A[ox + i][oy] = q--;\n        }\n    }\n    else {\n        switch (d){\n            case Right:\n                REP(i, n) A[ox + 0][oy + i] = p++;\n                break;\n            case Down:\n                REP(i, n) A[ox + i][oy + n] = p++;\n                break;\n            case Left:\n                DWN(i, n, 0) A[ox + n][oy + i] = p++;\n                break;\n            default:\n                DWN(i, n, 0) A[ox + i][oy] = p++;\n        }\n    }\n}\n\nvoid gao(){\n    ox = n, oy = n, q = 0;\n    A[ox + 0][oy + 0] = 1, A[ox + 0][oy + 1] = 4;\n    A[ox + 1][oy + 0] = 2, A[ox + 1][oy + 1] = 3; if (n == 2) return;\n    A[ox + 0][oy + 2] = 5; A[ox + 1][oy + 2] = 6, p = 7;\n\n    FOR_1(cur, 3, n){\n        if (cur&amp;1) --ox; else --oy;\n        spin(cur, Red, (Down + cur) % 4);\n        spin(cur, Blue, (Up + cur) % 4);\n    }\n}\n\nvoid print(){\n\n    if (n % 4 == 0) ++oy; else if (n % 4 == 1) ++ox;\n\n    REP(x, n){\n        REP(y, n) printf(&quot;%d &quot;, A[ox + x][oy + y] - q);\n        puts(&quot;&quot;);\n    }\n}\n\nint main(){\n\n#ifndef ONLINE_JUDGE\n    \/\/freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\n#endif\n\n    while (scanf(&quot;%d&quot;, &amp;n) != EOF &amp;&amp; n){\n        if (n == 1) puts(&quot;1&quot;);\n        else gao(), print();\n    }\n}\n[\/cpp]\n\n\u3002\u3002\u3002\u90a3\u4e48\u4ece\u4e8c\u7ef4\u5230\u4e09\u7ef4\u60c5\u51b5\u7a0d\u7a0d\u590d\u6742\u4e86\u4e00\u70b9\u3002\u3002\u3002\n\u6bd4\u8f83\u503c\u5f97\u8003\u8651\u7684\u95ee\u9898\u662f\u5982\u4f55\u8ba9\u524d\u540e\u4e24\u9636\u7684\u6d3b\u52a8\u7aef\u70b9\u90fd\u5904\u5728\u76f8\u540c\u7684\u4f4d\u7f6e\u3002\u3002\u6216\u8005\u81f3\u5c11\u4e5f\u5904\u5728\u540c\u4e00\u4e2a\u9762\u5f7c\u6b64\u4e92\u6362\u4e2a\u4f4d\u7f6e\u3002\u3002\u3002\uff09\n\uff08\u3002\u3002\u4e09\u7ef4\u7684\u60c5\u51b5\u5982\u679c\u5199\u8111\u6b8b\u7684\u8bdd\u6bd4\u8f83\u96be\u4ee5 Debug\u3002\u3002\u6211\u540e\u6765\u5199\u4e00\u4e2a\u51fd\u6570\u6765\u89c2\u5bdf\u67d0\u4e2a\u89d2\u5ea6\u7684\u89c6\u56fe\u3002\u3002\uff09\n\n[cpp collapse=\"true\" firstline=\"1\" highlight=\"\" title=\"Problem D. Cube Snake.cpp\"]\nconst int N = 109;\nint A[N][N][N], ox, oy, oz;\nint n, p, q;\n\nvoid watchFront(){\n    n += 2; REP(i, n){\n        REP(j, n) printf(&quot;%d &quot;, A[ox + i][oy][oz + j] - q);\n        puts(&quot;&quot;);\n    }\n}\n\nvoid gao(){\n\n    ox = n, oy = n, q = 0;\n\n    A[ox + 0][oy + 0][oz + 0] = 1, A[ox + 0][oy + 0][oz + 1] = 4;\n    A[ox + 0][oy + 1][oz + 0] = 2, A[ox + 0][oy + 1][oz + 1] = 3;\n\n    A[ox + 1][oy + 0][oz + 0] = 6, A[ox + 1][oy + 0][oz + 1] = 5;\n    A[ox + 1][oy + 1][oz + 0] = 7, A[ox + 1][oy + 1][oz + 1] = 8;\n\n    if (n == 2) return;\n\n    A[ox + 2][oy + 0][oz + 0] = 11, A[ox + 2][oy + 0][oz + 1] = 12;\n    A[ox + 2][oy + 1][oz + 0] = 10, A[ox + 2][oy + 1][oz + 1] = 9;\n\n    p = 13;\n\n    int x, y, z; bool rev = false;\n\n#define Blue (rev ? q-- : p++)\n#define Red (rev ? p++ : q--)\n\n    FOR_1(cur, 3, n){\n\n        if (cur &amp; 1){\n\n            --oy; REP(i, cur-1) A[ox][oy][oz + i] = Red;\n\n            DWN(i, cur-1, 0){\n                if (i&amp;1) DWN_1(j, cur-1, 1) A[ox + j][oy][oz + i] = Blue;\n                else REP_1(j, cur-1) A[ox + j][oy][oz + i] = Blue;\n            }\n\n            x = 0, y = 0, z = cur - 1;\n            A[ox + x][oy + y][oz + z] = Red;\n\n            REP_1(i, cur - 1){\n                if (i&amp;1){\n                    ++x; --y; REP(j, i+1) A[ox + x][oy + ++y][oz + z] = Red;\n                    REP(j, i) A[ox + --x][oy + y][oz + z] = Red;\n                }\n                else {\n                    ++y; --x; REP(j, i+1) A[ox + ++x][oy + y][oz + z] = Red;\n                    REP(j, i) A[ox + x][oy + --y][oz + z] = Red;\n                }\n            }\n\n            --oz;\n            x = cur - 1, y = 0, z = 0;\n            A[ox + x][oy + y][oz + z] = Blue;\n\n            REP_1(i, cur - 1){\n                if (i&amp;1){\n                    --x; --y; REP(j, i+1) A[ox + x][oy + ++y][oz + z] = Blue;\n                    REP(j, i) A[ox + ++x][oy + y][oz + z] = Blue;\n                }\n                else {\n                    ++y; ++x; REP(j, i+1) A[ox + --x][oy + y][oz + z] = Blue;\n                    REP(j, i) A[ox + x][oy + --y][oz + z] = Blue;\n                }\n            }\n        }\n        else{\n\n            --oy; REP(i, cur) A[ox][oy][oz + i] = Red;\n\n            DWN(i, cur, 0){\n                if (i&amp;1) DWN_1(j, cur-2, 1) A[ox + j][oy][oz + i] = Blue;\n                else REP_1(j, cur-2) A[ox + j][oy][oz + i] = Blue;\n            }\n\n            x = cur - 1, y = 0, z = 0;\n            A[ox + x][oy + y][oz + z] = Blue;\n\n            REP_1(i, cur - 1){\n                if (i&amp;1){\n                    --z; ++y; REP(j, i+1) A[ox + x][oy + y][oz + ++z] = Blue;\n                    REP(j, i) A[ox + x][oy + --y][oz + z] = Blue;\n                }\n                else {\n                    ++z; --y; REP(j, i+1) A[ox + x][oy + ++y][oz + z] = Blue;\n                    REP(j, i) A[ox + x][oy + y][oz + --z] = Blue;\n                }\n            }\n\n            --ox, x = 0, y = 0, z = cur - 1;\n            A[ox + x][oy + y][oz + z] = Red;\n\n            REP_1(i, cur - 1){\n                if (i&amp;1){\n                    ++y; ++z; REP(j, i+1) A[ox + x][oy + y][oz + --z] = Red;\n                    REP(j, i) A[ox + x][oy + --y][oz + z] = Red;\n                }\n                else {\n                    --z; --y; REP(j, i+1) A[ox + x][oy + ++y][oz + z] = Red;\n                    REP(j, i) A[ox + x][oy + y][oz + ++z] = Red;\n                }\n            }\n\n            rev = !rev;\n        }\n\n        rev = !rev;\n    }\n}\n\nvoid print(){\n\n    if (n % 4 == 3) ++oz; else if (n % 4 == 0) ++ox;\n\n    REP(x, n){\n        REP(y, n){\n            REP(z, n) printf(&quot;%d &quot;, A[ox + x][oy + y][oz + z] - q);\n            puts(&quot;&quot;);\n        }\n        puts(&quot;&quot;);\n    }\n}\n\nint main(){\n\n#ifndef ONLINE_JUDGE\n    \/\/freopen(&quot;in.txt&quot;, &quot;r&quot;, stdin);\n#endif\n\n    while (scanf(&quot;%d&quot;, &amp;n) != EOF &amp;&amp; n){\n        if (n == 1) puts(&quot;1&quot;);\n        else gao(), print();\n    }\n}\n[\/cpp]\n\n\nProblem E. Gripping Story\n\u3002\u3002\u3002\u5750\u6807\u4fe1\u606f\u5728\u8fd9\u9898\u91cc\u6ca1\u6709\u51e0\u4f55\u610f\u4e49\u7684\u3002\u3002\u4e8e\u662f\u62bd\u8c61\u4ee5\u540e\u5c31\u6210\u4e86\u7ef4\u62a4\u4e00\u5806\u6570\u5217\u7684\u95ee\u9898\u3002\u3002\u3002\n\u3002\u3002\u53ef\u4ee5\u6811\u72b6\u6570\u7ec4\u5957\u5e73\u8861\u6811\u88f8\u641e\u3002\u3002\u3002\u3002\n\n\n\n<h3>Code: <\/h3>\n<p><a href=\"http:\/\/codeforces.com\/contest\/198\/submission\/1815153\">A<\/a> <a href=\"http:\/\/codeforces.com\/contest\/198\/submission\/1821609\">B<\/a> <a href=\"http:\/\/codeforces.com\/contest\/198\/submission\/1822920\">C<\/a> <a href=\"http:\/\/codeforces.com\/contest\/198\/submission\/1838201\">D<\/a> <a href=\"http:\/\/codeforces.com\/contest\/198\/submission\/1823195\">E<\/a><\/p>\n<h3>External link: <\/h3>\n<p><a href=\"http:\/\/codeforces.com\/contest\/198\/room\/2\">http:\/\/codeforces.com\/contest\/198\/room\/2<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Brief description: Problem A. About Bacteria &#8230; \u57f9\u517b\u76bf\u4e2d\u7684 x \u53ea\u7ec6\u83cc\u4e0b\u4e00\u79d2\u4f1a\u7e41\u884d\u51fa kx+b \u53ea\u7ec6\u83cc\u3002\u3002\uff08\u3002\u3002\u3002 \u95ee\u5982\u679c\u521d\u59cb\u57f9\u517b\u76bf\u4e2d\u6709 t \u53ea\u7ec6\u83cc\uff0c\u81f3\u5c11\u591a\u5c11\u79d2\u624d\u53ef\u4ee5\u7e41\u884d\u51fa\u4e0d\u5c11\u4e8e z \u53ea\u7ec6\u83cc\u3002 \u3002\u3002\u3002z \u4e3a\u521d\u59cb\u4e3a\u4e00\u53ea\u7ec6\u83cc\u65f6\uff0c\u7e41\u884d n \u79d2\u7684\u7ec6\u83cc\u603b\u6570\u3002\u3002\u3002\uff08\u3002\u3002\u3002 (\u7565\uff0c\u7b97\u672f\u9898\u3002\u3002\u4e0d\u8981\u628a z \u771f\u7ed9\u7b97\u51fa\u6765\u5373\u53ef\u3002\u3002 Problem B. Jumping on Walls \u4e00\u4e2a\u5fcd\u8005\u5728\u4e00\u4e2a\u5751\u91cc\uff0c \u5de6\u53f3\u5404\u6709\u4e00\u9762\u5899\uff0c\u5899\u4e0a\u6709\u4e00\u4e9b\u969c\u788d\uff0c\u521d\u59cb\u5728\u6700\u4e0b\u89d2\u3002 \u6bcf\u79d2\u949f\u53ef\u4ee5\u4e0a\u4e0b\u79fb\u52a8\u4e00\u683c\uff0c\u6216\u8005\u8df3\u5230\u5bf9\u9762\u5899\u7684\u6070\u597d +k \u4f4d\u7f6e\u3002\u3002 \u3002\u3002\u95ee\u6700\u7ec8\u80fd\u51fa\u8df3\u51fa\u8fd9\u4e2a\u5751\u3002\u3002 \uff08\u7565\uff0c Hash Dp \u6216\u8005 BFS() \u90fd\u884c\u3002\u3002\u3002\u3002 Problem C. Delivering Carcinogen \u7ed9\u5b9a\u4e00\u9897\u884c\u661f\u5750\u6807 (xp, yp)\uff0c\u8f68\u9053\u534a\u5f84 R\uff0c\u56f4\u7ed5\u6052\u5fc3\u8fd0\u8f6c\u7684\u7ebf\u901f\u5ea6 vp\uff0c \u4ee5\u53ca\u4e00\u4e2a\u98de\u8239\u5750\u6807 (x, y)\uff0c\u98de\u8239\u901f\u5ea6 v\u3002\u3002\u95ee\u5230\u8fbe p [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[18],"tags":[24,25],"class_list":["post-271","post","type-post","status-publish","format-standard","hentry","category-codeforces","tag-24","tag-25"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2tdP7-4n","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/271","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/comments?post=271"}],"version-history":[{"count":1,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/271\/revisions"}],"predecessor-version":[{"id":272,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/posts\/271\/revisions\/272"}],"wp:attachment":[{"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/media?parent=271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/categories?post=271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuizilong.com\/house\/wp-json\/wp\/v2\/tags?post=271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}