hihocoder#1513: Little Hi's Trouble bitset

Source: Internet
Author: User
Tags bitset

Directory

    • Topic links
    • Exercises
    • Code
Topic links

hihocoder#1513: The worry of Little hi

Exercises

CDQ sets of CDQ sets of CDQ sets of CDQ is finished
Open n bitset for each section indicates who is currently in the section
Every time the query is &.

Code
#include <cstdio> #include <bitset> #include <cstring> #include <algorithm> #define LL Long Long #     Define GC GetChar () #define PC Putcharinline int read () {int x = 0,f = 1;     char C = GC;     while (C < ' 0 ' | | c > ' 9 ') C = GC;     while (c <= ' 9 ' && C >= ' 0 ') x = x * ten + C-' 0 ', C = GC; return x * f;}      void print (LL x) {if (x >=) print (X/10); PC (x 10 + ' 0 '); } const int MAXN = 30007; std::bitset<maxn>b[6][maxn]; int a[maxn][6]; int RK[MAXN];     int main () {int n = read ();          for (int i = 1;i <= n;++ i) for (int j = 1;j <= 5;++ j) {A[i][j] = read ();         } for (int j = 1;j <= 5;++ j) {for (int i = 1;i <= n;++ i) rk[a[i][j]] = i-1;             for (int i = 1;i <= n;++ i) {b[j][i] = b[j][i-1];         B[j][i].set (Rk[i]);     }} std::bitset<maxn>ans;         for (int i = 1;i <= n;++ i) {ans.set (); for (int j = 1;j <= 5;++ j) ans &= B[j][a[i][j]-1];         Print (Ans.count ());     PC (' \ n '); } return 0;}

hihocoder#1513: Little Hi's trouble bitset

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.