QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#203582#6961. XOR SubsequenceMXYH875WA 304ms10336kbC++142.9kb2023-10-06 18:23:382023-10-06 18:23:38

Judging History

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

  • [2023-10-06 18:23:38]
  • 评测
  • 测评结果:WA
  • 用时:304ms
  • 内存:10336kb
  • [2023-10-06 18:23:38]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<string>
#include<cstring>
#include<bitset> 
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<map>
#include<iomanip>
#include<algorithm>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define x first
#define y second
#define PI  acos(-1)
//CLOCKS_PER_SEC clock()函数每秒执行次数
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef unsigned long long ULL;
typedef pair<double,double> PDD;

const int N=1e6+10,mod=1e9+7,INF=0x3f3f3f3f;
int t;
int n;
int a[N];
int ans[30],num=0;
int s[N];
bool st[33];

int f(int u)
{
	int res=0;
	for(int i=0;i<n;i++)
	{
		if(u&(1<<i)) res^=ans[i];
	}
	return res;
}

bool check()
{
	
	int len=1;
	for(int i=1;i<(1<<n);i++)
	{
		s[len++]=f(i);
	}
		for(int i=1;i<len;i++) printf("%d ",s[i]);
		puts("");
		for(int i=1;i<len;i++) printf("%d ",a[i]);
		puts("");
	sort(s+1,s+len);
	for(int i=1;i<(1<<n);i++)
	{
		if(s[i]!=a[i]) return false;
	}
	return true;
}

int main()
{                                                                                                                          
	cin>>t;
	while(t--)
	{
		scanf("%d",&n);
		num=0;
		memset(st,false,sizeof st);
		for(int i=1;i<(1<<n);i++) scanf("%d",&a[i]);
		if(n==1)
		{
			printf("%d\n",a[1]);
			continue;
		}
		sort(a+1,a+(1<<n));
		for(int i=1;i<(1<<n);i++)
		{
			int tmp=a[i];
			for(int j=0;j<20;j++)
			{
				if(a[i]&(1<<j)&&!st[j])
				{
					ans[num++]=1<<j;
					st[j]=true;
				}
			}
		}
		for(int i=1;i<(1<<n);i++)
		{
			if(a[i]==0)
			{
				ans[num++]=0;
				break;
			}
		}
		int i=0;
		sort(ans,ans+num);
		while(num<n)
		{
			ans[num++]=ans[0];
		}
				printf("ans ");
				for(int i=0;i<n;i++) printf("%d ",ans[i]);
				puts("");
		if(check())
		{
			sort(ans,ans+n);
			for(int i=0;i<n;i++) printf("%d ",ans[i]);
			puts("");
		}
		else 
		{
			puts("-1");
		}
	}
	return 0;
}

/*
3
3
1 2 3 4 5 6 7
3
1 0 1 0 1 0 1
3
1 2 3 4 5 6 6
  
 */


/*
 *
 *  ┏┓   ┏┓+ +
 * ┏┛┻━━━┛┻┓ + +
 * ┃       ┃
 * ┃   ━   ┃ ++ + + +
 *  ████━████+
 *  ◥██◤ ◥██◤ +
 * ┃   ┻   ┃
 * ┃       ┃ + +
 * ┗━┓   ┏━┛
 *   ┃   ┃ + + + +Code is far away from  
 *   ┃   ┃ + bug with the animal protecting
 *   ┃    ┗━━━┓ 神兽保佑,代码无bug 
 *   ┃        ┣┓
 *    ┃        ┏┛
 *     ┗┓┓┏━┳┓┏┛ + + + +
 *    ┃┫┫ ┃┫┫
 *    ┗┻┛ ┗┻┛+ + + +
 */

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 304ms
memory: 10336kb

input:

4115
1
220426753
2
75752216 139004411 214624995
3
425320853 659634699 1040767902 61426054 620262285 1033998872 451979283
4
289669156 16842978 272957638 16779852 289737354 21236708 4456872 268501358 285213068 272894568 4524806 21299530 68270 285281058 268438464
5
288507119 704365180 764545802 9869220...

output:

220426753
ans 1 2 
1 2 3 
75752216 139004411 214624995 
-1
ans 1 2 4 
1 2 3 4 5 6 7 
61426054 425320853 451979283 620262285 659634699 1033998872 1040767902 
-1
ans 2 4 8 32 
2 4 6 8 10 12 14 32 34 36 38 40 42 44 46 
68270 4456872 4524806 16779852 16842978 21236708 21299530 268438464 268501358 272894...

result:

wrong answer 2nd lines differ - expected: '75752216 139004411', found: 'ans 1 2 '