版权声明:原创,未经作者允许禁止转载 https://blog.csdn.net/Mr_wuyongcong/article/details/82958724
前言
出现了!毒瘤抠题人BPM。
WHF大佬强势串场
成绩
正题
试卷【状态压缩】
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/82958042
字串数量【前缀和】
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/82958079
排列【 随机卡常 树状数组】
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/82958663
T1 dfs ACcode
#include<cstdio>
#include<cstring>
#include<iostream>
#define MS 1024
#define N 1010
using namespace std;
int t,n,m,k,v[MS],a[N],ans,answer;
char c;
void dfs(int x,int s)
{
if(x>=m)
{
ans=0;
memset(v,0,sizeof(v));
for(int i=1;i<=n;i++)
{
v[a[i]&s]++;
ans+=i-v[a[i]&s];
}
if(ans>=k) answer++;
return;
}
dfs(x+1,s*2+1);
dfs(x+1,s*2);
}
int main()
{
scanf("%d",&t);
for(int ti=1;ti<=t;ti++)
{
answer=0;
memset(a,0,sizeof(a));
scanf("%d%d%d",&n,&m,&k);
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
{
cin>>c;
a[i]=a[i]*2+(c=='A');
}
dfs(0,0);
printf("%d\n",answer);
}
}
T3 70code
#include<cstdio>
#include<cstring>
#define BPM (int(1e9)+7)
#define lobit(x) x&-x
using namespace std;
int t,n,a[1001],f[1001][1001],ans,c[1001];
void change(int x,int a)
{
while(x<=n)
{
(c[x]+=a)%=BPM;
x+=lobit(x);
}
}
int ask(int x)
{
int sum=0;
while(x)
{
(sum+=c[x])%=BPM;
x-=lobit(x);
}
return sum;
}
int main()
{
scanf("%d",&t);
for(int ti=1;ti<=t;ti++)
{
memset(f,0,sizeof(f));
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
for(int i=1;i<=n;i++)
f[1][i]=1;
printf("%d ",n);
for(int l=2;l<=n;l++)
{
memset(c,0,sizeof(c));
ans=0;
for(int i=1;i<=n;i++)
{
f[l][i]=ask(a[i]-1);
change(a[i],f[l-1][i]);
(ans+=f[l][i])%=BPM;
}
printf("%d",ans);
if(l!=n) printf(" ");
}
printf("\n");
}
}
尾声
没了