{"id":31,"date":"2023-01-29T17:38:00","date_gmt":"2023-01-29T09:38:00","guid":{"rendered":"https:\/\/solost.cn\/?p=31"},"modified":"2023-02-02T00:51:25","modified_gmt":"2023-02-01T16:51:25","slug":"65","status":"publish","type":"post","link":"https:\/\/solost.cn\/?p=31","title":{"rendered":"UNIQUE VISION Programming Contest 2023 New Year (AtCoder Beginner Contest 287)-D &#8211; Match or Not"},"content":{"rendered":"<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2026\/11\/211866676.png\" alt=\"\u8bf7\u8f93\u5165\u56fe\u7247\u63cf\u8ff0\" title=\"\u8bf7\u8f93\u5165\u56fe\u7247\u63cf\u8ff0\"><\/p>\n<h2>solution<\/h2>\n<p>\u8fd9\u9053\u9898\u5361\u4e86\u597d\u4e45\uff0c\u9898\u76ee\u610f\u601d\u770b\u4e86\u597d\u4e45\u6ca1\u770b\u61c2\u3002\u9898\u76ee\u5927\u610f\u662f\u6709\u4e24\u4e2a\u5b57\u7b26\u4e32s,t\uff0cs\u7684\u957f\u5ea6\u5927\u4e8et,\u6bcf\u6b21\u5220\u53bbs\u6bd4t\u957f\u7684\u90a3\u90e8\u5206\uff0c\u4ece\u5f00\u59cb\u5220\u9664\uff0c\u5220\u5230\u7ed3\u675f\uff0c\u6bcf\u6b21\u5220\u9664\u591a\u7684\uff0c\u5982\u679c\u6bcf\u4e2a\u5b57\u7b26\u90fd\u76f8\u540c\u8f93\u51fayes\uff0c\u5426\u5219no\u3002<\/p>\n<ol>\n<li>\u8fd9\u9053\u9898\u7684\u89e3\u6cd5\u521a\u5f00\u59cb\u662f\u60f3\u529e\u6cd5\u628a\u5b57\u7b26\u4e32\u622a\u65ad\u518d\u62fc\u63a5\uff0c\u53d1\u73b0\u6bcf\u6b21\u90fd\u9700\u8981\u590d\u5236\u5b57\u7b26\u4e32\uff0c\u4ee5\u4e3a\u65f6\u95f4\u590d\u6742\u5ea6\u5728\u8fd9\u4e2a\u5730\u65b9\u6bd4\u8f83\u9ad8\u3002<\/li>\n<li>\u540e\u6765\u4f18\u5316\u6210<code>s.erase(i, l)<\/code>\u8fd9\u4e2a\u4e1c\u897f\u662f\u628a\u4ecei\u5f00\u59cb\u957f\u5ea6\u662fl\u7684\u5b57\u7b26\u5220\u53bb\uff0c\u7136\u540e\u6765\u6b63\u5e38\u5339\u914d\uff0c\u6211\u60f3\u8fd9\u4e2a\u590d\u6742\u5ea6\u4e3b\u8981\u53d6\u51b3\u4e8eerase\u7684\u5b9e\u73b0\u539f\u7406\uff0c\u540e\u6765\u770b\u4e86\u65f6\u95f4\uff0c\u548c\u81ea\u5df1\u624b\u5199\u7684\u5dee\u4e0d\u591ahehe\u3002<\/li>\n<li>\u518d\u540e\u6765\u53d1\u73b0\u4e3b\u8981\u662f\u5e38\u6570\u95ee\u9898\uff0c\u6bcf\u6b21\u4fee\u6539\u540e\u90fd\u9700\u8981\u5224\u65ad\u4e00\u6b21\u662f\u4e0d\u662f\u5339\u914d\uff0c\u5982\u679c\u5b57\u7b26\u4e32\u7279\u522b\u957f\u90a3\u4e48\u5c31\u628a\u540c\u4e00\u4e2a\u5730\u65b9\u6bd4\u8f83\u597d\u591a\u6b21\uff0c\u6240\u4ee5\u540e\u6765\u4f18\u5316\u4e86\u4e00\u70b9\u5e38\u6570\uff0c\u628a\u4e0d\u5339\u914d\u7684\u5730\u65b9\u62ff\u51fa\u6765\u4e13\u95e8\u6765\u6d4b\u8bd5\uff0c\u53d1\u73b0\u867d\u7136\u5feb\u4e86\u70b9\uff0c\u4f46\u662f\u8fd8\u662f\u8d85\u65f6\u3002<\/li>\n<li>\n<p>\u6700\u540e\u5c31\u6ca1\u529e\u6cd5\u4e86\uff0c\u6bd4\u8d5b\u7684\u65f6\u5019\u6ca1\u5199\u51fa\u6765\u771f\u70e6\uff0c\u4ed6\u4eec\u90fd\u5199\u51fa\u6765\u4e86\uff01\uff01\uff01\u8fd9\u9053\u9898\u7684\u89e3\u6cd5\u6211\u4eec\u53ef\u4ee5\u5206\u6790\u4e00\u4e0b\uff0c\u6bcf\u6b21\u5220\u9664\u957f\u5ea6\u4e3al\u7684\u5b57\u7b26\u4e32\u4ece\u5934\u5230\u5c3e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u53d1\u73b0\uff0c\u6709\u4e00\u90e8\u5206\u662f\u5339\u914d\u7684\uff0c\u6709\u4e00\u90e8\u5206\u662f\u4e0d\u5339\u914d\u7684\uff0c\u4e24\u8fb9\u5339\u914d\uff0c\u4e2d\u95f4\u4e0d\u5339\u914d\u65f6\u53ef\u4ee5\u5220\u53bb\u7684\u3002\u6211\u4eec\u5b9a\u4e49\u6700\u957f\u516c\u5171\u524d\u7f00\u662fl,\u6700\u957f\u516c\u5171\u540e\u7f00\u662fr,\u90a3\u4e48x\u662f\u5220\u9664\u7684\u5730\u65b9\uff0c<code>x &gt;= 0 &amp;&amp; x &lt; t.size()<\/code>\uff0c\u6211\u4eec\u9700\u8981\u628a\u90a3\u4e9b\u4e2d\u95f4\u4e0d\u5339\u914d\u7684\u5730\u65b9\u5220\u9664\u4e86\uff0c\u5220\u9664\u6389\u4e00\u70b9\u524d\u540e\u7f00\u90fd\u662f\u53ef\u4ee5\u7684\uff0c\u5219\u8fd9\u6837\u5c31\u662f\u5339\u914d\u7684\u3002\u5339\u914d\u7684\u60c5\u51b5\u662f<code>x &lt;= l &amp;&amp; x &gt;= l - r<\/code><\/p>\n<pre><code class=\"C++\">#include&lt;map&gt;\n#include&lt;set&gt;\n#include&lt;stack&gt;\n#include&lt;queue&gt;\n#include&lt;cmath&gt;\n#include&lt;vector&gt;\n#include&lt;bitset&gt;\n#include&lt;cstdio&gt;\n#include&lt;cstring&gt;\n#include&lt;fstream&gt;\n#include&lt;cstdlib&gt;\n#include&lt;iostream&gt;\n#include&lt;algorithm&gt;\n#include&lt;unordered_map&gt;\n\nusing namespace std;\n#define endl &#039;\\n&#039;\n#define IOS                       \\\n    ios_base::sync_with_stdio(0); \\\n    cin.tie(0);                   \\\n    cout.tie(0);\ntypedef long long ll;\ntypedef pair&lt;int,int&gt; PII;\ntypedef unsigned long long ull;\nconst int INF = 0x3f3f3f3f, mod = 1000000007;\nconst int N = 2e5 + 10;\nint l, r;\nbool check(char a, char b){\n    return a == &#039;?&#039; || b == &#039;?&#039; || a == b;\n}\nint main(){\n    string s, t;\n    cin &gt;&gt; s &gt;&gt; t;\n    int n1 = s.size(), n2 = t.size();\n    while(l &lt; n2 &amp;&amp; check(s[l], t[l])) l++;\n    while(r &lt; n2 &amp;&amp; check(s[n1 - r - 1], t[n2 - r - 1])) r++;\n    for(int i = 0; i &lt;= n2; i++){\n        if(i &lt;= l &amp;&amp; i &gt;= n2 - r)\n            puts(&quot;Yes&quot;);\n        else\n            puts(&quot;No&quot;);\n    }\n    return 0;\n}<\/code><\/pre>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>solution \u8fd9\u9053\u9898\u5361\u4e86\u597d\u4e45\uff0c\u9898\u76ee\u610f\u601d\u770b\u4e86\u597d\u4e45\u6ca1\u770b\u61c2\u3002\u9898\u76ee\u5927\u610f\u662f\u6709\u4e24\u4e2a\u5b57\u7b26\u4e32s,t\uff0cs\u7684\u957f\u5ea6\u5927\u4e8et,\u6bcf\u6b21\u5220\u53bbs\u6bd4t\u957f\u7684\u90a3\u90e8\u5206\uff0c\u4ece\u5f00\u59cb\u5220\u9664\uff0c\u5220\u5230\u7ed3\u675f\uff0c\u6bcf\u6b21\u5220\u9664\u591a\u7684\uff0c\u5982\u679c\u6bcf\u4e2a\u5b57\u7b26\u90fd\u76f8\u540c\u8f93\u51fayes\uff0c\u5426\u5219no\u3002 \u8fd9\u9053\u9898\u7684\u89e3\u6cd5\u521a\u5f00\u59cb\u662f\u60f3\u529e\u6cd5\u628a\u5b57\u7b26\u4e32\u622a\u65ad\u518d\u62fc\u63a5\uff0c\u53d1\u73b0\u6bcf\u6b21\u90fd\u9700\u8981\u590d\u5236\u5b57\u7b26\u4e32\uff0c\u4ee5\u4e3a\u65f6\u95f4\u590d\u6742\u5ea6\u5728\u8fd9\u4e2a\u5730\u65b9\u6bd4\u8f83\u9ad8\u3002 \u540e\u6765\u4f18\u5316\u6210s.erase(i, l)\u8fd9\u4e2a\u4e1c\u897f\u662f\u628a\u4ecei\u5f00\u59cb\u957f\u5ea6\u662fl\u7684\u5b57\u7b26\u5220\u53bb\uff0c\u7136\u540e\u6765\u6b63\u5e38\u5339\u914d\uff0c\u6211\u60f3\u8fd9\u4e2a\u590d\u6742\u5ea6\u4e3b\u8981\u53d6\u51b3\u4e8eerase\u7684\u5b9e\u73b0\u539f\u7406\uff0c\u540e\u6765\u770b\u4e86\u65f6\u95f4\uff0c\u548c\u81ea\u5df1\u624b\u5199\u7684\u5dee\u4e0d\u591ahehe\u3002 \u518d\u540e\u6765\u53d1\u73b0\u4e3b\u8981\u662f\u5e38\u6570\u95ee\u9898\uff0c\u6bcf\u6b21\u4fee\u6539\u540e\u90fd\u9700\u8981\u5224\u65ad\u4e00\u6b21\u662f\u4e0d\u662f\u5339\u914d\uff0c\u5982\u679c\u5b57\u7b26\u4e32\u7279\u522b\u957f\u90a3\u4e48\u5c31\u628a\u540c\u4e00\u4e2a\u5730\u65b9\u6bd4\u8f83\u597d\u591a\u6b21\uff0c\u6240\u4ee5\u540e\u6765\u4f18\u5316\u4e86\u4e00\u70b9\u5e38\u6570\uff0c\u628a\u4e0d\u5339\u914d\u7684\u5730\u65b9\u62ff\u51fa\u6765\u4e13\u95e8\u6765\u6d4b\u8bd5\uff0c\u53d1\u73b0\u867d\u7136\u5feb\u4e86\u70b9\uff0c\u4f46\u662f\u8fd8\u662f\u8d85\u65f6\u3002 \u6700\u540e\u5c31\u6ca1\u529e\u6cd5\u4e86\uff0c\u6bd4\u8d5b\u7684\u65f6\u5019\u6ca1\u5199\u51fa\u6765\u771f\u70e6\uff0c\u4ed6\u4eec\u90fd\u5199\u51fa\u6765\u4e86\uff01\uff01\uff01\u8fd9\u9053\u9898\u7684\u89e3\u6cd5\u6211\u4eec\u53ef\u4ee5\u5206\u6790\u4e00\u4e0b\uff0c\u6bcf\u6b21\u5220\u9664\u957f\u5ea6\u4e3al\u7684\u5b57\u7b26\u4e32\u4ece\u5934\u5230\u5c3e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u53d1\u73b0\uff0c\u6709\u4e00\u90e8\u5206\u662f\u5339\u914d\u7684\uff0c\u6709\u4e00\u90e8\u5206\u662f\u4e0d\u5339\u914d\u7684\uff0c\u4e24\u8fb9\u5339\u914d\uff0c\u4e2d\u95f4\u4e0d\u5339\u914d\u65f6\u53ef\u4ee5\u5220\u53bb\u7684\u3002\u6211\u4eec\u5b9a\u4e49\u6700\u957f\u516c\u5171\u524d\u7f00\u662fl,\u6700\u957f\u516c\u5171\u540e\u7f00\u662fr,\u90a3\u4e48x\u662f\u5220\u9664\u7684\u5730\u65b9\uff0cx &gt;= 0 &amp;&amp; x &lt; t.size()\uff0c\u6211\u4eec\u9700\u8981\u628a\u90a3\u4e9b\u4e2d\u95f4\u4e0d\u5339\u914d\u7684\u5730\u65b9\u5220\u9664\u4e86\uff0c\u5220\u9664\u6389\u4e00\u70b9\u524d\u540e\u7f00\u90fd\u662f\u53ef\u4ee5\u7684\uff0c\u5219\u8fd9\u6837\u5c31\u662f\u5339\u914d\u7684\u3002\u5339\u914d\u7684\u60c5\u51b5\u662fx &lt;= l &amp;&amp; x &gt;= l - r #include&lt;map&gt; #include&lt;set&gt; #include&lt;stack&gt; #include&lt;queue&gt; #include&lt;cmath&gt; #include&lt;vector&gt; #include&lt;bitset&gt; #include&lt;cstdio&gt; #include&lt;cstring&gt; #include&lt;fstream&gt; #include&lt;cstdlib&gt; #include&lt;iostream&gt; #include&lt;algorithm&gt; #include&lt;unordered_map&gt; using namespace std; #define endl &#039;\\n&#039; #define IOS \\ ios_base::sync_with_stdio(0); \\ cin.tie(0); \\ cout.tie(0); typedef long long ll; typedef pair&lt;int,int&gt; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[9,7],"class_list":["post-31","post","type-post","status-publish","format-standard","hentry","category-solution","tag-9","tag-7"],"_links":{"self":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/31","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=31"}],"version-history":[{"count":0,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/31\/revisions"}],"wp:attachment":[{"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}