QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#607526#7514. Clique ChallengeXuJunMingWA 0ms1468kbC++141002b2024-10-03 15:10:122024-10-03 15:10:13

Judging History

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

  • [2024-10-03 15:10:13]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1468kb
  • [2024-10-03 15:10:12]
  • 提交

answer

#include<stdio.h>
#include<algorithm>
using namespace std;
#define int long long
const int aim=1e9;
int n,vis[1003],ss[1003],com=0,ans[1003];
struct Node{
	int p,id;
}a[1003];
void dfs(int x,int s)
{
	if(s+ss[x]<aim||s>aim)return;
	if(s+ss[x]==aim)
	{
		int k=0;
		for(int i=1;i<x;i++)if(vis[i])ans[++k]=a[i].id;
		for(int i=x;i<=n;i++)ans[++k]=a[i].id;
		printf("%lld",k);com=1;
		sort(ans+1,ans+1+k);
		for(int i=1;i<=k;i++)printf(" %lld",ans[i]);
		return;
	}
	if(s==aim)
	{
		int k=0;
		for(int i=1;i<x;i++)if(vis[i])ans[++k]=a[i].id;printf("%lld",k);com=1;
		sort(ans+1,ans+1+k);
		for(int i=1;i<=k;i++)printf(" %lld",ans[i]);
		return;
	}if(com)return;
	dfs(x+1,s);
	if(com)return;
	vis[x]=1;
	dfs(x+1,s+a[x].p);
	vis[x]=0;
	
}
bool cmp1(Node A,Node B)
{
	return A.p>B.p;
}
main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i].p),a[i].id=i;
	sort(a+1,a+1+n,cmp1);
	for(int i=n;i>=1;i--)ss[i]=ss[i+1]+a[i].p;
	dfs(1,0);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1468kb

input:

3 2
1 2
2 3

output:


result:

wrong answer 1st lines differ - expected: '5', found: ''