今日得分:34+5+4
(我每一天都以为今天的题是最毒瘤的,我每一天都感觉今天的题比前一天的毒瘤)(但貌似分数有所提升?)
T1
题目大意:
L<=18,Q<=5e5
题解:考虑分块维护,修改时维护后b位所有情况的值,询问时遍历前L-b位所有情况的值,取b=8,加上一些特判即可做到O(Q*2^8)的复杂度。需要卡常。
AC代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;
inline int re_ad()
{
int x=0,f=1;char ch=getchar();
while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')x=x*10+(ch^48),ch=getchar();
return x*f;
}
inline int re_ad01()
{
int x=0;char ch=getchar();
while(ch>'1'||ch<'0'){ch=getchar();}
while(ch>='0'&&ch<='1')x=(x<<1)+(ch^48),ch=getchar();
return x;
}
inline bool read(){char ch=getchar();while(ch!='Q'&&ch!='I')ch=getchar();return ch=='I';}
int L,q,rt,ygs[1000000];
struct xw{bool op;int x;unsigned int nu;}Q[500010];
const int h8=255;
unsigned int nu1[1<<10|1][(1<<16)+10],nu2[15][2][h8+10],nu3[h8+10];
inline void gx(int pla)
{
register int x=0,y=0,i;
char ch=getchar();while(ch!='0'&&ch!='1'&&ch!='*')ch=getchar();
for(i=1;i<=L;++i)
{
x<<=1;y<<=1;
if(ch=='*')x^=1;if(ch=='1')y^=1;
ch=getchar();
}
Q[pla].x=x;Q[pla].nu=y;
}
inline void change(register int x,register unsigned int y)
{
register int i;
for(i=0;i<=h8;++i)
{
nu1[x>>8][(i<<8)|(x&(i^h8))]+=y;
}
for(i=0;i<10;i++)
nu2[i][((x>>8)>>i)&1][x&h8]+=y;
nu3[x&255]+=y;
}
inline int ask(register int x,register int y)
{
register int i,j,z=x>>8,tmp;
register unsigned int ans=0;
if(ygs[x>>8]<=8)
{
for(i=z;i;i=(i-1)&z)ans+=nu1[(y>>8)|i][((x&h8)<<8)|(y&h8)];ans+=nu1[(y>>8)][((x&h8)<<8)|(y&h8)];
}
else if(ygs[x>>8]==9)
{
for(i=0;i<10;++i){if(!((x>>8)&(1<<i))){j=i;tmp=(y>>(i+8))&1;;break;}}
z=(x&h8);
for(i=z;i;i=z&(i-1))ans+=nu2[j][tmp][(y&h8)|i];ans+=nu2[j][tmp][(y&h8)];
}
else
{
z=(x&255);
for(i=z;i;i=z&(i-1))ans+=nu3[(y&h8)|i];ans+=nu3[(y&h8)];
}
return ans;
}
int main()
{
freopen("amino.in","r",stdin);
freopen("amino.out","w",stdout);
register int i,j;
register bool op;
L=re_ad();q=re_ad();
j=0;
for(i=1;i<=q;++i)
{
op=Q[i].op=read();
if(op)
{
Q[i].x=re_ad01();Q[i].nu=re_ad();
}
else
{
gx(i);j=1;
}
}
if(!j)return 0;
for(i=1;i<=524288;++i)ygs[i]=ygs[i>>1]+(i&1);
for(i=1;i<=q;++i)
{
if(Q[i].op)change(Q[i].x,Q[i].nu);
else printf("%u\n",ask(Q[i].x,Q[i].nu));
}
return 0;
}
T2
题目大意:(毒瘤提答)给你如下代码:
数据就不放了,有想要的可以私信我(不会吧不会吧,不会真有人想要这题的数据吧)
题解:
T3
题目大意:
题解: