{"id":14,"date":"2025-11-09T20:30:52","date_gmt":"2025-11-09T12:30:52","guid":{"rendered":"https:\/\/tblog.zeabur.app\/?p=14"},"modified":"2025-11-09T20:33:25","modified_gmt":"2025-11-09T12:33:25","slug":"%e9%a2%98%e8%a7%a3-cf2145b","status":"publish","type":"post","link":"https:\/\/tblog.zeabur.app\/?p=14","title":{"rendered":"\u9898\u89e3 CF2145B"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u9898\u76ee\u5927\u610f<\/h2>\n\n\n\n<p>\u7ed9\u5b9a\u4ece $1$ \u5230 $n$ \u7f16\u53f7\u7684\u724c\uff0c\u521d\u59cb\u6309 $1$ \u5728\u9876\u90e8\u3001$n$ \u5728\u5e95\u90e8\u7684\u987a\u5e8f\u6392\u5217\u3002\u8fdb\u884c\u4e86 $k$ \u6b21\u64cd\u4f5c\uff0c\u64cd\u4f5c\u7c7b\u578b\u5305\u62ec\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u79fb\u9664\u9876\u90e8\u7684\u724c\uff1b<\/li>\n\n\n\n<li>\u79fb\u9664\u5e95\u90e8\u7684\u724c\uff1b<\/li>\n\n\n\n<li>\u79fb\u9664\u9876\u90e8\u6216\u5e95\u90e8\u7684\u4efb\u610f\u4e00\u5f20\u724c\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u9700\u5224\u65ad\u6bcf\u5f20\u724c\u7684\u72b6\u6001\uff1a\u88ab\u79fb\u9664\uff08\u8f93\u51fa <code>-<\/code>\uff09\u3001\u4fdd\u7559\uff08\u8f93\u51fa <code>+<\/code>\uff09\u6216\u72b6\u6001\u4e0d\u786e\u5b9a\uff08\u8f93\u51fa <code>?<\/code>\uff09\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u601d\u8def<\/h2>\n\n\n\n<p>\u901a\u8fc7\u4e09\u4e2a\u53d8\u91cf\u7edf\u8ba1\u65b0\u7684\u9876\u90e8\u4f4d\u7f6e $ctop$\uff0c\u65b0\u7684\u5e95\u90e8\u4f4d\u7f6e $cback$ \u4ee5\u53ca\u672a\u77e5\u79fb\u9664\u7684\u4e2a\u6570 $uk$\u3002<\/p>\n\n\n\n<p>\u4e4b\u540e\u904d\u5386 $1\\sim n$\uff0c\u5206\u5982\u4e0b\u51e0\u79cd\u60c5\u51b5\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u60c5\u51b5\u4e00\uff1a\u5982\u679c\u64cd\u4f5c\u6b21\u6570 $k$ \u5927\u4e8e\u7b49\u4e8e\u603b\u6570 $n$\u200b\uff0c\u5219\u8bf4\u660e\u5df2\u7ecf\u6ca1\u6709\u724c\u5b58\u5728\u4e86\uff0c\u76f4\u63a5\u8f93\u51fa <code>-<\/code>\u3002\\<\/li>\n\n\n\n<li>\u60c5\u51b5\u4e8c\uff1a\u5982\u679c\u5f53\u524d\u4f4d\u7f6e\u4e0d\u5728\u9876\u4f4d\u7f6e\u52a0\u4e0a\u672a\u77e5\u79fb\u9664\u6570\u4ee5\u53ca\u5e95\u4f4d\u7f6e\u51cf\u53bb\u672a\u77e5\u79fb\u9664\u6570\u7684\u8303\u56f4\u4e2d\uff0c\u5219\u8bf4\u660e\u5373\u4f7f\u672a\u77e5\u79fb\u9664\u5168\u4e3a\u540c\u4e00\u4e2a\u64cd\u4f5c\u4e5f\u65e0\u6cd5\u79fb\u9664\u5f53\u524d\u4f4d\u7f6e\uff0c\u8f93\u51fa <code>+<\/code>\u3002<\/li>\n\n\n\n<li>\u60c5\u51b5\u4e09\uff1a\u5982\u679c\u5f53\u524d\u4f4d\u7f6e\u4e0d\u5728\u9876\u4f4d\u7f6e\u4ee5\u53ca\u5e95\u4f4d\u7f6e\u4e4b\u95f4\uff0c\u5219\u4e00\u5b9a\u88ab\u79fb\u9664\u4e86\uff0c\u8f93\u51fa <code>-<\/code>\u3002<\/li>\n\n\n\n<li>\u60c5\u51b5\u56db\uff1a\u5269\u4f59\u60c5\u51b5\u5373\u4e3a\u4e0d\u786e\u5b9a\uff0c\u8f93\u51fa <code>?<\/code>\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ee3\u7801\u5b9e\u73b0<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;bits\/stdc++.h&gt;\n#define int long long\nusing namespace std;\ninline void solve()\n{\n    int n,k,ctop=0,cback=0,uk=0;string s;\n    cin&gt;&gt;n&gt;&gt;k&gt;&gt;s;\n    cback=n;\/\/\u521d\u59cb\u5316\u5e95\u4f4d\u7f6e\n    for(char c:s)\n    {\n        if(c=='0')\/\/\u66f4\u65b0\u9876\u4f4d\u7f6e\n        {\n            ctop++;\n        }\n        else if(c=='1')\/\/\u66f4\u65b0\u5e95\u4f4d\u7f6e\n        {\n            cback--;\n        }\n        else\/\/\u66f4\u65b0\u672a\u77e5\u4f4d\u7f6e\n        {\n            uk++;\n        }\n    }\n    for(int i=1;i&lt;=n;i++)\n    {\n        if(k&gt;=n)cout&lt;&lt;\"-\";\/\/\u60c5\u51b51\n        else if(i&gt;ctop+uk&amp;&amp;i&lt;cback-uk+1)cout&lt;&lt;\"+\";\/\/\u60c5\u51b52\n        else if(i&lt;=ctop||i&gt;=cback+1)cout&lt;&lt;\"-\";\/\/\u60c5\u51b53\n        else cout&lt;&lt;\"?\";\/\/\u60c5\u51b54\n    }\n    puts(\"\");\n}\nsigned main()\n{\n    int t;\n    cin&gt;&gt;t;\/\/\u522b\u5fd8\u4e86 t \u7ec4\u6837\u4f8b\n    while(t--)\n    {\n        solve();\n    }\n    return 0;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u590d\u6742\u5ea6<\/h2>\n\n\n\n<p>\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a $\\mathcal{O}(t(k+n))$\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u5927\u610f \u7ed9\u5b9a\u4ece $1$ \u5230 $n$ \u7f16\u53f7\u7684\u724c\uff0c\u521d\u59cb\u6309 $1$ \u5728\u9876\u90e8\u3001$n$ \u5728\u5e95\u90e8\u7684\u987a\u5e8f\u6392\u5217\u3002\u8fdb\u884c\u4e86 $k [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[3],"class_list":["post-14","post","type-post","status-publish","format-standard","hentry","category-oi","tag-oi"],"featured_image_src":null,"author_info":{"display_name":"CaelumRadish_c","author_link":"https:\/\/tblog.zeabur.app\/?author=1"},"_links":{"self":[{"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=\/wp\/v2\/posts\/14","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14"}],"version-history":[{"count":4,"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions"}],"predecessor-version":[{"id":18,"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions\/18"}],"wp:attachment":[{"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tblog.zeabur.app\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}