T2
包含
https://ac.nowcoder.com/acm/contest/7607/B
T2
正解不清楚,因此打了记忆化搜索
由于对于任意整数a,b必有c = (a & b) ≤ min(a , b),因此对于每一个a[i]搜索自己再记录桶,时间复杂度O(N)(最大也就1e6)
code:
#include<iostream> #include<cstdio> #include<bitset> using namespace std; const int N = 2000010 , K = 24; int n , m; int a[N] , s[N]; inline int read() { int res = 0 ; char c = getchar(); while(c < '0' || c > '9') c = getchar(); while(c >= '0' && c <= '9') { res = res * 10 + c - '0'; c = getchar(); } return res; } void dfs(int x) { if(s[x]) return; for(int i = 0 ; (1 << i) <= x ; i++) if(x & (1 << i)) dfs(x ^ (1 << i)); s[x] = 1; } int main() { n = read() ; m = read(); for(int i = 1 ; i <= n ; i++) { a[i] = read(); dfs(a[i]); } for(int i = 1 , X ; i <= m ; i++) { X = read(); if(s[X]) printf("yes\n"); else printf("no\n"); } return 0; }