{"id":146,"date":"2026-05-16T11:13:38","date_gmt":"2026-05-16T03:13:38","guid":{"rendered":"https:\/\/huxiaole.cloud\/?p=146"},"modified":"2026-05-20T18:32:35","modified_gmt":"2026-05-20T10:32:35","slug":"d-ghostfires","status":"publish","type":"post","link":"https:\/\/huxiaole.cloud\/index.php\/2026\/05\/16\/d-ghostfires\/","title":{"rendered":"D. Ghostfires"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\u9898\u76ee\u63cf\u8ff0<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">OtterZ \u51b3\u5b9a\u7528\u5e7d\u7075\u706b\u5236\u4f5c\u4e00\u628a\u6b66\u5668\u3002\u4ed6\u6536\u96c6\u4e86\u82e5\u5e72\u7ea2\u8272\u3001\u7eff\u8272\u548c\u84dd\u8272\u7684\u5e7d\u7075\u706b\u3002\u4ed6\u5c06\u628a\u4e00\u4e9b\u5e7d\u7075\u706b\u6392\u6210\u4e00\u6392\u6765\u5236\u9020\u6b66\u5668\u3002\u4e3a\u4e86\u8ba9\u6b66\u5668\u53d1\u6325\u6700\u5927\u5a01\u529b\uff0cOtterZ \u5c06\u5c3d\u53ef\u80fd\u591a\u5730\u4f7f\u7528\u5e7d\u7075\u706b\uff0c\u4f46\u5982\u679c\u5728\u8fd9\u4e00\u6392\u4e2d\uff0c\u6709\u4e24\u4e2a\u76f8\u540c\u989c\u8272\u7684\u5e7d\u7075\u706b<strong>\u76f8\u90bb<\/strong>\uff0c\u6216\u8005\u5b83\u4eec\u4e4b\u95f4<strong>\u6070\u597d\u9694\u7740\u4e24\u4e2a<\/strong>\u5e7d\u7075\u706b\uff0c\u6b66\u5668\u5c31\u4f1a\u5931\u63a7\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f62\u5f0f\u5316\u5730\u8bf4\uff0cOtterZ \u6536\u96c6\u4e86 r \u4e2a\u7ea2\u8272\u5e7d\u7075\u706b\u3001g \u4e2a\u7eff\u8272\u5e7d\u7075\u706b\u548c b \u4e2a\u84dd\u8272\u5e7d\u7075\u706b\u3002\u4ed6\u5e0c\u671b\u6784\u9020\u4e00\u4e2a\u7531\u5b57\u7b26 &#8216;R&#8217;\u3001&#8217;G&#8217; \u548c &#8216;B&#8217; \u7ec4\u6210\u7684\u5b57\u7b26\u4e32 s\uff0c\u6ee1\u8db3\u4ee5\u4e0b\u6761\u4ef6\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5b57\u7b26\u4e32 s \u4e2d &#8216;R&#8217;\u3001&#8217;G&#8217; \u548c &#8216;B&#8217; \u7684\u51fa\u73b0\u6b21\u6570\u5206\u522b\u4e0d\u8d85\u8fc7 r\u3001g \u548c b\u3002<br><\/li>\n\n\n\n<li>\u5bf9\u4e8e\u6240\u6709\u7684$ 1 \\le i \\le |s|-1\uff0cs_i \\neq s_{i+1}$\u3002<br><\/li>\n\n\n\n<li>\u5bf9\u4e8e\u6240\u6709\u7684$ 1 \\le i \\le |s|-3\uff0cs_i \\neq s_{i+3}$\u3002<br><\/li>\n\n\n\n<li>\u5b57\u7b26\u4e32 s \u7684\u957f\u5ea6\u6700\u5927\u3002<br><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">\u8bf7\u5e2e\u52a9 OtterZ \u6784\u9020\u8fd9\u4e00\u6392\u5e7d\u7075\u706b\u3002\u867d\u7136\u53ef\u80fd\u6709\u591a\u4e2a\u6ee1\u8db3\u6761\u4ef6\u7684\u6392\u5217\u65b9\u5f0f\uff0cOtterZ \u53ea\u9700\u8981\u5176\u4e2d\u4efb\u610f\u4e00\u4e2a\u5373\u53ef\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u5165\u683c\u5f0f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bcf\u4e2a\u6d4b\u8bd5\u70b9\u5305\u542b\u591a\u4e2a\u6d4b\u8bd5\u7528\u4f8b\u3002\u7b2c\u4e00\u884c\u5305\u542b\u6d4b\u8bd5\u7528\u4f8b\u7684\u6570\u91cf t$ (1 \\le t \\le 10^4)$\u3002\u63a5\u4e0b\u6765\u662f\u6d4b\u8bd5\u7528\u4f8b\u7684\u63cf\u8ff0\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bcf\u4e2a\u6d4b\u8bd5\u7528\u4f8b\u53ea\u6709\u4e00\u884c\uff0c\u5305\u542b\u4e09\u4e2a\u6574\u6570 r\u3001g \u548c b$ (0 \\le r, g, b \\le 10^6\uff0cr+g+b > 0)$\uff0c\u5206\u522b\u8868\u793a\u7ea2\u8272\u3001\u7eff\u8272\u548c\u84dd\u8272\u5e7d\u7075\u706b\u7684\u6570\u91cf\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u4fdd\u8bc1\u6240\u6709\u6d4b\u8bd5\u7528\u4f8b\u4e2d r+g+b \u7684\u603b\u548c\u4e0d\u8d85\u8fc7$ 10^6$\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u51fa\u683c\u5f0f<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u5bf9\u4e8e\u6bcf\u4e2a\u6d4b\u8bd5\u7528\u4f8b\uff0c\u8f93\u51fa\u4e00\u4e2a\u7531\u5b57\u7b26 &#8216;R&#8217;\u3001&#8217;G&#8217; \u548c &#8216;B&#8217; \u7ec4\u6210\u7684\u5b57\u7b26\u4e32 s\u3002\u5176\u4e2d$ s_i $\u4e3a &#8216;R&#8217;\u3001&#8217;G&#8217; \u6216 &#8216;B&#8217; \u5206\u522b\u8868\u793a\u7b2c i \u4e2a\u5e7d\u7075\u706b\u662f\u7ea2\u8272\u3001\u7eff\u8272\u6216\u84dd\u8272\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5982\u679c\u6709\u591a\u4e2a\u6700\u4f18\u7b54\u6848\uff0c\u8f93\u51fa\u4efb\u610f\u4e00\u4e2a\u5373\u53ef\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u6837\u4f8b<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8f93\u5165\u6837\u4f8b<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Plaintext<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>5\n0 0 1\n1 1 1\n0 3 0\n2 2 2\n2 7 3\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8f93\u51fa\u6837\u4f8b<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Plaintext<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>B\nRGB\nG\nGBRBRG\nGRGRGBGBGBG\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u63d0\u793a<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5bf9\u4e8e\u7b2c\u4e00\u4e2a\u6d4b\u8bd5\u7528\u4f8b\uff0c&#8221;B&#8221; \u662f\u552f\u4e00\u6709\u6548\u7684\u6784\u9020\u3002<br><\/li>\n\n\n\n<li>\u5bf9\u4e8e\u7b2c\u4e8c\u4e2a\u6d4b\u8bd5\u7528\u4f8b\uff0c&#8221;RGB&#8221;\u3001&#8221;RBG&#8221;\u3001&#8221;GRB&#8221;\u3001&#8221;BRG&#8221; \u548c &#8220;BGR&#8221; \u90fd\u662f\u6b63\u786e\u7684\u3002<br><\/li>\n\n\n\n<li>\u5bf9\u4e8e\u7b2c\u4e09\u4e2a\u6d4b\u8bd5\u7528\u4f8b\uff0c&#8221;GG&#8221; \u548c &#8220;GGG&#8221; \u90fd\u662f\u65e0\u6548\u7684\uff0c\u56e0\u4e3a s_1 = s_2\uff0c\u8fdd\u53cd\u4e86\u76f8\u90bb\u4e0d\u80fd\u540c\u8272\u7684\u89c4\u5219\u3002<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">\u601d\u8def<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u7ecf\u9a8c\u4e4b\u8c08\uff0c\u4f18\u5148\u9009\u6700\u5927\u7684\uff0c\u63a5\u7740\u9009\u6b21\u5927\u7684\uff0c\u540c\u65f6\u8981\u7b26\u5408\u6761\u4ef6\u8981\u6c42$(s_i\\neq s_{i-3} and s_i\\neq s_{i-1})$\uff0c\u5982\u679c\u4e09\u8005\u76f8\u7b49\uff0c\u90a3\u4e48\u4f18\u5148\u9009$s_i = s_i-2$,\u5982\u679c\u9009\u4e0d\u5230\uff0c\u90a3\u5c31\u7ed3\u675f\u561e\uff01<br>\u65f6\u95f4\u590d\u6742\u5ea6O\uff08n\uff09\uff0c\u6a21\u62df\u8fc7\u53bb\u6ca1\u95ee\u9898\uff0c\u6211\u5b66\u5230\u4e86\u53ef\u4ee5\u7528\u4e00\u4e2a\u6570\u7ec4\u904d\u5386\uff0c\u627e\u5230\u5f53\u524d\u6700\u5927\u503c<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ee3\u7801<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/&nbsp;Sunshine,&nbsp;sunshine,&nbsp;ladybugs&nbsp;awake!  \n\/\/&nbsp;Clap&nbsp;your&nbsp;hooves&nbsp;and&nbsp;do&nbsp;a&nbsp;little&nbsp;shake!  \n#include&nbsp;&lt;bits\/stdc++.h&gt;  \n#define&nbsp;int&nbsp;long&nbsp;long  \n\/\/#define&nbsp;endl&nbsp;'\\n'  \nusing&nbsp;namespace&nbsp;std;  \n  \nusing&nbsp;PII=pair&lt;int,int&gt;&nbsp;;  \nusing&nbsp;PIC=pair&lt;int,char&gt;&nbsp;;  \ninline&nbsp;static&nbsp;constexpr&nbsp;int&nbsp;MAXN=2010;  \ninline&nbsp;static&nbsp;constexpr&nbsp;int&nbsp;mod=1e9+7;  \n  \nvoid&nbsp;solve()&nbsp;{  \n&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;a1,b1,c1;  \n&nbsp;&nbsp;&nbsp;&nbsp;cin&gt;&gt;a1&gt;&gt;b1&gt;&gt;c1;  \n&nbsp;&nbsp;&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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if(a&#91;i].first&gt;a&#91;idx].first)  \n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;idx=i;  \n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if(cnt&gt;=2&amp;&amp;a&#91;i].first==a&#91;idx].first&amp;&amp;a&#91;i].second==s&#91;cnt-2])  \n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;idx=i;  \n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  \n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(idx==-1)break;  \n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a&#91;idx].first--;  \n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s+=a&#91;idx].second;  \n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cnt++;  \n&nbsp;&nbsp;&nbsp;&nbsp;}  \n&nbsp;&nbsp;&nbsp;&nbsp;cout&lt;&lt;s&lt;&lt;endl;  \n}  \n  \nsigned&nbsp;main()&nbsp;{  \n&nbsp;&nbsp;&nbsp;&nbsp;ios_base::sync_with_stdio(false);  \n&nbsp;&nbsp;&nbsp;&nbsp;cin.tie(NULL);  \n&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;t;cin&nbsp;&gt;&gt;&nbsp;t;while&nbsp;(t--)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;solve();  \n&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;0;  \n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u63cf\u8ff0 OtterZ \u51b3\u5b9a\u7528\u5e7d\u7075\u706b\u5236\u4f5c\u4e00\u628a\u6b66\u5668\u3002\u4ed6\u6536\u96c6\u4e86\u82e5\u5e72\u7ea2\u8272\u3001\u7eff\u8272\u548c\u84dd\u8272\u7684\u5e7d\u7075\u706b\u3002\u4ed6\u5c06\u628a\u4e00\u4e9b\u5e7d\u7075\u706b\u6392\u6210\u4e00 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":136,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,11,10],"tags":[],"class_list":["post-146","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-codeforces","category-11","category-10"],"_links":{"self":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=146"}],"version-history":[{"count":2,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/146\/revisions"}],"predecessor-version":[{"id":206,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/posts\/146\/revisions\/206"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/media\/136"}],"wp:attachment":[{"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/huxiaole.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}