{"id":227,"date":"2018-10-26T07:51:17","date_gmt":"2018-10-25T23:51:17","guid":{"rendered":"http:\/\/SmokeyDays.top\/wordpress\/?p=227"},"modified":"2018-10-26T07:52:22","modified_gmt":"2018-10-25T23:52:22","slug":"cf1073","status":"publish","type":"post","link":"http:\/\/SmokeyDays.top\/wordpress\/2018\/10\/26\/cf1073\/","title":{"rendered":"CF1073"},"content":{"rendered":"<p>CF1073A<\/p>\n<p>\u4e00\u9053\u6c34\u9898\u3002<br \/>\n\u9996\u5148\u4ece\u9898\u610f\u53ef\u77e5\uff0c\u5f53\u8fde\u7eed\u4e24\u4e2a\u5b57\u7b26\u4e0d\u540c\u7684\u65f6\u5019\uff0c\u8fd9\u6837\u7684\u5b57\u7b26\u4e32\u5c31\u662f\u5408\u6cd5\u7684\u3002<br \/>\n\u6240\u4ee5\u627e\u7b2c\u4e00\u7ec4\u4e24\u4e2a\u4e0d\u540c\u7684\u5b57\u7b26\u5373\u53ef\u3002<\/p>\n<p>CF1073B<\/p>\n<p>\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\uff0c\u4f9d\u7167\u9898\u610f\u5927\u529b\u6a21\u62df\u5373\u53ef\u3002<\/p>\n<p>CF1073C<\/p>\n<p>\u6709\u4e00\u5b9a\u96be\u5ea6\u7684\u6c34\u9898\uff0c\u4f46\u662f\u6211\u8003\u573a\u4e0a\u6ca1 \u8c03 \u51fa \u6765\uff01<br \/>\n\u5176\u5b9e\u5f88\u5bb9\u6613\u53ef\u4ee5\u60f3\u5230\uff0c\u56e0\u4e3a\u5f53\u957f\u5ea6\u4e3a\\(len\\)\u7684\u53ef\u884c\uff0c\u957f\u5ea6\u4e3a\\(len+1\\)\u7684\u4e5f\u4e00\u5b9a\u53ef\u884c\u3002<br \/>\n\u6240\u4ee5\u8003\u8651\u4e8c\u5206\u7b54\u6848\u3002<br \/>\n\u5982\u4f55\u68c0\u9a8c\u5462\uff1f\u5176\u5b9e\u5c31\u662f\u5c06\u4e00\u8fde\u4e32\u7684\u79fb\u52a8\u79fb\u9664\u4e86\uff0c\u7136\u540e\u8003\u8651\u5b83\u524d\u9762\u7684\u90e8\u5206\u52a0\u4e0a\u540e\u9762\u7684\u90e8\u5206\uff0c\u518d\u52a0\u4e0a\u957f\u5ea6\u4e3alen\u7684\u79fb\u52a8\u5e8f\u5217\uff0c\u8981\u600e\u6837\u624d\u80fd\u8d70\u5230\u7ec8\u70b9\u3002<br \/>\n\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u9884\u5904\u7406\u66fc\u54c8\u987f\u8ddd\u79bb\u524d\u7f00\u548c\u3002\u4e8e\u662f\u53ef\u4ee5\\(O(1)\\)\u68c0\u9a8c\u3002<br \/>\n\u8fd9\u9898\u5c31\u505a\u5b8c\u4e86\u3002<br \/>\n\u4f46\u662f\uff0c\u6211\u8c03\u4e86\u4e00\u4e2a\u591a\u5c0f\u65f6\u2014\u2014<br \/>\n\u56e0\u4e3a\u6211\u7684Abs\u51fd\u6570\u5199\u6302\u4e86\uff01\uff01\uff01\uff01\uff01<br \/>\n\u4e8e\u662f\u5c31\u4ece\u5f00\u5fc3\u4e0a\u5206\u573a\u53d8\u6210\u4e86\u6389\u5206\u573a\u3002<br \/>\n\u7f3a\u7701\u6e90\u80fd\u5199\u6302\u4e5f\u662f\u5f88\u5389\u5bb3\u3002<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"cpp\">#include&lt;iostream&gt;\r\n#include&lt;cstdio&gt;\r\n#include&lt;cstring&gt;\r\n#include&lt;algorithm&gt;\r\n#include&lt;queue&gt;\r\n#include&lt;vector&gt;\r\nusing namespace std;\r\n#define Max(_A,_B) ((_A)&gt;(_B)?(_A):(_B))\r\n#define Min(_A,_B) ((_A)&lt;(_B)?(_A):(_B))\r\n#define INF 0x3f3f3f3f\r\n#define Abs(_A) ((_A)&gt;0?(_A):(-(_A)))\r\n\/*\r\nCF1073A\r\n*\/\r\nint n;\r\nchar ch[1005];\r\ninline void pt(const char &amp;a,const char &amp;b){\r\n\tputs(\"YES\");\r\n\tputchar(b),putchar(a);\r\n} \r\nvoid init(){\r\n\tscanf(\"%d\",&amp;n);\r\n\tcin&gt;&gt;ch;\r\n\tint nw=0;\r\n\tfor(int i=0;i&lt;n;++i){\r\n\t\tif(!i){\r\n\t\t\tnw=ch[i];\r\n\t\t}\r\n\t\tif(ch[i]!=nw){\r\n\t\t\tpt(ch[i],nw);\r\n\t\t\treturn;\r\n\t\t}\r\n\t}\r\n\tputs(\"NO\");\r\n}\r\nint main(){\r\n\tinit();\r\n\treturn 0;\r\n}\r\n<\/code><\/pre>\n<pre class=\"pure-highlightjs\"><code class=\"cpp\">#include&lt;iostream&gt;\r\n#include&lt;cstdio&gt;\r\n#include&lt;cstring&gt;\r\n#include&lt;algorithm&gt;\r\n#include&lt;queue&gt;\r\n#include&lt;vector&gt;\r\nusing namespace std;\r\n#define Max(_A,_B) ((_A)&gt;(_B)?(_A):(_B))\r\n#define Min(_A,_B) ((_A)&lt;(_B)?(_A):(_B))\r\n#define INF 0x3f3f3f3f\r\n#define Abs(_A) ((_A)&gt;0?(_A):(-(_A)))\r\n\/*\r\nCF1073B\r\n*\/\r\nint n,a[200005],b[200005];\r\nbool bckt[200005];\r\npriority_queue&lt; int,vector&lt;int&gt;,greater&lt;int&gt; &gt; q;\r\nvoid init(){\r\n\tscanf(\"%d\",&amp;n);\r\n\tmemset(bckt,0,sizeof(bckt));\r\n\tfor(int i=1;i&lt;=n;++i){\r\n\t\tscanf(\"%d\",&amp;a[i]);\r\n\t}\r\n\tint cnt=0,p=1;\r\n\tfor(int i=1;i&lt;=n;++i){\r\n\t\tscanf(\"%d\",&amp;b[i]);\r\n\t\tcnt=0;\r\n\t\tif(bckt[b[i]]){\r\n\t\t\tprintf(\"0 \");\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\twhile(a[p]!=b[i]&amp;&amp;p&lt;=n){\r\n\t\t\tbckt[a[p]]=1;\r\n\t\t\t++cnt;\r\n\t\t\t++p;\r\n\t\t}\r\n\t\tif(a[p]==b[i]){\r\n\t\t\tbckt[a[p]]=1;\r\n\t\t\t++cnt;\r\n\t\t\t++p;\r\n\t\t}\r\n\t\tprintf(\"%d \",cnt);\r\n\t}\r\n\t\r\n}\r\nint main(){\r\n\tinit();\r\n\treturn 0;\r\n}\r\n<\/code><\/pre>\n<pre class=\"pure-highlightjs\"><code class=\"cpp\">#include&lt;iostream&gt;\r\n#include&lt;cstdio&gt;\r\n#include&lt;cstring&gt;\r\n#include&lt;algorithm&gt;\r\n#include&lt;queue&gt;\r\n#include&lt;vector&gt;\r\nusing namespace std;\r\n#define Max(_A,_B) ((_A)&gt;(_B)?(_A):(_B))\r\n#define Min(_A,_B) ((_A)&lt;(_B)?(_A):(_B))\r\n#define INF 0x3f3f3f3f\r\n#define Abs(_A) ((_A)&gt;0?(_A):(-(_A)))\r\n\/*\r\nCF1073C\r\n\u6709\u4e00\u5b9a\u96be\u5ea6\u7684\u6c34\u9898\uff0c\u4f46\u662f\u6211\u8003\u573a\u4e0a\u6ca1 \u8c03 \u51fa \u6765\uff01\r\n\u5176\u5b9e\u5f88\u5bb9\u6613\u53ef\u4ee5\u60f3\u5230\uff0c\u56e0\u4e3a\u5f53\u957f\u5ea6\u4e3a$lated len$\u7684\u53ef\u884c\uff0c\u957f\u5ea6\u4e3a\\(len+1\\)\u7684\u4e5f\u4e00\u5b9a\u53ef\u884c\u3002\r\n\u6240\u4ee5\u8003\u8651\u4e8c\u5206\u7b54\u6848\u3002\r\n\u5982\u4f55\u68c0\u9a8c\u5462\uff1f\u5176\u5b9e\u5c31\u662f\u5c06\u4e00\u8fde\u4e32\u7684\u79fb\u52a8\u79fb\u9664\u4e86\uff0c\u7136\u540e\u8003\u8651\u5b83\u524d\u9762\u7684\u90e8\u5206\u52a0\u4e0a\u540e\u9762\u7684\u90e8\u5206\uff0c\u518d\u52a0\u4e0a\u957f\u5ea6\u4e3alen\u7684\u79fb\u52a8\u5e8f\u5217\uff0c\u8981\u600e\u6837\u624d\u80fd\u8d70\u5230\u7ec8\u70b9\u3002 \r\n\u56e0\u6b64\u6211\u4eec\u53ef\u4ee5\u9884\u5904\u7406\u66fc\u54c8\u987f\u8ddd\u79bb\u524d\u7f00\u548c\u3002\u4e8e\u662f\u53ef\u4ee5\\(O(1)\\)\u68c0\u9a8c\u3002\r\n\u8fd9\u9898\u5c31\u505a\u5b8c\u4e86\u3002\r\n\u4f46\u662f\uff0c\u6211\u8c03\u4e86\u4e00\u4e2a\u591a\u5c0f\u65f6\u2014\u2014\r\n\u56e0\u4e3a\u6211\u7684Abs\u51fd\u6570\u5199\u6302\u4e86\uff01\uff01\uff01\uff01\uff01\r\n\u4e8e\u662f\u5c31\u4ece\u5f00\u5fc3\u4e0a\u5206\u573a\u53d8\u6210\u4e86\u6389\u5206\u573a\u3002\r\n\u7f3a\u7701\u6e90\u80fd\u5199\u6302\u4e5f\u662f\u5f88\u5389\u5bb3\u3002 \r\n*\/\r\nint n;\r\nchar ch[200005];\r\nint X,Y,smx[200005],smy[200005];\r\ninline bool cckk(const int &amp;s,const int &amp;t,const int &amp;len){\r\n\tint dx=X-(smx[n]-smx[t])-smx[s-1],dy=Y-(smy[n]-smy[t])-smy[s-1];\r\n\tif(((dx+dy)&amp;1)!=(len&amp;1)){\r\n\t\treturn 0;\r\n\t}\r\n\tif((Abs(dx)+Abs(dy)&gt;len)){\r\n\t\treturn 0;\r\n\t}\r\n\treturn 1;\r\n}\r\ninline bool chck(const int &amp;len){\r\n\tfor(int i=1;i-1+len&lt;=n;++i){\r\n\t\tif(cckk(i,i+len-1,len)){\r\n\t\t\treturn 1;\r\n\t\t}\r\n\t}\r\n\treturn 0;\r\n}\r\nvoid init(){\r\n\tscanf(\"%d\",&amp;n);\r\n\tcin&gt;&gt;ch+1;\r\n\tscanf(\"%d%d\",&amp;X,&amp;Y);\r\n\tsmx[0]=smy[0]=0;\r\n\tfor(int i=1;i&lt;=n;++i){\r\n\t\tif(ch[i]=='U'){\r\n\t\t\tsmy[i]=smy[i-1]+1;\r\n\t\t\tsmx[i]=smx[i-1];\r\n\t\t}else if(ch[i]=='D'){\r\n\t\t\tsmy[i]=smy[i-1]-1;\r\n\t\t\tsmx[i]=smx[i-1];\r\n\t\t}else if(ch[i]=='L'){\r\n\t\t\tsmx[i]=smx[i-1]-1;\r\n\t\t\tsmy[i]=smy[i-1];\r\n\t\t}else if(ch[i]=='R'){\r\n\t\t\tsmx[i]=smx[i-1]+1;\r\n\t\t\tsmy[i]=smy[i-1];\r\n\t\t}\r\n\t}\r\n\tint l=0,r=n+1,mid;\r\n\twhile(l&lt;r){\r\n\t\tmid=(l+r)&gt;&gt;1;\r\n\t\tif(chck(mid)){\r\n\t\t\tr=mid;\r\n\t\t}else{\r\n\t\t\tl=mid+1;\r\n\t\t}\r\n\t}\r\n\tif(l&gt;n){\r\n\t\tputs(\"-1\");\r\n\t}else{\r\n\t\tprintf(\"%d\",l);\r\n\t}\r\n}\r\nint main(){\r\n\tinit();\r\n\treturn 0;\r\n}\r\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CF1073A \u4e00\u9053\u6c34\u9898\u3002 \u9996\u5148\u4ece\u9898\u610f\u53ef\u77e5\uff0c\u5f53\u8fde\u7eed\u4e24\u4e2a\u5b57\u7b26\u4e0d\u540c\u7684\u65f6\u5019\uff0c\u8fd9\u6837\u7684\u5b57\u7b26\u4e32\u5c31\u662f\u5408\u6cd5\u7684\u3002 \u6240\u4ee5\u627e\u7b2c\u4e00\u7ec4\u4e24 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/SmokeyDays.top\/wordpress\/2018\/10\/26\/cf1073\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201cCF1073\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":[20,5],"tags":[],"_links":{"self":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/227"}],"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=227"}],"version-history":[{"count":2,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/227\/revisions"}],"predecessor-version":[{"id":229,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/posts\/227\/revisions\/229"}],"wp:attachment":[{"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/media?parent=227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/categories?post=227"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/SmokeyDays.top\/wordpress\/wp-json\/wp\/v2\/tags?post=227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}