bitset水题求调
  • 板块CF878D Magic Breeding
  • 楼主Lyz09G410/G407
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/3/11 10:11
  • 上次更新2023/10/23 21:57:52
查看原帖
bitset水题求调
284013
Lyz09G410/G407楼主2023/3/11 10:11
#include<iostream>
#include<bitset>
#include<algorithm>
using namespace std;
#define N 200010
#define K 14
int n,k,q,tot,opt,x,y,cnt[N],f[N][K],a[K][N];
bitset<11451> b[N];
int main()
{
	cin>>n>>k>>q;
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=n;j++)
		 scanf("%d",&a[i][j]);
	}
	tot=k;
	for(int i=1;i<=n;i++)
	{
		cnt[i]=0;
		for(int j=1;j<=k;j++)
		 f[i][++cnt[i]]=a[j][i];
		sort(f[i]+1,f[i]+cnt[i]+1);
		cnt[i]=unique(f[i]+1,f[i]+cnt[i]+1)-f[i]-1;
		for(int j=1;j<=k;j++)
		 a[j][i]=lower_bound(f[i]+1,f[i]+cnt[i]+1,a[j][i])-f[i];
	}
	for(int i=1;i<=k;i++)
	{
		for(int j=1;j<=n;j++)
		for(int k=1;k<=13;k++)
		 b[i][(j-1)*13+(k-1)]=(a[i][j]>=k);
	}
//	for(int i=1;i<=tot;i++)
//	{
//		for(int j=0;j<n*12;j++)
//		 cout<<b[i][j]<<" ";
//		cout<<endl;
//	}
	for(int i=1;i<=q;i++)
	{
		scanf("%d%d%d",&opt,&x,&y);
		if(opt==1)
		{
			tot++;
			b[tot]=b[x]|b[y];
		}
		if(opt==2)
		{
			tot++;
			b[tot]=b[x]&b[y];
		}
		if(opt==3)
		{
			int ans=0; 
			for(int k=1;k<=13;k++)
			if(b[x][(y-1)*13+(k-1)])
			 ans=k;
			printf("%d\n",f[y][ans]);
		}
//		cout<<tot<<"--->>>"<<endl;
//		for(int j=0;j<n*12;j++)
//		 cout<<b[tot][j]<<" ";
//		cout<<endl;
	}
}

小数据都过了,对拍也拍不出来...

2023/3/11 10:11
加载中...