답안 #744632

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744632 2023-05-18T21:00:30 Z MohamedAhmed04 Hiperkocka (COCI21_hiperkocka) C++14
110 / 110
47 ms 3600 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 17 ;

int arr[MAX] ;
int n ;

vector< vector<int> >adj(MAX) ;
int val[MAX] ;
int cnt = 0 ;

void dfs(int node , int par)
{
	for(auto &child : adj[node])
	{
		if(child == par)
			continue ;
		val[child] = val[node] ^ (1 << cnt) ;
		++cnt ;
		dfs(child , node) ;
	}
}

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	for(int i = 0 ; i < n ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		adj[x].push_back(y) ;
		adj[y].push_back(x) ;
	}
	dfs(0 , -1) ;
	cout<<(1 << (n-1))<<"\n" ;
	for(int mask = 0 ; mask < (1 << n) ; ++mask)
	{
		if((__builtin_popcount(mask) & 1))
			continue ;
		for(int i = 0 ; i <= n ; ++i)
			cout<<(val[i] ^ mask)<<" " ;
		cout<<"\n" ;
	}
	return 0 ;
}		
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 320 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 45 ms 3500 KB Output is correct
10 Correct 6 ms 580 KB Output is correct
11 Correct 10 ms 980 KB Output is correct
12 Correct 42 ms 3600 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 42 ms 3512 KB Output is correct
15 Correct 25 ms 1788 KB Output is correct
16 Correct 10 ms 980 KB Output is correct
17 Correct 43 ms 3496 KB Output is correct
18 Correct 46 ms 3560 KB Output is correct
19 Correct 43 ms 3492 KB Output is correct
20 Correct 47 ms 3488 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 44 ms 3532 KB Output is correct
23 Correct 43 ms 3520 KB Output is correct
24 Correct 44 ms 3532 KB Output is correct
25 Correct 45 ms 3500 KB Output is correct
26 Correct 21 ms 1748 KB Output is correct