QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#217748#1773. Breaking BarsPhantomThresholdCompile Error//C++141.7kb2023-10-17 11:50:312023-10-17 11:50:32

Judging History

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

  • [2023-10-17 11:50:32]
  • 评测
  • [2023-10-17 11:50:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	vector<vector<int>> id(7,vector<int>(7));
	vector<int> x(33),y(33);
	int idx=0;
	for(int i=6;i>=1;i--)
		for(int j=i;j>=1;j--)
		{
			id[i][j]=id[j][i]=++idx;
			x[idx]=i;y[idx]=j;
		}
	int n,t;
	cin>>n>>t;
	vector<int> cnt(33);
	int tot=0;
	for(int i=1;i<=n;i++)
	{
		int xi,yi;
		char ch;
		cin>>xi>>ch>>yi;
		cnt[id[xi][yi]]++;
		tot+=xi*yi;
	}
	map<tuple<vector<int>,int,int,int,int>,int> mp;
	int ans=9;
	function<int(int,int,int,int)> dfs=[&](int pos,int sum,int cuts,int waste)
	{
		if(cuts>=ans)return 0x3f3f3f3f;
		if(tot-waste<t*2)return 0x3f3f3f3f;
//		cerr<<"dfs "<<pos<<' '<<sum<<' '<<cuts<<' '<<curcut<<' '<<tot-waste<<' '<<tot<<' '<<waste<<endl;
//		for(int i=1;i<=idx;i++)cerr<<cnt[i]<<' ';cerr<<endl;
		int tmp=sum;
		for(int i=pos;i<=idx;i++)
		{
			tmp+=(cnt[i]/2)*x[i]*y[i];
		}
		if(tmp>=t)
		{
			ans=min(ans,cuts);
			return cuts;
		}
		if(pos>idx)return 0x3f3f3f3f;
		if(mp.contains({cnt,pos,sum,cuts,waste}))return mp[{cnt,pos,sum,cuts,waste}];
		int ret=dfs(pos+1,sum+(cnt[pos]/2)*x[pos]*y[pos],cuts,waste+(cnt[pos]%2)*x[pos]*y[pos]);
		if(cnt[pos])
		{
			cnt[pos]--;
			for(int i=1;i<x[pos];i++)
			{
				cnt[id[i][y[pos]]]++;
				cnt[id[x[pos]-i][y[pos]]]++;
				ret=min(ret,dfs(pos,sum,cuts+1,waste)+1);
				cnt[id[i][y[pos]]]--;
				cnt[id[x[pos]-i][y[pos]]]--;
			}
			for(int i=1;i<y[pos];i++)
			{
				cnt[id[x[pos]][i]]++;
				cnt[id[x[pos]][y[pos]-i]]++;
				ret=min(ret,dfs(pos,sum,cuts+1,waste)+1);
				cnt[id[x[pos]][i]]--;
				cnt[id[x[pos]][y[pos]-i]]--;
			}
			cnt[pos]++;
		}
		return mp[{cnt,pos,sum,cuts,waste}]=ret;
	};
	dfs(1,0,0,0);
	cout<<ans<<endl;
	return 0;
}

詳細信息

answer.code: In lambda function:
answer.code:46:23: error: ‘class std::map<std::tuple<std::vector<int, std::allocator<int> >, int, int, int, int>, int>’ has no member named ‘contains’
   46 |                 if(mp.contains({cnt,pos,sum,cuts,waste}))return mp[{cnt,pos,sum,cuts,waste}];
      |                       ^~~~~~~~