{"id":21,"date":"2016-04-29T22:45:38","date_gmt":"2016-04-29T14:45:38","guid":{"rendered":"http:\/\/tyswly.com\/?p=21"},"modified":"2016-04-29T22:45:38","modified_gmt":"2016-04-29T14:45:38","slug":"codevs-2173%e5%bf%a0%e8%af%9a","status":"publish","type":"post","link":"https:\/\/tys.fun\/?p=21","title":{"rendered":"[CodeVS 2173]\u5fe0\u8bda"},"content":{"rendered":"<p>\u539f\u9898\u89c1<a href=\"http:\/\/codevs.cn\/problem\/2173\/\">CodeVS<\/a><br \/>\n\u5206\u6790\uff1a\u8fd9\u9053\u9898\u4e00\u770b\u65f6\u95f4\u3001\u6570\u636e\u8303\u56f4\u3001\u67e5\u8be2\u65b9\u5f0f\u5c31\u80fd\u77e5\u9053\u80af\u5b9a\u662f\u7ebf\u6bb5\u6811\u3002\u800c\u4e14\u662f\u88f8\u7ebf\u6bb5\u6811\/\/\u96fe\u3002\u3002\u3002<br \/>\n\u987a\u5e26\u5410\u69fd\u4e00\u4e0b\u9898\u9762\uff0c\u8fd9\u4e2a\u4e3b\u4eba\u80fd\u628a\u8d26\u8bb0\u5f97\u90a3\u4e48\u8be6\u7ec6\u8fd8\u8981\u7ba1\u5bb6\u5e72\u4ec0\u4e48\u3002\u3002\u3002<\/p>\n<pre class=\"lang:c++ decode:true\">#include &lt;iostream&gt;\n#include &lt;cstdio&gt;\n#include &lt;algorithm&gt;\nusing namespace std;\nint n, m;\nint c[100005];\nstruct node{\n\tint mini, le, ri;\n}tree[300015];\ninline int leftt(int x)\n{\n\treturn x&lt;&lt;1;\n}\ninline int rightt(int x)\n{\n\treturn (x&lt;&lt;1)^1;\n}\ninline int mid(int x,int y)\n{\n\treturn (x+y)&gt;&gt;1;\n}\ninline void biu(int cur,int l,int r)\n{\n\tif(l==r)\n\t{\n\t\ttree[cur].le=tree[cur].ri=l;\n\t\ttree[cur].mini=c[l];\n\t\treturn;\n\t}\n\telse\n\t{\n\t\tbiu(leftt(cur),l,mid(l,r));\n\t\tbiu(rightt(cur),mid(l,r)+1,r);\n\t\ttree[cur].mini=min(tree[leftt(cur)].mini,tree[rightt(cur)].mini);\n\t\ttree[cur].le=l;\n\t\ttree[cur].ri=r;\n\t}\n\treturn;\n}\nint ask(int cur,int l,int r)\n{\n\tif(tree[cur].le==l&amp;&amp;tree[cur].ri==r)\n\t\treturn tree[cur].mini;\n\telse\n\t{\n\t\tif(r&lt;=tree[leftt(cur)].ri)\n\t\t\treturn ask(leftt(cur),l,r);\n\t\telse if(l&gt;=tree[rightt(cur)].le)\n\t\t\treturn ask(rightt(cur),l,r);\n\t\telse\n\t\t\treturn min(ask(leftt(cur),l,tree[leftt(cur)].ri),ask(rightt(cur),tree[rightt(cur)].le,r));\n\t}\n}\ninline int get_num()\n{\n\tint ans=0;\n\tchar tmp;\n\ttmp=getchar();\n\twhile(tmp&lt;'0'||tmp&gt;'9')\ttmp=getchar();\n\twhile(tmp&gt;='0'&amp;&amp;tmp&lt;='9')\n\t{\n\t\tans=ans*10+tmp-48;\n\t\ttmp=getchar();\n\t}\n\treturn ans;\n}\nint main()\n{\n\tm=get_num();n=get_num();\n\tfor(int i=1;i&lt;=m;i++)\n\t{\n\t\tc[i]=get_num();\n\t}\n\tbiu(1,1,m);\n\tfor(int i=1;i&lt;=n;i++)\n\t{\n\t\tint x, y;\n\t\tx=get_num();\n\t\ty=get_num();\n\t\tcout&lt;&lt;ask(1,x,y)&lt;&lt;\" \";\n\t}\n\treturn 0;\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u9898\u89c1CodeVS \u5206\u6790\uff1a\u8fd9\u9053\u9898\u4e00\u770b\u65f6\u95f4\u3001\u6570\u636e\u8303\u56f4\u3001\u67e5\u8be2\u65b9\u5f0f\u5c31\u80fd\u77e5\u9053\u80af\u5b9a\u662f\u7ebf\u6bb5\u6811\u3002\u800c\u4e14\u662f\u88f8\u7ebf\u6bb5\u6811\/\/\u96fe\u3002\u3002\u3002  &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-21","post","type-post","status-publish","format-standard","hentry","category-report"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/posts\/21","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tys.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=21"}],"version-history":[{"count":0,"href":"https:\/\/tys.fun\/index.php?rest_route=\/wp\/v2\/posts\/21\/revisions"}],"wp:attachment":[{"href":"https:\/\/tys.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=21"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tys.fun\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=21"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tys.fun\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=21"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}