{"id":272,"date":"2012-11-19T08:33:00","date_gmt":"2012-11-19T00:33:00","guid":{"rendered":"http:\/\/nike0good.jp1.rpvhost.net\/177"},"modified":"2012-11-19T08:33:00","modified_gmt":"2012-11-19T00:33:00","slug":"poj_2155_the_2d_zkw_segment_tree","status":"publish","type":"post","link":"https:\/\/nike0good.com\/?p=272","title":{"rendered":"POJ 2155(\u4e8c\u7ef4zkw\u7ebf\u6bb5\u6811\uff09"},"content":{"rendered":"<table border=\"0\" width=\"100%\" background=\"http:\/\/poj.org\/images\/table_back.jpg\" style=\"font-family:Simsun\">\n<tbody>\n<tr>\n<td>\n<div style=\"position:absolute; right:10px\">Language:<select size=\"1\"><option value=\"default\" selected=\"selected\"><br \/>\nDefault<\/option><\/select><\/div>\n<div class=\"ptt\" lang=\"en-US\" style=\"text-align:center; font-size:18pt; font-weight:bold; color:blue\">\nMatrix<\/div>\n<div class=\"plm\" style=\"text-align:center; font-size:12pt\">\n<table align=\"center\">\n<tbody>\n<tr>\n<td><strong>Time Limit:<\/strong>&nbsp;3000MS<\/td>\n<td width=\"10px\">&nbsp;<\/td>\n<td><strong>Memory Limit:<\/strong>&nbsp;65536K<\/td>\n<\/tr>\n<tr>\n<td><strong>Total Submissions:<\/strong>&nbsp;13137<\/td>\n<td width=\"10px\">&nbsp;<\/td>\n<td><strong>Accepted:<\/strong>&nbsp;4948<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p class=\"pst\" style=\"font-size:18pt; font-weight:bold; color:blue\">Description<\/p>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u7ed9\u5b9a\u4e00\u4e2a\u77e9\u9635\uff08\u521d\u59cb\u4e3a0\uff09\uff0c\u7ef4\u62a42\u4e2a\u64cd\u4f5c\uff1a<br \/>\n1. C x1 y1 x2 y2 (1 &lt;= x1 &lt;= x2 &lt;= n, 1 &lt;= y1 &lt;= y2 &lt;= n) ,\u4ee5(x1,y1)\u4e3a\u5de6\u4e0a\u89d2\uff0c(x2,y2)\u4e3a\u53f3\u4e0a\u89d2\u7684\u77e9\u9635\u53d6\u53cd\u3002<br \/>\n2. Q x y (1 &lt;= x, y &lt;= n) \u8f93\u51fa(x,y)\u7684\u72b6\u6001\n<\/div>\n<p class=\"pst\" style=\"font-size:18pt; font-weight:bold; color:blue\">Input<\/p>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u7b2c\u4e00\u884c\u4e3a\u6570\u636e\u7ec4\u6570X (X &lt;= 10)<br \/>\n\u6bcf\u7ec4\u6570\u636e\u7b2c\u4e00\u884c\u4e3aN,T (2 &lt;= N &lt;= 1000, 1 &lt;= T &lt;= 50000) \u8868\u793a\u77e9\u9635\u8fb9\u957f\u4e0e\u64cd\u4f5c\u6b21\u6570\u3002<\/div>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n<span style=\"white-space:pre\"><\/span>\u63a5\u4e0b\u6765T\u884c\uff0c\u4e3aQ\u6216C\u64cd\u4f5c&nbsp;\n<\/div>\n<p class=\"pst\" style=\"font-size:18pt; font-weight:bold; color:blue\">Output<\/p>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u8bf7\u8f93\u51fa\u6240\u6709\u63d0\u95ee\u7ed3\u679c\u3002<\/div>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n\u6bcf\u7ec4\u6570\u636e\u540e\u4e00\u56de\u8f66\u3002&nbsp;\n<\/div>\n<p class=\"pst\" style=\"font-size:18pt; font-weight:bold; color:blue\">Sample Input<\/p>\n<pre class=\"sio\" style=\"font-family:'Courier New',Courier,monospace; font-size:12pt\">1\n2 10\nC 2 1 2 2\nQ 2 2\nC 2 1 2 1\nQ 1 1\nC 1 1 2 1\nC 1 2 1 2\nC 1 1 2 2\nQ 1 1\nC 1 1 2 1\nQ 2 1\n<\/pre>\n<p class=\"pst\" style=\"font-size:18pt; font-weight:bold; color:blue\">Sample Output<\/p>\n<pre class=\"sio\" style=\"font-family:'Courier New',Courier,monospace; font-size:12pt\">1\n0\n0\n1\n<\/pre>\n<p class=\"pst\" style=\"font-size:18pt; font-weight:bold; color:blue\">Source<\/p>\n<div class=\"ptx\" lang=\"en-US\" style=\"font-family:'Times New Roman',Times,serif; font-size:12pt\">\n<a href=\"http:\/\/poj.org\/searchproblem?field=source&amp;key=POJ+Monthly\" style=\"text-decoration:none\">POJ Monthly<\/a>,Lou Tiancheng<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-family:Simsun; font-size:14px\">\u8fd9\u9898\u662f\u4e8c\u7ef4\u7684\u7ebf\u6bb5\u6811\uff0c<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\">\u5148\u5efa\u4e00\u68f5\u7ebf\u6bb5\u6811\uff0c\u518d\u5c06\u5b83\u7684\u6240\u6709\u7ed3\u70b9\uff08\u5305\u62ec\u6839\uff09\u5efa\u7acb\u4e00\u4e2a\u4e8c\u53c9\u6811\uff08\u7ef4\u62a4\u8fd9\u4e2a\u7ed3\u70b9\uff09<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\">\u5f02\u6216\u4ec5\u9700\u8bb0\u5f55\u6807\u8bb0\u67d0\u70b9\u6240\u5bf9\u5e94\u7684\u533a\u95f4\u53d6\u53cd<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\">\u67e5\u627e\u65f6\u7edf\u8ba1\u5171\u8bb0\u4e86\u51e0\u4e2a\u6807\u8bb0\u5373\u53ef\uff08\u6807\u8bb0\u6c38\u4e45\u5316\uff09<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-family:Simsun; font-size:14px\"><\/span><\/p>\n<pre name=\"code\" class=\"delphi\">Program Matrix;\nconst\n   maxtt=10;\n   maxn=1000;\n   maxMM=50000;\nvar\n   tt,n,mm,i,j,k,x1,y1,x2,y2,x,y,p1,p2,ans:longint;\n   c:char;\n   t:array[1..5000,1..5000] of boolean;\n   M:longint;\n\nProcedure change_y(x,y1,y2:longint);\nvar\n   i,j:longint;\nbegin\n   dec(y1);inc(y2);\n   inc(y1,M);inc(y2,M);\n   while ((y1 xor y2 xor 1)&gt;0) do\n   begin\n      if ((y1 and 1)=0) then t[x,y1+1]:=not(t[x,y1+1]);\n      if ((y2 and 1)=1) then t[x,y2-1]:=not(t[x,y2-1]);\n      y1:=y1 shr 1;y2:=y2 shr 1;\n   end;\n\nend;\n\nProcedure change_x(x1,y1,x2,y2:longint);\nvar\n   i,j:longint;\nbegin\n   dec(x1);inc(x2);\n   inc(x1,M);inc(x2,M);\n   while ((x1 xor x2 xor 1)&gt;0) do\n   begin\n      if ((x1 and 1)=0) then change_y(x1+1,y1,y2);\n      if ((x2 and 1)=1) then change_y(x2-1,y1,y2);\n      x1:=x1 shr 1;x2:=x2 shr 1;\n   end;\nend;\n\nfunction find_y(x,y:longint):boolean;\nvar\n   i,j:longint;\nbegin\n   inc(y,M); find_y:=false;\n   while (y&gt;0) do\n   begin\n      if (t[x,y]) then find_y:=not(find_y);\n      y:=y shr 1;\n   end;\n\nend;\nfunction find_x(x,y:longint):boolean;\nvar\n   i,j:longint;\nbegin\n   inc(x,M); find_x:=false;\n   while (x&gt;0) do\n   begin\n      find_x:=find_x xor find_y(x,y);\n      x:=x shr 1;\n   end;\nend;\nbegin\n   readln(tt);\n   while (tt&gt;0) do\n   begin\n      fillchar(t,sizeof(t),false);\n      readln(n,mm);\n      M:=1;\n      while (M-2&lt;n) do M:=M shl 1;\n      for k:=1 to mm do\n      begin\n         read(c);\n         if c='C' then\n         begin\n            readln(x1,y1,x2,y2);\n            change_x(x1,y1,x2,y2);\n\n\n\n\n\n         end\n         else\n         begin     \/\/Q\n            readln(x1,y1);\n            if (find_x(x1,y1)) then writeln('1') else writeln('0');\n\n\n         end;\n\n\n\n      end;\n      dec(tt);\n      if (tt&gt;0) then writeln;\n   end;\nend.\n<\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Language: Default Matrix Time Limit:&nbsp;3000MS &nbsp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","footnotes":""},"categories":[3],"tags":[52],"class_list":["post-272","post","type-post","status-publish","format-standard","hentry","category-defaultcategory","tag-the_zkw_segment_tree"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>POJ 2155(\u4e8c\u7ef4zkw\u7ebf\u6bb5\u6811\uff09 - nike0good<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nike0good.com\/?p=272\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"POJ 2155(\u4e8c\u7ef4zkw\u7ebf\u6bb5\u6811\uff09 - nike0good\" \/>\n<meta property=\"og:description\" content=\"Language: Default Matrix Time Limit:&nbsp;3000MS &nbsp; [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nike0good.com\/?p=272\" \/>\n<meta property=\"og:site_name\" content=\"nike0good\" \/>\n<meta property=\"article:published_time\" content=\"2012-11-19T00:33:00+00:00\" \/>\n<meta name=\"author\" content=\"nike0good\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"nike0good\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=272#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=272\"},\"author\":{\"name\":\"nike0good\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\"},\"headline\":\"POJ 2155(\u4e8c\u7ef4zkw\u7ebf\u6bb5\u6811\uff09\",\"datePublished\":\"2012-11-19T00:33:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=272\"},\"wordCount\":79,\"commentCount\":0,\"keywords\":[\"zkw\u7ebf\u6bb5\u6811\"],\"articleSection\":[\"DefaultCategory\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/nike0good.com\\\/?p=272#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=272\",\"url\":\"https:\\\/\\\/nike0good.com\\\/?p=272\",\"name\":\"POJ 2155(\u4e8c\u7ef4zkw\u7ebf\u6bb5\u6811\uff09 - nike0good\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/#website\"},\"datePublished\":\"2012-11-19T00:33:00+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=272#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/nike0good.com\\\/?p=272\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/?p=272#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/nike0good.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"POJ 2155(\u4e8c\u7ef4zkw\u7ebf\u6bb5\u6811\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#website\",\"url\":\"https:\\\/\\\/nike0good.com\\\/\",\"name\":\"nike0good\",\"description\":\"\u6709\u6240\u4f5c\u4e3a\u662f\u4eba\u751f\u7684\u6700\u9ad8\u5883\u754c\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/nike0good.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/nike0good.com\\\/#\\\/schema\\\/person\\\/4defa38da89de87e400861e73396baad\",\"name\":\"nike0good\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g\",\"caption\":\"nike0good\"},\"sameAs\":[\"https:\\\/\\\/nike0good.com\"],\"url\":\"https:\\\/\\\/nike0good.com\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"POJ 2155(\u4e8c\u7ef4zkw\u7ebf\u6bb5\u6811\uff09 - nike0good","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nike0good.com\/?p=272","og_locale":"zh_CN","og_type":"article","og_title":"POJ 2155(\u4e8c\u7ef4zkw\u7ebf\u6bb5\u6811\uff09 - nike0good","og_description":"Language: Default Matrix Time Limit:&nbsp;3000MS &nbsp; [&hellip;]","og_url":"https:\/\/nike0good.com\/?p=272","og_site_name":"nike0good","article_published_time":"2012-11-19T00:33:00+00:00","author":"nike0good","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"nike0good","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nike0good.com\/?p=272#article","isPartOf":{"@id":"https:\/\/nike0good.com\/?p=272"},"author":{"name":"nike0good","@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad"},"headline":"POJ 2155(\u4e8c\u7ef4zkw\u7ebf\u6bb5\u6811\uff09","datePublished":"2012-11-19T00:33:00+00:00","mainEntityOfPage":{"@id":"https:\/\/nike0good.com\/?p=272"},"wordCount":79,"commentCount":0,"keywords":["zkw\u7ebf\u6bb5\u6811"],"articleSection":["DefaultCategory"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nike0good.com\/?p=272#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nike0good.com\/?p=272","url":"https:\/\/nike0good.com\/?p=272","name":"POJ 2155(\u4e8c\u7ef4zkw\u7ebf\u6bb5\u6811\uff09 - nike0good","isPartOf":{"@id":"https:\/\/nike0good.com\/#website"},"datePublished":"2012-11-19T00:33:00+00:00","author":{"@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad"},"breadcrumb":{"@id":"https:\/\/nike0good.com\/?p=272#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nike0good.com\/?p=272"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nike0good.com\/?p=272#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nike0good.com\/"},{"@type":"ListItem","position":2,"name":"POJ 2155(\u4e8c\u7ef4zkw\u7ebf\u6bb5\u6811\uff09"}]},{"@type":"WebSite","@id":"https:\/\/nike0good.com\/#website","url":"https:\/\/nike0good.com\/","name":"nike0good","description":"\u6709\u6240\u4f5c\u4e3a\u662f\u4eba\u751f\u7684\u6700\u9ad8\u5883\u754c","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nike0good.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/nike0good.com\/#\/schema\/person\/4defa38da89de87e400861e73396baad","name":"nike0good","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8e5fa08d5c367a1a6fb5ff13bb10ed5a331f981513256951290ae42322da6854?s=96&d=identicon&r=g","caption":"nike0good"},"sameAs":["https:\/\/nike0good.com"],"url":"https:\/\/nike0good.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts\/272","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=272"}],"version-history":[{"count":0,"href":"https:\/\/nike0good.com\/index.php?rest_route=\/wp\/v2\/posts\/272\/revisions"}],"wp:attachment":[{"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nike0good.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}