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

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

前言

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


成绩

RankRank PersonPerson ScoreScore AA BB CC
11 2017myself2017myself 270270 100100 100100 7070
22 2015hjw2015hjw 160160 3030 100100 3030
33 2016whf2016whf 130130 00 100100 3030
44 2017xjq2017xjq 100100 00 100100 00
55 2015gjh2015gjh 100100 00 100100 00
66 2015lzx2015lzx 100100 00 100100 00
77 2015zzy2015zzy 100100 00 100100 00
88 2015cjx2015cjx 100100 00 100100 00
99 2017xxy2017xxy 7070 00 7070 00
1010 2017zyc2017zyc 7070 00 7070 00

正题


T1:nssl1185T1:nssl1185-试卷【状态压缩】

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


T2:nssl1186T2:nssl1186-字串数量【前缀和】

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


T3:nssl1187T3:nssl1187-排列【dp,dp,随机卡常,,树状数组】

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


some of codesome\ 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");
	}
}

尾声

没了

阅读更多
换一批

没有更多推荐了,返回首页