{"id":815,"date":"2020-03-21T10:36:48","date_gmt":"2020-03-21T17:36:48","guid":{"rendered":"http:\/\/209.126.2.187\/?p=815"},"modified":"2020-05-17T12:28:13","modified_gmt":"2020-05-17T19:28:13","slug":"bit-manipulation","status":"publish","type":"post","link":"https:\/\/nanzhou.cc\/index.php\/2020\/03\/21\/bit-manipulation\/","title":{"rendered":"Pure Bit Manipulation"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>In this post, I will introduce problems related to bit manipulation. Before that, you may want to learn the <code>std::bitset&lt;><\/code> class template.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Detials<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/leetcode.com\/problems\/cinema-seat-allocation\/\"><a rel=\"noreferrer noopener\" href=\"https:\/\/leetcode.com\/problems\/cinema-seat-allocation\/\" target=\"_blank\">LC 1386. Cinema Seat Allocation<\/a><\/a><\/h4>\n\n\n\n<p>The problem is not difficult. But it is tricky to write a clean code. The hint is that all valid patterns can be presented by the predefined bit-sets. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"cpp\" class=\"language-cpp\">auto const p1 = bitset&lt;10>(0b011'1100'000);\nauto const p2 = bitset&lt;10>(0b000'1111'000);\nauto const p3 = bitset&lt;10>(0b000'0011'110);<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><a rel=\"noreferrer noopener\" href=\"https:\/\/leetcode.com\/problems\/people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list\/\" target=\"_blank\">LC 1452. People Whose List of Favorite Companies Is Not a Subset of Another List<\/a><\/h4>\n\n\n\n<p>Bitsets support fast intersect and union of unordered sets. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"cpp\" class=\"language-cpp\">\/\/ intersect\na &amp; b\n\/\/ union\na | b\n\/\/ check if a is in b\n(a &amp; b) == a<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Summary In this post, I will introduce problems related to bit manipulation. Before that, you may want to learn the std::bitset&lt;> class template. Detials LC 1386. Cinema Seat Allocation The problem is not difficult. But it is tricky to write a clean code. The hint is that all valid patterns can be presented by the&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48,53],"tags":[],"class_list":["post-815","post","type-post","status-publish","format-standard","hentry","category-alg","category-bit-manipulation"],"_links":{"self":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/815","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/comments?post=815"}],"version-history":[{"count":3,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/815\/revisions"}],"predecessor-version":[{"id":1243,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/815\/revisions\/1243"}],"wp:attachment":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/media?parent=815"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/categories?post=815"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/tags?post=815"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}