using ll=longlong; using ull=unsignedlonglong; using pii=pair<int,int>; #define begend(x) x.begin(),x.end() #define mem0(x) memset(x,0,sizeof(x)) #define YES puts("Yes") #define NO puts("No")
intread(){ int f=1,x=0;char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=x*10+c-'0';c=getchar();} return x*f; }
using ll=longlong; using ull=unsignedlonglong; using pii=pair<int,int>; #define begend(x) x.begin(),x.end() #define mem0(x) memset(x,0,sizeof(x)) #define YES puts("Yes") #define NO puts("No")
intread(){ int f=1,x=0;char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=x*10+c-'0';c=getchar();} return x*f; }
constint N = 105;
int a[N]; int cha[N]; // 相邻绝对值的前缀和
voidsolve(){ int n=read(),k=read(); for(int i=1;i<=n;i++){ a[i]=read(); }
using ll=longlong; using ull=unsignedlonglong; using pii=pair<int,int>; #define begend(x) x.begin(),x.end() #define mem0(x) memset(x,0,sizeof(x)) #define YES puts("Yes") #define NO puts("No")
intread(){ int f=1,x=0;char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=x*10+c-'0';c=getchar();} return x*f; }
constint N = 2e5+5;
char a[N][31]; int up[N][31]; // 从 (i,j) 找到第一个 0 int dp[N]; int dpmx[N]; // max(dp[1..i])
voidsolve(){ int n=read();
int val = -1; for(int i=1;i<=n;i++){ int x=read(); if(val==-1)val=x; else val&=x;
using ll=longlong; using ull=unsignedlonglong; using pii=pair<int,int>; #define begend(x) x.begin(),x.end() #define mem0(x) memset(x,0,sizeof(x)) #define YES puts("Yes") #define NO puts("No")
intread(){ int f=1,x=0;char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=x*10+c-'0';c=getchar();} return x*f; }
constint N = 2e5+5;
int a[N];
voidsolve(){ int n=read();
int val = -1; for(int i=1;i<=n;i++){ a[i]=read(); if(val==-1)val=a[i]; else val&=a[i]; }
if(val!=0){ puts("1"); return; }
int ans = 0; int now = -1; for(int i=1;i<=n;i++){ if(now==-1){ now=a[i]; }else{ now &= a[i]; }
if(now==0){ ans++; now=-1; } }
printf("%d\n",ans); }
intmain(){ int T=read(); while(T--){ solve(); } return0; }
C. Vampiric Powers, anyone?
题意
给定 n 个正整数,a1,a2,…,an。每次可以选取一段后缀的异或,加入到序列的后面。求在进行了任意次操作后,最大能在序列中得到多少。
using ll=longlong; using ull=unsignedlonglong; using pii=pair<int,int>; #define begend(x) x.begin(),x.end() #define mem0(x) memset(x,0,sizeof(x)) #define YES puts("Yes") #define NO puts("No")
intread(){ int f=1,x=0;char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=x*10+c-'0';c=getchar();} return x*f; }
constint N = 2e5+5; int a[N],b[N];
int* dellist[N<<5], delcnt; // 保存要删除的节点 int ch[N << 5][2], tot, ans; voidinsert(int x){ for (int i = 30, u = 1; i >= 0; --i) { int c = ((x >> i) & 1); // 二进制一位一位向下取 if (!ch[u][c]){ ch[u][c] = ++tot; dellist[delcnt++]=&ch[u][c]; } u = ch[u][c]; } } voidget(int x){ int res = 0; for (int i = 30, u = 1; i >= 0; --i) { int c = ((x >> i) & 1); if (ch[u][c^1]) { // 如果能向和当前位不同的子树走,就向那边走 u = ch[u][c^1]; res |= (1<<i); } else u = ch[u][c]; } ans = max(ans, res); // 更新答案 }
using ll=longlong; using ull=unsignedlonglong; using pii=pair<int,int>; #define begend(x) x.begin(),x.end() #define mem0(x) memset(x,0,sizeof(x)) #define YES puts("Yes") #define NO puts("No")
intread(){ int f=1,x=0;char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=x*10+c-'0';c=getchar();} return x*f; }
using ll=longlong; using ull=unsignedlonglong; using pii=pair<int,int>; #define begend(x) x.begin(),x.end() #define mem0(x) memset(x,0,sizeof(x)) #define YES puts("Yes") #define NO puts("No")
intread(){ int f=1,x=0;char c=getchar(); while(!isdigit(c)){if(c=='-')f=-1;c=getchar();} while(isdigit(c)){x=x*10+c-'0';c=getchar();} return x*f; }