QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#203545#6961. XOR SubsequenceMXYH875WA 186ms10176kbC++142.7kb2023-10-06 18:00:242023-10-06 18:00:24

Judging History

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

  • [2023-10-06 18:00:24]
  • 评测
  • 测评结果:WA
  • 用时:186ms
  • 内存:10176kb
  • [2023-10-06 18:00:24]
  • 提交

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];

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;
		for(int i=1;i<(1<<n);i++) scanf("%d",&a[i]);
		sort(a+1,a+(1<<n));
		for(int i=0;i<n;i++)
		{
			for(int j=1;j<(1<<n);j++)
			{
				if(a[j]&(1<<i)) 
				{
					ans[num++]=(1<<i);
					break;
				}
			}
		}
		for(int i=1;i<(1<<n);i++)
		{
			if(a[i]==0)
			{
				ans[num++]=0;
				break;
			}
		}
		int i=0;
		while(num<n)
		{
			ans[num++]=ans[i];
		}
//				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
  
 */


/*
 *
 *  ┏┓   ┏┓+ +
 * ┏┛┻━━━┛┻┓ + +
 * ┃       ┃
 * ┃   ━   ┃ ++ + + +
 *  ████━████+
 *  ◥██◤ ◥██◤ +
 * ┃   ┻   ┃
 * ┃       ┃ + +
 * ┗━┓   ┏━┛
 *   ┃   ┃ + + + +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: 186ms
memory: 10176kb

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:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

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