QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#641624#8790. First BillionwallcrackCompile Error//C++201.4kb2024-10-14 21:43:552024-10-14 21:43:55

Judging History

你现在查看的是最新测评结果

  • [2024-10-14 21:43:55]
  • 评测
  • [2024-10-14 21:43:55]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int B=36,N=100+10;
typedef pair<int,bitset<N>> Pib;
int n,b;
Pib a[N],c[B+10];
mt19937 rnd(time(0));
void operator +=(Pib &x,Pib &y)
{
	x.first+=y.first;
	x.second|=y.second;
}
bool cmp(Pib &x,Pib &y)
{
	return x.first<y.first;
}
Pib solve()
{
	vector<Pib> p1,p2;
	for(int i=1;i<=b;i++)
		if(i<=b/2)p1.push_back(c[i]);
		else p2.push_back(c[i]);
	vector<Pib> archive;
	for(int i=0;i<(1<<p1.size());i++)
	{
		Pib cur;
		for(int j=0;j<p1.size();j++)
			if(i&(1<<j))cur+=p1[j];
		archive.push_back(cur);
	}
	sort(archive.begin(),archive.end(),cmp);
	for(int i=0;i<(1<<p2.size());i++)
	{
		Pib cur;
		for(int j=0;j<p2.size();j++)
			if(i&(1<<j))cur+=p2[j];
		int l=0,r=archive.size()-1,mid;
		while(l<r)
		{
			mid=(l+r+1)>>1;
			if(cur.first+archive[mid].first<=1e9)l=mid;
			else r=mid-1;
		}
		auto res=cur;
		res+=archive[l];
		if(res.first==1e9)return res;
	}
	Pib any;
	return any;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].first;
		a[i].second[i]=1;
	}
	Pib ans;
	do
	{
		b=min(n,B);
		for(int i=1;i<=b;i++)
		{
			int p=1,minv=1e9;
			for(int j=1;j<=b;j++)
				if(c[j].first<minv)
					p=j,minv=c[j].first;
			c[p]+=a[i];
		}
		ans=solve();
		if(ans.first==1e9)
	}while(1);
	cout<<ans.second.count()<<" ";
	for(int i=1;i<=n;i++)
		if(ans.second[i])cout<<i<<" ";
	return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:73:9: error: expected primary-expression before ‘}’ token
   73 |         }while(1);
      |         ^