{"id":169,"date":"2025-11-19T20:43:00","date_gmt":"2025-11-19T12:43:00","guid":{"rendered":"https:\/\/www.tangent0712.top\/?p=169"},"modified":"2025-11-26T10:27:12","modified_gmt":"2025-11-26T02:27:12","slug":"%e6%b4%9b%e8%b0%b7%e9%a2%98%e5%8d%95%e3%80%90%e7%ae%97%e6%b3%951-1%e3%80%91%e6%a8%a1%e6%8b%9f%e4%b8%8e%e9%ab%98%e7%b2%be%e5%ba%a61","status":"publish","type":"post","link":"https:\/\/www.tangent0712.top\/index.php\/2025\/11\/19\/%e6%b4%9b%e8%b0%b7%e9%a2%98%e5%8d%95%e3%80%90%e7%ae%97%e6%b3%951-1%e3%80%91%e6%a8%a1%e6%8b%9f%e4%b8%8e%e9%ab%98%e7%b2%be%e5%ba%a61\/","title":{"rendered":"\u6d1b\u8c37\u9898\u5355:\u3010\u7b97\u6cd51-1\u3011\u6a21\u62df\u4e0e\u9ad8\u7cbe\u5ea6(1)"},"content":{"rendered":"<h1>P1042 [NOIP 2003 \u666e\u53ca\u7ec4] \u4e52\u4e53\u7403<\/h1>\n<h2>\u9898\u76ee\u80cc\u666f<\/h2>\n<p>\u56fd\u9645\u4e52\u8054\u73b0\u5728\u4e3b\u5e2d\u6c99\u62c9\u62c9\u81ea\u4ece\u4e0a\u4efb\u4ee5\u6765\u5c31\u7acb\u5fd7\u4e8e\u63a8\u884c\u4e00\u7cfb\u5217\u6539\u9769\uff0c\u4ee5\u63a8\u52a8\u4e52\u4e53\u7403\u8fd0\u52a8\u5728\u5168\u7403\u7684\u666e\u53ca\u3002\u5176\u4e2d $11$ \u5206\u5236\u6539\u9769\u5f15\u8d77\u4e86\u5f88\u5927\u7684\u4e89\u8bae\uff0c\u6709\u4e00\u90e8\u5206\u7403\u5458\u56e0\u4e3a\u65e0\u6cd5\u9002\u5e94\u65b0\u89c4\u5219\u53ea\u80fd\u9009\u62e9\u9000\u5f79\u3002\u534e\u534e\u5c31\u662f\u5176\u4e2d\u4e00\u4f4d\uff0c\u4ed6\u9000\u5f79\u4e4b\u540e\u8d70\u4e0a\u4e86\u4e52\u4e53\u7403\u7814\u7a76\u5de5\u4f5c\uff0c\u610f\u56fe\u5f04\u660e\u767d $11$ \u5206\u5236\u548c $21$ \u5206\u5236\u5bf9\u9009\u624b\u7684\u4e0d\u540c\u5f71\u54cd\u3002\u5728\u5f00\u5c55\u4ed6\u7684\u7814\u7a76\u4e4b\u524d\uff0c\u4ed6\u9996\u5148\u9700\u8981\u5bf9\u4ed6\u591a\u5e74\u6bd4\u8d5b\u7684\u7edf\u8ba1\u6570\u636e\u8fdb\u884c\u4e00\u4e9b\u5206\u6790\uff0c\u6240\u4ee5\u9700\u8981\u4f60\u7684\u5e2e\u5fd9\u3002<\/p>\n<h2>\u9898\u76ee\u63cf\u8ff0<\/h2>\n<p>\u534e\u534e\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u8fdb\u884c\u5206\u6790\uff0c\u9996\u5148\u5c06\u6bd4\u8d5b\u6bcf\u4e2a\u7403\u7684\u80dc\u8d1f\u5217\u6210\u4e00\u5f20\u8868\uff0c\u7136\u540e\u5206\u522b\u8ba1\u7b97\u5728 <code>11<\/code> \u5206\u5236\u548c <code>21<\/code>$ \u5206\u5236\u4e0b\uff0c\u53cc\u65b9\u7684\u6bd4\u8d5b\u7ed3\u679c\uff08\u622a\u81f3\u8bb0\u5f55\u672b\u5c3e\uff09\u3002<\/p>\n<p>\u6bd4\u5982\u73b0\u5728\u6709\u8fd9\u4e48\u4e00\u4efd\u8bb0\u5f55\uff0c\uff08\u5176\u4e2d <code>W<\/code> \u8868\u793a\u534e\u534e\u83b7\u5f97\u4e00\u5206\uff0c<code>L<\/code> \u8868\u793a\u534e\u534e\u5bf9\u624b\u83b7\u5f97\u4e00\u5206\uff09\uff1a<\/p>\n<p>$$\n\\texttt{WWWWWWWWWWWWWWWWWWWWWWLW}\n$$<\/p>\n<p>\u5728 11\u5206\u5236\u4e0b\uff0c\u6b64\u65f6\u6bd4\u8d5b\u7684\u7ed3\u679c\u662f\u534e\u534e\u7b2c\u4e00\u5c40 11 \u6bd4 0 \u83b7\u80dc\uff0c\u7b2c\u4e8c\u5c40 11\u6bd4 0\u83b7\u80dc\uff0c\u6b63\u5728\u8fdb\u884c\u7b2c\u4e09\u5c40\uff0c\u5f53\u524d\u6bd4\u5206 1 \u6bd4 1\u3002\u800c\u5728 21 \u5206\u5236\u4e0b\uff0c\u6b64\u65f6\u6bd4\u8d5b\u7ed3\u679c\u662f\u534e\u534e\u7b2c\u4e00\u5c4021 \u6bd40 \u83b7\u80dc\uff0c\u6b63\u5728\u8fdb\u884c\u7b2c\u4e8c\u5c40\uff0c\u6bd4\u52062 \u6bd41\u3002\u5982\u679c\u4e00\u5c40\u6bd4\u8d5b\u521a\u5f00\u59cb\uff0c\u5219\u6b64\u65f6\u6bd4\u5206\u4e3a 0\u6bd40\u3002\u76f4\u5230\u5206\u5dee\u5927\u4e8e\u6216\u8005\u7b49\u4e8e 2\uff0c\u624d\u4e00\u5c40\u7ed3\u675f\u3002<\/p>\n<p><strong>\u6ce8\u610f\uff1a\u5f53\u4e00\u5c40\u6bd4\u8d5b\u7ed3\u675f\u540e\uff0c\u4e0b\u4e00\u5c40\u7acb\u523b\u5f00\u59cb<\/strong>\u3002<\/p>\n<h2>\u8f93\u5165\u683c\u5f0f<\/h2>\n<p>\u6bcf\u4e2a\u8f93\u5165\u6587\u4ef6\u5305\u542b\u82e5\u5e72\u884c\u5b57\u7b26\u4e32\uff0c\u5b57\u7b26\u4e32\u7531\u5927\u5199\u7684 W \u3001 L \u548c  E \u7ec4\u6210\u3002\u5176\u4e2d  E \u8868\u793a\u6bd4\u8d5b\u4fe1\u606f\u7ed3\u675f\uff0c\u7a0b\u5e8f\u5e94\u8be5\u5ffd\u7565 E \u4e4b\u540e\u7684\u6240\u6709\u5185\u5bb9\u3002<\/p>\n<h2>\u8f93\u51fa\u683c\u5f0f<\/h2>\n<p>\u8f93\u51fa\u7531\u4e24\u90e8\u5206\u7ec4\u6210\uff0c\u6bcf\u90e8\u5206\u6709\u82e5\u5e72\u884c\uff0c\u6bcf\u4e00\u884c\u5bf9\u5e94\u4e00\u5c40\u6bd4\u8d5b\u7684\u6bd4\u5206\uff08\u6309\u6bd4\u8d5b\u4fe1\u606f\u8f93\u5165\u987a\u5e8f\uff09\u3002\u5176\u4e2d\u7b2c\u4e00\u90e8\u5206\u662f 11\u5206\u5236\u4e0b\u7684\u7ed3\u679c\uff0c\u7b2c\u4e8c\u90e8\u5206\u662f 21\u5206\u5236\u4e0b\u7684\u7ed3\u679c\uff0c\u4e24\u90e8\u5206\u4e4b\u95f4\u7531\u4e00\u4e2a\u7a7a\u884c\u5206\u9694\u3002<\/p>\n<h2>\u8f93\u5165\u8f93\u51fa\u6837\u4f8b #1<\/h2>\n<h3>\u8f93\u5165 #1<\/h3>\n<pre><code>WWWWWWWWWWWWWWWWWWWW\nWWLWE<\/code><\/pre>\n<h3>\u8f93\u51fa #1<\/h3>\n<pre><code>11:0\n11:0\n1:1\n\n21:0\n2:1<\/code><\/pre>\n<h2>\u8bf4\u660e\/\u63d0\u793a<\/h2>\n<p>\u6bcf\u884c\u81f3\u591a 25 \u4e2a\u5b57\u6bcd\uff0c\u6700\u591a\u6709 2500 \u884c\u3002<\/p>\n<p><strong>\u3010\u7ba1\u7406\u5458\u9644\u6ce8\u3011<\/strong><\/p>\n<p>\u672c\u9898\u4e3a\u975e\u5e38\u65e9\u671f\u7684\u8bd5\u9898\uff0c\u5728\u6d4b\u8bd5\u70b9\u4e2d\u51fa\u73b0\u4e86\u5982\u4e0b\u4e24\u4e2a\u95ee\u9898\u3002\u5728\u6d1b\u8c37\u4e0a\u8fd9\u4e24\u4e2a\u6d4b\u8bd5\u70b9\u7684\u758f\u6f0f\u88ab\u4fdd\u7559\uff1a<\/p>\n<ol>\n<li>\u6709\u4e00\u4e2a\u6d4b\u8bd5\u70b9\u5b9e\u9645\u4e0a\u6709 2501 \u884c\u6570\u636e\u3002<\/li>\n<li>\n<p>\u6709\u4e00\u4e2a\u6d4b\u8bd5\u70b9\u7684\u8f93\u5165\u6570\u636e\u51fa\u73b0\u4e86\u975e  W \u3001  L \u548c  E \u7684\u5b57\u7b26\uff0c\u4e0d\u7b26\u5408\u8f93\u5165\u683c\u5f0f\u7684\u8981\u6c42\u3002\u4e0d\u8fc7\u8fd9\u4e9b\u5b57\u7b26\u53ea\u51fa\u73b0\u5728 E \u5b57\u7b26\u4e4b\u540e\uff0c\u6309\u9898\u76ee\u8981\u6c42\u5ffd\u7565 E \u4e4b\u540e\u7684\u5168\u90e8\u5b57\u7b26\u5373\u53ef\u3002<\/p>\n<p><strong>\u3010\u9898\u76ee\u6765\u6e90\u3011<\/strong><\/p>\n<\/li>\n<\/ol>\n<p>NOIP 2003 \u666e\u53ca\u7ec4\u7b2c\u4e00\u9898<\/p>\n<h2>\u89e3\u6790<\/h2>\n<p>\u6b63\u5982\u9898\u5355\u7684\u540d\u5b57,\u672c\u9898\u7684\u5173\u95ed\u5728\u4e8e\u7406\u89e3\u6bd4\u8d5b\u89c4\u5219:<\/p>\n<ul>\n<li>\u4e00\u5c40\u7ed3\u675f\u7684\u540c\u65f6,\u53e6\u4e00\u5c40\u7acb\u5373\u5f00\u59cb:\u5982\u679c\u6700\u540e\u4e00\u5c40\u521a\u597d\u7ed3\u675f,\u90a3\u4e48\u6700\u540e\u5c06\u518d\u8f93\u51fa\u4e00\u884c<code>0:0<\/code><\/li>\n<li>\u4e00\u5c40\u7ed3\u675f\u7684\u6761\u4ef6:\u4e00\u65b9\u80dc\u5229\u4e8611\/21\u6b21\u4e14\u53cc\u65b9\u80dc\u5229\u6b21\u6570\u5927\u4e8e\u7b49\u4e8e2,\u6216\u662f\u81ea\u7136\u7ed3\u675f<\/li>\n<\/ul>\n<p>\u6240\u4ee5\u5148\u601d\u8003\u5982\u4f55\u5f55\u5165\u6570\u636e:<\/p>\n<ul>\n<li>\u4f7f\u7528while\u5faa\u73af,\u6bcf\u6b21\u8bfb\u53d6\u4e00\u4e2a\u5b57\u7b26<\/li>\n<li>\u78b0\u5230<code>'E'<\/code>\u5219\u7ed3\u675f<\/li>\n<\/ul>\n<p>\u518d\u601d\u8003\u5982\u4f55\u8f93\u51fa:<\/p>\n<ul>\n<li>\u904d\u5386\u8f93\u5165\u7684\u6570\u636e,\u6bcf\u8bfb\u53d6\u4e00\u4f4d(\u5f53\u524d\u6570\u636e\u53d1\u751f\u53d8\u5316)\u5c31\u8981\u5224\u65ad\u662f\u5426\u8fbe\u5230\u6bd4\u8d5b\u7ed3\u675f\u7684\u6761\u4ef6<\/li>\n<li>\u904d\u5386\u7ed3\u675f\u7684\u65f6\u5019,\u628a\u5269\u4f59\u7684\u5206\u6570\u8f93\u51fa(\u6bd4\u8d5b\u81ea\u7136\u7ed3\u675f)<\/li>\n<li>\u7531\u4e8e\u8fbe\u5230\u6761\u4ef6\u800c\u7ed3\u675f\u7684\u6bd4\u8d5b\u4e00\u5b9a\u5728\u5012\u6570\u7b2c\u4e8c\u53e5,\u5176\u540e\u9762\u4e00\u5b9a\u8fd8\u6709\u4e00\u5c40,\u6240\u4ee5\u65e0\u9700\u4efb\u4f55\u6761\u4ef6\u5224\u65ad,\u76f4\u63a5\u8f93\u51fa\u5373\u53ef<\/li>\n<\/ul>\n<h3>\u6211\u7684\u4ee3\u7801<\/h3>\n<pre><code class=\"lang-cpp language-cpp cpp\">#include\n&lt;cstdio&gt;\n#include\n&lt;cmath&gt;\n#include\n&lt;string&gt;\n\nint main () {\n    \/\/\u8f93\u5165\n    char temp = '\\n' ;\n    std::string contest_in ;\n    do{\n        if(temp!='\\n'){\n            contest_in += temp ;\n        }\n        temp = getchar() ;\n    }while(temp!='E');\n\n    \/\/\u9010\u4f4d\u8bfb\u53d6\n    int win=0 , lose=0 ;\n    for(char temp : contest_in){\n        if(temp=='W'){\n            win++ ;\n        }\n        if(temp=='L'){\n            lose++ ;\n        }\n        if((win&gt;=11 || lose&gt;=11)&amp;&amp;(abs(win-lose)&gt;=2)){\n            printf(&quot;%d:%d\\n&quot;,win,lose);\n            win = lose = 0 ;\n        }\n    }\n\n    printf(&quot;%d:%d\\n&quot;,win,lose);\n\n    printf(&quot;\\n&quot;);\n\n    \/\/\u9010\u4f4d\u8bfb\u53d6\n    win=lose=0 ;\n    for(char temp : contest_in){\n        if(temp=='W'){\n            win++ ;\n        }\n        if(temp=='L'){\n            lose++ ;\n        }\n        if((win&gt;=21 || lose&gt;=21)&amp;&amp;(abs(win-lose)&gt;=2)){\n            printf(&quot;%d:%d\\n&quot;,win,lose);\n            win = lose = 0 ;\n        }\n    }\n\n    printf(&quot;%d:%d\\n&quot;,win,lose);\n\n    printf(&quot;\\n&quot;);\n}<\/code><\/pre>\n<h1>P2670 [NOIP 2015 \u666e\u53ca\u7ec4] \u626b\u96f7\u6e38\u620f<\/h1>\n<h2>\u9898\u76ee\u80cc\u666f<\/h2>\n<p>NOIP2015 \u666e\u53ca\u7ec4 T2<\/p>\n<h2>\u9898\u76ee\u63cf\u8ff0<\/h2>\n<p>\u626b\u96f7\u6e38\u620f\u662f\u4e00\u6b3e\u5341\u5206\u7ecf\u5178\u7684\u5355\u673a\u5c0f\u6e38\u620f\u3002\u5728 n \u884c m \u5217\u7684\u96f7\u533a\u4e2d\u6709\u4e00\u4e9b\u683c\u5b50\u542b\u6709\u5730\u96f7\uff08\u79f0\u4e4b\u4e3a\u5730\u96f7\u683c\uff09\uff0c\u5176\u4ed6\u683c\u5b50\u4e0d\u542b\u5730\u96f7\uff08\u79f0\u4e4b\u4e3a\u975e\u5730\u96f7\u683c\uff09\u3002\u73a9\u5bb6\u7ffb\u5f00\u4e00\u4e2a\u975e\u5730\u96f7\u683c\u65f6\uff0c\u8be5\u683c\u5c06\u4f1a\u51fa\u73b0\u4e00\u4e2a\u6570\u5b57\u2014\u2014\u63d0\u793a\u5468\u56f4\u683c\u5b50\u4e2d\u6709\u591a\u5c11\u4e2a\u662f\u5730\u96f7\u683c\u3002\u6e38\u620f\u7684\u76ee\u6807\u662f\u5728\u4e0d\u7ffb\u51fa\u4efb\u4f55\u5730\u96f7\u683c\u7684\u6761\u4ef6\u4e0b\uff0c\u627e\u51fa\u6240\u6709\u7684\u975e\u5730\u96f7\u683c\u3002<\/p>\n<p>\u73b0\u5728\u7ed9\u51fa n \u884c m \u5217\u7684\u96f7\u533a\u4e2d\u7684\u5730\u96f7\u5206\u5e03\uff0c\u8981\u6c42\u8ba1\u7b97\u51fa\u6bcf\u4e2a\u975e\u5730\u96f7\u683c\u5468\u56f4\u7684\u5730\u96f7\u683c\u6570\u3002<\/p>\n<p>\u6ce8\uff1a\u4e00\u4e2a\u683c\u5b50\u7684\u5468\u56f4\u683c\u5b50\u5305\u62ec\u5176\u4e0a\u3001\u4e0b\u3001\u5de6\u3001\u53f3\u3001\u5de6\u4e0a\u3001\u53f3\u4e0a\u3001\u5de6\u4e0b\u3001\u53f3\u4e0b\u516b\u4e2a\u65b9\u5411\u4e0a\u4e0e\u4e4b\u76f4\u63a5\u76f8\u90bb\u7684\u683c\u5b50\u3002<\/p>\n<h2>\u8f93\u5165\u683c\u5f0f<\/h2>\n<p>\u7b2c\u4e00\u884c\u662f\u7528\u4e00\u4e2a\u7a7a\u683c\u9694\u5f00\u7684\u4e24\u4e2a\u6574\u6570 n \u548c m\uff0c\u5206\u522b\u8868\u793a\u96f7\u533a\u7684\u884c\u6570\u548c\u5217\u6570\u3002<\/p>\n<p>\u63a5\u4e0b\u6765 n \u884c\uff0c\u6bcf\u884c m \u4e2a\u5b57\u7b26\uff0c\u63cf\u8ff0\u4e86\u96f7\u533a\u4e2d\u7684\u5730\u96f7\u5206\u5e03\u60c5\u51b5\u3002\u5b57\u7b26 * \u8868\u793a\u76f8\u5e94\u683c\u5b50\u662f\u5730\u96f7\u683c\uff0c\u5b57\u7b26? \u8868\u793a\u76f8\u5e94\u683c\u5b50\u662f\u975e\u5730\u96f7\u683c\u3002\u76f8\u90bb\u5b57\u7b26\u4e4b\u95f4\u65e0\u5206\u9694\u7b26\u3002<\/p>\n<h2>\u8f93\u51fa\u683c\u5f0f<\/h2>\n<p>\u8f93\u51fa\u6587\u4ef6\u5305\u542b n \u884c\uff0c\u6bcf\u884c m \u4e2a\u5b57\u7b26\uff0c\u63cf\u8ff0\u6574\u4e2a\u96f7\u533a\u3002\u7528 * \u8868\u793a\u5730\u96f7\u683c\uff0c\u7528\u5468\u56f4\u7684\u5730\u96f7\u4e2a\u6570\u8868\u793a\u975e\u5730\u96f7\u683c\u3002\u76f8\u90bb\u5b57\u7b26\u4e4b\u95f4\u65e0\u5206\u9694\u7b26\u3002<\/p>\n<h2>\u8f93\u5165\u8f93\u51fa\u6837\u4f8b #1<\/h2>\n<h3>\u8f93\u5165 #1<\/h3>\n<pre><code>3 3\n*??\n???\n?*?<\/code><\/pre>\n<h3>\u8f93\u51fa #1<\/h3>\n<pre><code>*10\n221\n1*1<\/code><\/pre>\n<h2>\u8f93\u5165\u8f93\u51fa\u6837\u4f8b #2<\/h2>\n<h3>\u8f93\u5165 #2<\/h3>\n<pre><code>2 3\n?*?\n*??<\/code><\/pre>\n<h3>\u8f93\u51fa #2<\/h3>\n<pre><code>2*1\n*21<\/code><\/pre>\n<h2>\u8bf4\u660e\/\u63d0\u793a<\/h2>\n<p>\u5bf9\u4e8e 100%\u7684\u6570\u636e\uff0c1\u2264n\u2264100, 1\u2264m\u2264100\u3002<\/p>\n<h2>\u89e3\u6790<\/h2>\n<p>\u5904\u7406\u8f93\u5165:<\/p>\n<ul>\n<li>\u9996\u5148\u58f0\u660e\u4e24\u4e2a\u53d8\u91cf,\u5206\u522b\u6765\u5b58\u50a8\u884c\u6570\u548c\u5217\u6570<\/li>\n<li>\u7136\u540e\u65b0\u5efa\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4,\u4e00\u7ea7\u7d22\u5f15\u8868\u793a\u7eb5\u5750\u6807(\u7b2c\u51e0\u884c),\u4e8c\u7ea7\u7d22\u5f15\u8868\u793a\u6a2a\u5750\u6807(\u7b2c\u51e0\u5217)<\/li>\n<li>\u4ece\u63a7\u5236\u53f0\u83b7\u53d6\u8f93\u5165,\u904d\u5386\u4e8c\u7ef4\u6570\u7ec4,\u5c06\u5730\u96f7\u5b58\u50a8\u4e3a1,\u65e0\u5730\u96f7\u5b58\u50a8\u4e3a0(\u6570\u5b57\u5316\u7ba1\u7406)<\/li>\n<\/ul>\n<p>\u7a0b\u5e8f\u4e3b\u4f53:<\/p>\n<ul>\n<li>\u5bf9\u4e8e\u6bcf\u4e00\u4e2a\u4f4d\u7f6e,\u6211\u4eec\u8981\u8ba1\u7b97\u5176\u4e00\u5468\u4e0a\u6709\u591a\u5c111,\u91cd\u70b9\u5728\u4e8e\u4e0d\u662f\u6240\u6709\u5143\u7d20\u7684\u5468\u56f4\u90fd\u67098\u4e2a\u5143\u7d20,\u9700\u8981\u5904\u7406\u8fb9\u754c<\/li>\n<li>\u58f0\u660etop,bottom,left,right\u6765\u8868\u793a\u5143\u7d20\u662f\u5426\u5728\u8fb9\u754c\u4e0a,1\u8868\u793a\u8be5\u8fb9\u754c\u662f\u5b89\u5168\u7684,\u53ef\u4ee5\u8bbf\u95ee,0\u8868\u793a\u8be5\u5143\u7d20\u5904\u4e8e\u8fb9\u754c,\u4e0d\u53ef\u4ee5\u7ee7\u7eed\u8bbf\u95ee,\u5426\u5219\u5c06\u5bfc\u81f4\u6570\u7ec4\u8d8a\u754c<\/li>\n<li>\u6839\u636etop,bottom,left,right\u6765\u51b3\u5b9a\u9700\u8981\u8bfb\u53d6\u54ea\u51e0\u4e2a\u4f4d\u7f6e\u4e0a\u7684\u5143\u7d20,\u9047\u52301\u5219count++<\/li>\n<li>\u5c06count\u5b58\u50a8\u5728\u4e00\u4e2a\u65b0\u7684\u4e8c\u4f4d\u6570\u7ec4\u4e2d<\/li>\n<\/ul>\n<p>\u5904\u7406\u8f93\u51fa:<\/p>\n<ul>\n<li>\u904d\u5386\u4e8c\u7ef4\u6570\u7ec4\u7684\u6bcf\u4e00\u4e2a\u5143\u7d20<\/li>\n<li>\u82e5\u8be5\u4f4d\u7f6e\u662f\u5730\u96f7,\u5219\u8f93\u51fa*<\/li>\n<li>\u5426\u5219\u8f93\u51fa\u4e0a\u9762\u8ba1\u7b97\u51fa\u7684count<\/li>\n<\/ul>\n<h2>\u6211\u7684\u4ee3\u7801<\/h2>\n<pre><code class=\"lang-cpp language-cpp cpp\">#include \n&lt;cstdio&gt;\n\nint main () {\n    \/\/\u5904\u7406\u8f93\u5165\n    int n,m ;\n    scanf(&quot;%d %d&quot;,&amp;n,&amp;m);\n    int map_in[n][m];\n    int map_out[n][m];\n    char temp ;\n    getchar();\n    for(int i = 0 ;i&lt;n ; i++ ){\n        for(int j = 0 ;j&lt;m ; j ++){\n            scanf(&quot;%c&quot;,&amp;temp);\n            map_in[i][j] = temp=='*' ? 1:0 ;\n        }\n        getchar();\n    }\n\n    \/\/\u8ba1\u7b97\u8f93\u51fa\n    int left,right,top,bottom,count ;\n    for(int i = 0 ;i&lt;n ; i++ ){\n        if(i&gt;0){\n            top = 1 ;\n        }else{\n            top = 0 ;\n        }\n        if(i&lt;n-1){\n            bottom = 1 ;\n        }else{\n            bottom = 0 ;\n        }\n        for(int j = 0 ;j&lt;m ; j ++){\n            count = 0 ;\n            if(j&gt;0){\n                left = 1 ;\n            }else{\n                left = 0 ;\n            }\n            if(j&lt;m-1){\n                right = 1 ;\n            }else{\n                right = 0 ;\n            }\n            if(top){\n                if(map_in[i-1][j]){\n                    count ++ ;\n                }\n            }\n            if(bottom){\n                if(map_in[i+1][j]){\n                    count ++ ;\n                }\n            }\n            if(left){\n                if(map_in[i][j-1]){\n                    count ++ ;\n                }\n            }\n            if(right){\n                if(map_in[i][j+1]){\n                    count ++ ;\n                }\n            }\n            if(top &amp;&amp; left){\n                if(map_in[i-1][j-1]){\n                    count ++ ;\n                }\n            }\n            if(bottom &amp;&amp; left){\n                if(map_in[i+1][j-1]){\n                    count ++ ;\n                }\n            }\n            if(top &amp;&amp; right){\n                if(map_in[i-1][j+1]){\n                    count ++ ;\n                }\n            }\n            if(bottom &amp;&amp; right){\n                if(map_in[i+1][j+1]){\n                    count ++ ;\n                }\n            }\n            map_out[i][j] = count ;\n        }\n    }\n\n    \/\/\u6253\u5370\u8f93\u51fa\n    for(int i = 0 ;i&lt;n ; i++ ){\n        for(int j = 0 ;j&lt;m ; j ++){\n            if(map_in[i][j]==1){\n                printf(&quot;*&quot;);\n            }else{\n                printf(&quot;%d&quot;,map_out[i][j]);\n            }\n        }\n        printf(&quot;\\n&quot;);\n    }\n}<\/code><\/pre>\n<h1>P1563 [NOIP 2016 \u63d0\u9ad8\u7ec4] \u73a9\u5177\u8c1c\u9898<\/h1>\n<h2>\u9898\u76ee\u80cc\u666f<\/h2>\n<p>NOIP2016 \u63d0\u9ad8\u7ec4 D1T1<\/p>\n<h2>\u9898\u76ee\u63cf\u8ff0<\/h2>\n<p>\u5c0f\u5357\u6709\u4e00\u5957\u53ef\u7231\u7684\u73a9\u5177\u5c0f\u4eba\uff0c\u5b83\u4eec\u5404\u6709\u4e0d\u540c\u7684\u804c\u4e1a\u3002<\/p>\n<p>\u6709\u4e00\u5929\uff0c\u8fd9\u4e9b\u73a9\u5177\u5c0f\u4eba\u628a\u5c0f\u5357\u7684\u773c\u955c\u85cf\u4e86\u8d77\u6765\u3002\u5c0f\u5357\u53d1\u73b0\u73a9\u5177\u5c0f\u4eba\u4eec\u56f4\u6210\u4e86\u4e00\u4e2a\u5708\uff0c\u5b83\u4eec\u6709\u7684\u9762\u671d\u5708\u5185\uff0c\u6709\u7684\u9762\u671d\u5708\u5916\u3002<\/p>\n<p>\u8fd9\u65f6 singer \u544a\u8bc9\u5c0f\u5357\u4e00\u4e2a\u8c1c\u9898\uff1a\u201c\u773c\u955c\u85cf\u5728\u6211\u5de6\u6570\u7b2c 3 \u4e2a\u73a9\u5177\u5c0f\u4eba\u7684\u53f3\u6570\u7b2c 1 \u4e2a\u73a9\u5177\u5c0f\u4eba\u7684\u5de6\u6570\u7b2c 2 \u4e2a\u73a9\u5177\u5c0f\u4eba\u90a3\u91cc\u3002\u201d<\/p>\n<p>\u5c0f\u5357\u53d1\u73b0\uff0c\u8fd9\u4e2a\u8c1c\u9898\u4e2d\u73a9\u5177\u5c0f\u4eba\u7684\u671d\u5411\u975e\u5e38\u5173\u952e\uff0c\u56e0\u4e3a\u671d\u5185\u548c\u671d\u5916\u7684\u73a9\u5177\u5c0f\u4eba\u7684\u5de6\u53f3\u65b9\u5411\u662f\u76f8\u53cd\u7684\uff1a\u9762\u671d\u5708\u5185\u7684\u73a9\u5177\u5c0f\u4eba\uff0c\u5b83\u7684\u5de6\u8fb9\u662f\u987a\u65f6\u9488\u65b9\u5411\uff0c\u53f3\u8fb9\u662f\u9006\u65f6\u9488\u65b9\u5411\uff1b\u800c\u9762\u5411\u5708\u5916\u7684\u73a9\u5177\u5c0f\u4eba\uff0c\u5b83\u7684\u5de6\u8fb9\u662f\u9006\u65f6\u9488\u65b9\u5411\uff0c\u53f3\u8fb9\u662f\u987a\u65f6\u9488\u65b9\u5411\u3002<\/p>\n<p>\u5c0f\u5357\u4e00\u8fb9\u8270\u96be\u5730\u8fa8\u8ba4\u7740\u73a9\u5177\u5c0f\u4eba\uff0c\u4e00\u8fb9\u6570\u7740:<\/p>\n<p>singer \u671d\u5185\uff0c\u5de6\u6570\u7b2c 3 \u4e2a\u662f archer\u3002<\/p>\n<p>archer \u671d\u5916\uff0c\u53f3\u6570\u7b2c 1 \u4e2a\u662f thinker\u3002<\/p>\n<p>thinker \u671d\u5916\uff0c\u5de6\u6570\u7b2c 2 \u4e2a\u662f writer\u3002<\/p>\n<p>\u6240\u4ee5\u773c\u955c\u85cf\u5728 writer \u8fd9\u91cc\uff01<\/p>\n<p>\u867d\u7136\u6210\u529f\u627e\u56de\u4e86\u773c\u955c\uff0c\u4f46\u5c0f\u5357\u5e76\u6ca1\u6709\u653e\u5fc3\u3002\u5982\u679c\u4e0b\u6b21\u6709\u66f4\u591a\u7684\u73a9\u5177\u5c0f\u4eba\u85cf\u4ed6\u7684\u773c\u955c\uff0c\u6216\u662f\u8c1c\u9898\u7684\u957f\u5ea6\u66f4\u957f\uff0c\u4ed6\u53ef\u80fd\u5c31\u65e0\u6cd5\u627e\u5230\u773c\u955c\u4e86\u3002\u6240\u4ee5\u5c0f\u5357\u5e0c\u671b\u4f60\u5199\u7a0b\u5e8f\u5e2e\u4ed6\u89e3\u51b3\u7c7b\u4f3c\u7684\u8c1c\u9898\u3002\u8fd9\u6837\u7684\u8c1c\u9898\u5177\u4f53\u53ef\u4ee5\u63cf\u8ff0\u4e3a\uff1a<\/p>\n<p>\u6709 n\u4e2a\u73a9\u5177\u5c0f\u4eba\u56f4\u6210\u4e00\u5708\uff0c\u5df2\u77e5\u5b83\u4eec\u7684\u804c\u4e1a\u548c\u671d\u5411\u3002\u73b0\u5728\u7b2c 1\u4e2a\u73a9\u5177\u5c0f\u4eba\u544a\u8bc9\u5c0f\u5357\u4e00\u4e2a\u5305\u542b m\u6761\u6307\u4ee4\u7684\u8c1c\u9898\uff0c\u5176\u4e2d\u7b2c z$ \u6761\u6307\u4ee4\u5f62\u5982\u201c\u5411\u5de6\u6570\/\u53f3\u6570\u7b2c s \u4e2a\u73a9\u5177\u5c0f\u4eba\u201d\u3002\u4f60\u9700\u8981\u8f93\u51fa\u4f9d\u6b21\u6570\u5b8c\u8fd9\u4e9b\u6307\u4ee4\u540e\uff0c\u5230\u8fbe\u7684\u73a9\u5177\u5c0f\u4eba\u7684\u804c\u4e1a\u3002<\/p>\n<h2>\u8f93\u5165\u683c\u5f0f<\/h2>\n<p>\u8f93\u5165\u7684\u7b2c\u4e00\u884c\u5305\u542b\u4e24\u4e2a\u6b63\u6574\u6570 n,m\uff0c\u8868\u793a\u73a9\u5177\u5c0f\u4eba\u7684\u4e2a\u6570\u548c\u6307\u4ee4\u7684\u6761\u6570\u3002<\/p>\n<p>\u63a5\u4e0b\u6765 n \u884c\uff0c\u6bcf\u884c\u5305\u542b\u4e00\u4e2a\u6574\u6570\u548c\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u4ee5\u9006\u65f6\u9488\u4e3a\u987a\u5e8f\u7ed9\u51fa\u6bcf\u4e2a\u73a9\u5177\u5c0f\u4eba\u7684\u671d\u5411\u548c\u804c\u4e1a\u3002\u5176\u4e2d 0 \u8868\u793a\u671d\u5411\u5708\u5185\uff0c1 \u8868\u793a\u671d\u5411\u5708\u5916\u3002\u4fdd\u8bc1\u4e0d\u4f1a\u51fa\u73b0\u5176\u4ed6\u7684\u6570\u3002\u5b57\u7b26\u4e32\u957f\u5ea6\u4e0d\u8d85\u8fc7 10\u4e14\u4ec5\u7531\u82f1\u6587\u5b57\u6bcd\u6784\u6210\uff0c\u5b57\u7b26\u4e32\u4e0d\u4e3a\u7a7a\uff0c\u5e76\u4e14\u5b57\u7b26\u4e32\u4e24\u4e24\u4e0d\u540c\u3002\u6574\u6570\u548c\u5b57\u7b26\u4e32\u4e4b\u95f4\u7528\u4e00\u4e2a\u7a7a\u683c\u9694\u5f00\u3002<\/p>\n<p>\u63a5\u4e0b\u6765 m \u884c\uff0c\u5176\u4e2d\u7b2c i \u884c\u5305\u542b\u4e24\u4e2a\u6574\u6570 a_i,s_i\uff0c\u8868\u793a\u7b2c i \u6761\u6307\u4ee4\u3002\u82e5 a_i=0\uff0c\u8868\u793a\u5411\u5de6\u6570 s_i \u4e2a\u4eba\uff1b\u82e5 a_i=1\uff0c\u8868\u793a\u5411\u53f3\u6570 s_i \u4e2a\u4eba\u3002 \u4fdd\u8bc1 a_i \u4e0d\u4f1a\u51fa\u73b0\u5176\u4ed6\u7684\u6570\uff0cs_i &lt; n\u3002<\/p>\n<h2>\u8f93\u51fa\u683c\u5f0f<\/h2>\n<p>\u8f93\u51fa\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u8868\u793a\u4ece\u7b2c\u4e00\u4e2a\u8bfb\u5165\u7684\u5c0f\u4eba\u5f00\u59cb\uff0c\u4f9d\u6b21\u6570\u5b8c m \u6761\u6307\u4ee4\u540e\u5230\u8fbe\u7684\u5c0f\u4eba\u7684\u804c\u4e1a\u3002<\/p>\n<h2>\u8f93\u5165\u8f93\u51fa\u6837\u4f8b #1<\/h2>\n<h3>\u8f93\u5165 #1<\/h3>\n<pre><code>7 3\n0 singer\n0 reader\n0 mengbier \n1 thinker\n1 archer\n0 writer\n1 mogician \n0 3\n1 1\n0 2<\/code><\/pre>\n<h3>\u8f93\u51fa #1<\/h3>\n<pre><code>writer<\/code><\/pre>\n<h2>\u8f93\u5165\u8f93\u51fa\u6837\u4f8b #2<\/h2>\n<h3>\u8f93\u5165 #2<\/h3>\n<pre><code>10 10\n1 C\n0 r\n0 P\n1 d\n1 e\n1 m\n1 t\n1 y\n1 u\n0 V\n1 7\n1 1\n1 4\n0 5\n0 3\n0 1\n1 6\n1 2\n0 8\n0 4<\/code><\/pre>\n<h3>\u8f93\u51fa #2<\/h3>\n<pre><code>y<\/code><\/pre>\n<h2>\u89e3\u6790<\/h2>\n<ul>\n<li>\u503c\u5f97\u6ce8\u610f\u7684\u662f,\u5de6\u6570\/\u53f3\u6570\u548c\u671d\u5185\/\u671d\u5916\u5171\u540c\u51b3\u5b9a\u4e86\u5411\u91cf\u7684\u65b9\u5411<\/li>\n<li>\u53ef\u4ee5\u628a\u5411\u91cf\u89c4\u5b9a\u4e3a\u987a\u52bf\u9488\u548c\u9006\u65f6\u9488,\u90a3\u4e48,\u53ea\u8981\u628a\u6570\u6570\u7684\u65b9\u5411\u548c\u671d\u5411\u76f8\u4e58\u5373\u53ef<\/li>\n<li>\u9898\u5e72\u4e2d0\u8868\u793a\u671d\u5411\u5708\u5185,1\u8868\u793a\u671d\u5411\u5708\u5916,\u90a3\u4e48\u6211\u4eec\u89c4\u5b9a\u671d\u5411\u5708\u5185\u662f-1,\u671d\u5411\u5708\u5916\u662f1,\u5de6\u6570\u8bb0\u4e3a-1,\u53f3\u6570\u8bb0\u4e3a1<\/li>\n<li>\u90a3\u4e481\u5c31\u662f\u987a\u65f6\u9488,-1\u5c31\u662f\u9006\u65f6\u9488<\/li>\n<li>\u4f46\u662f\u9898\u76ee\u7ed9\u7684\u987a\u5e8f\u662f\u9006\u65f6\u9488,\u6240\u4ee5\u53cd\u8f6c\u4e00\u4e0b,\u9006\u65f6\u9488\u4e3a\u6b63<\/li>\n<\/ul>\n<h2>\u6211\u7684\u4ee3\u7801<\/h2>\n<pre><code class=\"lang-cpp language-cpp cpp\">#include\n&lt;cstdio&gt;\n#include\n&lt;string&gt;\n#include\n&lt;iostream&gt;\n\nint main () {\n    \/\/\u5904\u7406\u8f93\u5165:n\u662f\u4eba\u6570,m\u662f\u6307\u4ee4\u7684\u6761\u6570\n    int n,m ;\n    std::cin&gt;&gt;n&gt;&gt;m;\n    \/\/\u5904\u7406\u5c0f\u4eba\u8f93\u5165,\u6570\u7ec4towards\u4ee3\u8868\u671d\u5411,names\u4ee3\u8868\u540d\u79f0\n    int towards[n];\n    std::string names[n];\n    for(int i = 0 ; i&lt;n ; i++ ){\n        std::cin&gt;&gt;towards[i]&gt;&gt;names[i];\n        \/\/\u6807\u51c6\u5316towards\n        towards[i] = towards[i]==0?-1:1;\n    }\n    \/\/\u5904\u7406\u6307\u4ee4\u8f93\u5165,command\u4ee3\u8868\u5904\u7406\u540e\u7684\u6307\u4ee4,towards_cmd\u4ee3\u8868\u6307\u4ee4\u671d\u5411\n    int command[m] ;\n    int towards_cmd[m];\n    int now_p = 0 ;\n    for(int i = 0 ; i&lt;m ; i++){\n        std::cin&gt;&gt;towards_cmd[i]&gt;&gt;command[i];\n        \/\/\u6807\u51c6\u5316towards_cmd\n        towards_cmd[i] = towards_cmd[i]==0?-1:1;\n        command[i] = towards_cmd[i]*towards[now_p]==1?(-command[i]):command[i] ;\n        \/\/\u6309\u7167command[i]\u6267\u884c,\u5f97\u5230\u65b0\u7684now_p(\u4fdd\u8bc1\u4e3a\u6b63)\n        now_p+=(command[i]+n) ;\n        \/\/now_p\u53ef\u80fd\u662f\u8d8a\u754c\u7684,\u8c03\u6574now_p\n        now_p = now_p%n;\n    }\n\n    \/\/\u73b0\u5728\u7684now_p\u5728\u6b63\u786e\u7684\u4f4d\u7f6e\u4e0a\u4e86,\u8f93\u51fa\n    std::cout&lt;&lt;names[now_p];\n}<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>P1042 [NOIP 2003 \u666e\u53ca\u7ec4] \u4e52\u4e53\u7403 \u9898\u76ee\u80cc\u666f \u56fd\u9645\u4e52\u8054\u73b0\u5728\u4e3b\u5e2d\u6c99\u62c9\u62c9\u81ea\u4ece\u4e0a\u4efb\u4ee5\u6765\u5c31\u7acb\u5fd7\u4e8e\u63a8\u884c\u4e00 [&hellip;]<\/p>","protected":false},"author":1,"featured_media":170,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,3],"tags":[],"class_list":["post-169","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-algorithm","category-coding"],"_links":{"self":[{"href":"https:\/\/www.tangent0712.top\/index.php\/wp-json\/wp\/v2\/posts\/169","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tangent0712.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tangent0712.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tangent0712.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tangent0712.top\/index.php\/wp-json\/wp\/v2\/comments?post=169"}],"version-history":[{"count":4,"href":"https:\/\/www.tangent0712.top\/index.php\/wp-json\/wp\/v2\/posts\/169\/revisions"}],"predecessor-version":[{"id":192,"href":"https:\/\/www.tangent0712.top\/index.php\/wp-json\/wp\/v2\/posts\/169\/revisions\/192"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tangent0712.top\/index.php\/wp-json\/wp\/v2\/media\/170"}],"wp:attachment":[{"href":"https:\/\/www.tangent0712.top\/index.php\/wp-json\/wp\/v2\/media?parent=169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tangent0712.top\/index.php\/wp-json\/wp\/v2\/categories?post=169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tangent0712.top\/index.php\/wp-json\/wp\/v2\/tags?post=169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}