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