ssl提高组国庆模拟赛【2018.10.7】

版权声明:原创,未经作者允许禁止转载 https://blog.csdn.net/Mr_wuyongcong/article/details/82958724

前言

出现了!毒瘤抠题人BPM。
WHF大佬强势串场


成绩

R a n k Rank P e r s o n Person S c o r e Score A A B B C C
1 1 2017 m y s e l f 2017myself 270 270 100 100 100 100 70 70
2 2 2015 h j w 2015hjw 160 160 30 30 100 100 30 30
3 3 2016 w h f 2016whf 130 130 0 0 100 100 30 30
4 4 2017 x j q 2017xjq 100 100 0 0 100 100 0 0
5 5 2015 g j h 2015gjh 100 100 0 0 100 100 0 0
6 6 2015 l z x 2015lzx 100 100 0 0 100 100 0 0
7 7 2015 z z y 2015zzy 100 100 0 0 100 100 0 0
8 8 2015 c j x 2015cjx 100 100 0 0 100 100 0 0
9 9 2017 x x y 2017xxy 70 70 0 0 70 70 0 0
10 10 2017 z y c 2017zyc 70 70 0 0 70 70 0 0

正题


T 1 : n s s l 1185 T1:nssl1185- 试卷【状态压缩】

博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/82958042


T 2 : n s s l 1186 T2:nssl1186- 字串数量【前缀和】

博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/82958079


T 3 : n s s l 1187 T3:nssl1187- 排列【 d p , dp, 随机卡常 , , 树状数组】

博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/82958663


s o m e   o f   c o d e some\ of\ code


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");
	}
}

尾声

没了

猜你喜欢

转载自blog.csdn.net/Mr_wuyongcong/article/details/82958724