Submission #56560182


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#include "E:/OI/normal/templates/debug.h"
#else
#define dbg(...) (void)0
#define msg(...) (void)0
#endif
#define ll long long
#define endl '\n'
#define PB emplace_back
#define PPB pop_back
#define MP make_pair
#define ALL(Name) Name.begin(),Name.end()
#define PII pair<int,int>
#define VI vector<int>
#define GI greater<int>
#define fi first
#define se second

const int N=60;
int n,m;
ll adj[N],eqn[N],ans[N];bool s[N],sol[N];
bool gauss()
{
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
			if(eqn[j]&&__builtin_ctzll(eqn[j])==i){swap(eqn[i],eqn[j]),swap(s[i],s[j]);break;}
		if(!((eqn[i]>>i)&1))continue;
		for(int j=0;j<n;j++)
			if(j!=i&&((eqn[j]>>i)&1))eqn[j]^=eqn[i],s[j]^=s[i];
	}
	for(int i=0;i<n;i++)dbg(eqn[i],s[i]);
	for(int i=n-1;~i;i--)
		if(!eqn[i])
		{
			if(s[i])return 0;
			sol[i]=1;
		}
		else
		{
			sol[i]=s[i];
			for(int j=i+1;j<n;j++)sol[i]^=sol[j]&&((eqn[i]>>j)&1);
		}
	return 1;
}

int main()
{
	ios::sync_with_stdio(false),cin.tie(nullptr);
//	int _;cin>>_;while(_--)

	cin>>n>>m;
	for(int i=1,u,v;i<=m;i++)cin>>u>>v,--u,--v,adj[u]|=1ll<<v,adj[v]|=1ll<<u;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)s[j]=(adj[j]>>i)&1,eqn[j]=adj[j]&~(1ull<<i);
		if(!gauss())return cout<<"No",0;
		for(int j=0;j<n;j++)ans[j]|=(ll)(sol[j])<<i;
	}
	cout<<"Yes\n";
	for(int i=0;i<n;i++)cout<<ans[i]<<" ";
	
	return 0;
}

Submission Info

Submission Time
Task G - XOR Neighbors
User yeminghan2021
Language C++ 20 (gcc 12.2)
Score 600
Code Size 1458 Byte
Status AC
Exec Time 1 ms
Memory 3648 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 4
AC × 46
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt
All 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 02_handmade_01.txt, 02_handmade_02.txt, 02_handmade_03.txt, 02_handmade_04.txt, 02_handmade_05.txt, 02_handmade_06.txt, 02_handmade_07.txt, 02_handmade_08.txt, 02_handmade_09.txt, 02_handmade_10.txt, 02_handmade_11.txt, 02_handmade_12.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 3532 KiB
00_sample_02.txt AC 1 ms 3528 KiB
00_sample_03.txt AC 1 ms 3528 KiB
00_sample_04.txt AC 1 ms 3612 KiB
01_random_01.txt AC 1 ms 3408 KiB
01_random_02.txt AC 1 ms 3460 KiB
01_random_03.txt AC 1 ms 3532 KiB
01_random_04.txt AC 1 ms 3480 KiB
01_random_05.txt AC 1 ms 3492 KiB
01_random_06.txt AC 1 ms 3532 KiB
01_random_07.txt AC 1 ms 3600 KiB
01_random_08.txt AC 1 ms 3404 KiB
01_random_09.txt AC 1 ms 3524 KiB
01_random_10.txt AC 1 ms 3428 KiB
01_random_11.txt AC 1 ms 3532 KiB
01_random_12.txt AC 1 ms 3416 KiB
01_random_13.txt AC 1 ms 3420 KiB
01_random_14.txt AC 1 ms 3532 KiB
01_random_15.txt AC 1 ms 3596 KiB
01_random_16.txt AC 1 ms 3528 KiB
01_random_17.txt AC 1 ms 3616 KiB
01_random_18.txt AC 1 ms 3468 KiB
01_random_19.txt AC 1 ms 3428 KiB
01_random_20.txt AC 1 ms 3596 KiB
01_random_21.txt AC 1 ms 3488 KiB
01_random_22.txt AC 1 ms 3628 KiB
01_random_23.txt AC 1 ms 3524 KiB
01_random_24.txt AC 1 ms 3428 KiB
01_random_25.txt AC 1 ms 3648 KiB
01_random_26.txt AC 1 ms 3524 KiB
01_random_27.txt AC 1 ms 3468 KiB
01_random_28.txt AC 1 ms 3620 KiB
01_random_29.txt AC 1 ms 3404 KiB
01_random_30.txt AC 1 ms 3480 KiB
02_handmade_01.txt AC 1 ms 3520 KiB
02_handmade_02.txt AC 1 ms 3516 KiB
02_handmade_03.txt AC 1 ms 3536 KiB
02_handmade_04.txt AC 1 ms 3432 KiB
02_handmade_05.txt AC 1 ms 3536 KiB
02_handmade_06.txt AC 1 ms 3532 KiB
02_handmade_07.txt AC 1 ms 3432 KiB
02_handmade_08.txt AC 1 ms 3624 KiB
02_handmade_09.txt AC 1 ms 3528 KiB
02_handmade_10.txt AC 1 ms 3456 KiB
02_handmade_11.txt AC 1 ms 3484 KiB
02_handmade_12.txt AC 1 ms 3476 KiB