#pragma GCC optimize("unroll-loops,Ofast,O3")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define spc << " " <<
#define endl "\n"
#define all(x) x.begin(), x.end()
#define ll long long
#define int long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define st first
#define nd second
#define inf 1000000009
#define MOD 1000000007
#define lim 65540
using namespace std;
vi edges[lim];
vi res(lim);
void place(int num, int node, int par){
res[node]=num;
for(auto i:edges[node]){
if(i==par) continue;
place((num^(1<<(i-1))), i, node);
}
}
void solve(){
int n; cin >> n;
for(int i=1; i<=n; i++){
int a,b; cin >> a >> b;
edges[a].pb(b);
edges[b].pb(a);
}
cout << (1<<(n-1)) << endl;
for(int i=0; i<(1<<n); i++){
if(__builtin_popcount(i)%2) continue;
place(i, 0, 0);
for(int j=0; j<=n; j++) cout << res[j] << " ";
cout << endl;
}
}
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
ll t=1;
//cin >> t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
2 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
2 ms |
2512 KB |
Output is correct |
9 |
Correct |
34 ms |
5716 KB |
Output is correct |
10 |
Correct |
7 ms |
2904 KB |
Output is correct |
11 |
Correct |
9 ms |
3164 KB |
Output is correct |
12 |
Correct |
33 ms |
5724 KB |
Output is correct |
13 |
Correct |
2 ms |
2392 KB |
Output is correct |
14 |
Correct |
34 ms |
5688 KB |
Output is correct |
15 |
Correct |
17 ms |
3932 KB |
Output is correct |
16 |
Correct |
9 ms |
3160 KB |
Output is correct |
17 |
Correct |
34 ms |
5716 KB |
Output is correct |
18 |
Correct |
34 ms |
5724 KB |
Output is correct |
19 |
Correct |
34 ms |
5692 KB |
Output is correct |
20 |
Correct |
34 ms |
5724 KB |
Output is correct |
21 |
Correct |
2 ms |
2396 KB |
Output is correct |
22 |
Correct |
35 ms |
5712 KB |
Output is correct |
23 |
Correct |
41 ms |
5716 KB |
Output is correct |
24 |
Correct |
34 ms |
5712 KB |
Output is correct |
25 |
Correct |
37 ms |
5716 KB |
Output is correct |
26 |
Correct |
17 ms |
3928 KB |
Output is correct |