{"id":493,"date":"2018-12-17T19:17:55","date_gmt":"2018-12-17T11:17:55","guid":{"rendered":"http:\/\/SmokeyDays.top\/wordpress\/?p=493"},"modified":"2018-12-17T19:17:55","modified_gmt":"2018-12-17T11:17:55","slug":"agc029","status":"publish","type":"post","link":"http:\/\/SmokeyDays.top\/wordpress\/2018\/12\/17\/agc029\/","title":{"rendered":"AGC029"},"content":{"rendered":"\n<p>\u8fd9\u4e00\u573a\u6253\u5f97\u8fd8\u884c\uff0c\u53ef\u60dcC\u6ca1\u6709\u8c03\u51fa\u6765\u3002\u4e0d\u8fc7\u8fd8\u662f\u66b4\u6da8\u4e03\u767e\u591a\u5206\u3002\u6478\u4e0d\u900f\u7b97\u5206\u673a\u5236\u3002<\/p>\n\n\n\n<p>AGC 29 A<br>\n\u7ed9\u5b9a\u4e00\u4e2a01\u5e8f\u5217\uff0c\u6bcf\u4e00\u6b21\u53ef\u4ee5\u628a01\u53d8\u621010\uff0c\u6c42\u6700\u5927\u64cd\u4f5c\u6b21\u6570\u3002<br>\n\u731c\u7ed3\u8bba\u9898\uff08\u5176\u5b9e\u8bc1\u660e\u5f88\u663e\u7136\uff09\u3002\u7ed3\u8bba\u662f\u6bcf\u4e00\u4e2a1\u540e\u9762\u76840\u7684\u4e2a\u6570\u4e4b\u548c\u3002 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\n#include&lt;cstdio>\n#include&lt;cstring>\n\nint n;\nchar ch[200005];\nint sm[200005];\nvoid init(){\n\tstd::cin>>(ch+1);\n\tn=std::strlen(ch+1);\n\tfor(int i=1;i&lt;=n;++i){\n\t\tch[i]=(ch[i]=='B'?1:0);\n\t}\n\tsm[n+1]=0;\n\tfor(int i=n;i>=1;--i){\n\t\tsm[i]=sm[i+1]+(ch[i]^1);\n\t}\n\tlong long ans=0;\n\tfor(int i=1;i&lt;=n;++i){\n\t\tif(ch[i]){\n\t\t\tans+=sm[i+1];\n\t\t}\n\t}\n\tprintf(\"%lld\",ans);\n}\n\nint main(){\n\tinit();\n\treturn 0;\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>AGC 29 B<br>\n\u7ed9\u5b9a\u4e00\u4e2a\u5e8f\u5217\uff0c\u95ee\u4ece\u4e2d\u6700\u591a\u80fd\u627e\u51fa\u591a\u5c11\u4e2a\u6570\u5bf9\u4f7f\u5f97\u5b83\u4eec\u7684\u548c\u662f\u4e8c\u7684\u6b21\u5e42\u3002<br>\n\u8d2a\u5fc3\u3002\u8003\u8651\u4ece\u5927\u5f80\u5c0f\u904d\u5386\uff0c\u5982\u679c\u4e00\u4e2a\u5927\u7684\u6570\u80fd\u591f\u627e\u5230\u4e00\u4e2a\u6bd4\u5b83\u5c0f\u7684\u6570\u914d\u6210\u4e8c\u7684\u6b21\u5e42\uff0c\u90a3\u4e48\u4e0d\u9009\u8fd9\u4e2a\u5927\u7684\u6570\u80af\u5b9a\u4e0d\u4f1a\u66f4\u4f18\u3002<br>\n\u7528\\(map\\)\u4f18\u5316\u4e00\u4e0b\u5373\u53ef\u3002 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\n#include&lt;cstdio>\n#include&lt;map>\n#include&lt;algorithm>\n\nstd::map&lt;int,int> mp;\n\nint n,a[200005];\n\nvoid init(){\n\tscanf(\"%d\",&amp;n);\n\tfor(int i=1;i&lt;=n;++i){\n\t\tscanf(\"%d\",a+i);\n\t\tmp[a[i]]?(++mp[a[i]]):mp[a[i]]=1;\n\t}\n\tstd::map&lt;int,int>::iterator it=mp.end();\n\t--it;\n\t\n\tint ans=0,nw;\n\twhile(1){\n\t\tif(it->second==0){\n\t\t\tgoto loop;\n\t\t}\n\t\tnw=it->first;\n\t\tfor(int i=30;i>=1;--i){\n\t\t\twhile(it->second>=1&amp;&amp;(1&lt;&lt;i)-nw>=0&amp;&amp;mp[(1&lt;&lt;i)-nw]>=1&amp;&amp;(nw!=(1&lt;&lt;(i-1)))){\n\t\t\t\t--mp[(1&lt;&lt;i)-nw];\n\t\t\t\tit->second-=1;\n\t\t\t\t++ans;\n\t\t\t}\n\t\t\twhile(it->second>=2&amp;&amp;nw==(1&lt;&lt;(i-1))){\n\t\t\t\tit->second-=2;\n\t\t\t\t++ans;\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tloop:\n\t\t\tif(it==mp.begin()){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t--it;\n\t}\n\t\n\tprintf(\"%d\\n\",ans);\n} \n\nint main(){\n\tinit();\n\treturn 0;\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>AGC 29 D<br>\n\u5bb9\u6613\u77e5\u9053\uff0c\u6bcf\u4e00\u8f6eT\u4e00\u5b9a\u662f\u80fd\u8d70\u5c31\u8d70\u3002\u56e0\u4e3a\u5982\u679cT\u4e0d\u8d70\uff0c\u90a3\u4e48A\u5c31\u53ef\u4ee5\u901a\u8fc7\u4e0d\u8d70\u6765\u5f3a\u8feb\u6e38\u620f\u7ed3\u675f\u3002 <br>\n\u5e76\u4e14\uff0c\u5982\u679cP\u7ecf\u8fc7\u4e86\u4e00\u4e2a\u969c\u788d\u4e0a\u65b9\uff0c\u6e38\u620f\u5c31\u7ed3\u675f\u4e86\u3002\u6240\u4ee5A\u4e00\u5b9a\u4f1a\u5c3d\u53ef\u80fd\u5730\u8ba9P\u8d70\u5230\u4e00\u4e2a\u969c\u788d\u4e0a\u65b9\u3002 <br>\n\u6545\u800c\uff0cA\u4e0d\u5f80\u53f3\u8d70\uff0c\u53ea\u6709\u4e24\u79cd\u60c5\u51b5\u3002\u4e00\uff0c\u662f\u4e0b\u65b9\u5b58\u5728\u4e00\u4e2a\u969c\u788d\uff1b\u4e8c\uff0c\u662f\u53f3\u8fb9\u6709\u969c\u788d\u6321\u4f4f\u3002<br>\n\u5f88\u663e\u7136\uff0c\u5982\u679c\u56fa\u5b9a\u8d77\u59cb\u70b9\uff0c\u53ea\u6709\u6a2a\u5750\u6807\u4e0e\u7eb5\u5750\u6807\u76f8\u540c\u7684\u70b9\u624d\u4f1a\u6321\u4f4fA\u3002<br>\n\u56e0\u6b64\uff0c\u6bcf\u4e00\u6b21A\u88ab\u6321\u4f4f\u4e86\uff0c\u5c31\u66f4\u65b0\u8d77\u59cb\u70b9\uff0c\u7136\u540e\u5411\u4e0b\u8d70\u5373\u53ef\u3002 <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include&lt;iostream>\n#include&lt;cstdio>\n#include&lt;algorithm>\n\nstruct data{\n\tint x;int y;\n\tinline bool operator&lt;(const data &amp;B){\n\t\treturn x==B.x?y&lt;B.y:x&lt;B.x;\n\t}\n\tinline void init(int X,int Y){\n\t\tx=X,y=Y;\n\t}\n}a[200005];\nint n,h,w;\nvoid init(){\n\tscanf(\"%d%d%d\",&amp;h,&amp;w,&amp;n);\n\tint x,y;\n\tfor(int i=1;i&lt;=n;++i){\n\t\tscanf(\"%d%d\",&amp;x,&amp;y);\n\t\ta[i].init(x,y);\n\t}\n\tstd::sort(a+1,a+1+n);\n\tint nw=0;\n\tfor(int i=1;i&lt;=n;++i){\n\t\tif(a[i].x-nw==a[i].y){\n\t\t\t++nw;\n\t\t}\n\t\tif(a[i].x-nw>a[i].y){\n\t\t\tprintf(\"%d\\n\",a[i].x-1);\n\t\t\treturn;\n\t\t}\n\t}\n\tprintf(\"%d\\n\",h);\n}\n\nint main(){\n\tinit();\n\treturn 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u4e00\u573a\u6253\u5f97\u8fd8\u884c\uff0c\u53ef\u60dcC\u6ca1\u6709\u8c03\u51fa\u6765\u3002\u4e0d\u8fc7\u8fd8\u662f\u66b4\u6da8\u4e03\u767e\u591a\u5206\u3002\u6478\u4e0d\u900f\u7b97\u5206\u673a\u5236\u3002 AGC 29 A \u7ed9\u5b9a\u4e00\u4e2a01\u5e8f\u5217\uff0c &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/SmokeyDays.top\/wordpress\/2018\/12\/17\/agc029\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cAGC029\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,64,5],"tags":[],"_links":{"self":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/493"}],"collection":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/comments?post=493"}],"version-history":[{"count":1,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/493\/revisions"}],"predecessor-version":[{"id":494,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/493\/revisions\/494"}],"wp:attachment":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/media?parent=493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/categories?post=493"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/tags?post=493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}