답안 #1022325

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1022325 2024-07-13T12:04:09 Z vjudge1 Hiperkocka (COCI21_hiperkocka) C++17
110 / 110
63 ms 3684 KB
#include <bits/stdc++.h>

using namespace std;

const int M = 17;

vector<int> nei[M];
int path[M],x;

void dfs(int u,int p=-1)
{
	for (int i:nei[u])
		if (i!=p)
		{
			path[i]=path[u]^(1<<x++);
			dfs(i,u);
		}
}

int main()
{
	int n;
	cin>>n;
	for (int i=0;i<n;i++)
	{
		int u,v;
		cin>>u>>v;
		nei[u].push_back(v);
		nei[v].push_back(u);
	}
	dfs(0);
	cout<<(1<<n-1)<<'\n';
	for (int i=0;i<(1<<n);i++)
	{
		if (__builtin_popcount(i) & 1)
			continue;
		for (int u=0;u<=n;u++)
			cout<<(i^path[u])<<' ';
		cout<<'\n';
	}
	
	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:32:13: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   32 |  cout<<(1<<n-1)<<'\n';
      |            ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 436 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 62 ms 3588 KB Output is correct
10 Correct 4 ms 604 KB Output is correct
11 Correct 10 ms 860 KB Output is correct
12 Correct 35 ms 3664 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 43 ms 3480 KB Output is correct
15 Correct 17 ms 1884 KB Output is correct
16 Correct 8 ms 856 KB Output is correct
17 Correct 39 ms 3668 KB Output is correct
18 Correct 35 ms 3668 KB Output is correct
19 Correct 37 ms 3556 KB Output is correct
20 Correct 51 ms 3664 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 38 ms 3684 KB Output is correct
23 Correct 51 ms 3664 KB Output is correct
24 Correct 63 ms 3668 KB Output is correct
25 Correct 61 ms 3556 KB Output is correct
26 Correct 17 ms 1696 KB Output is correct