This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif
#define int long long
#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)
int inf=1000000000000000007;
int mod=1000000007;
int mod1=998244353;
const int N=107;
int n;
vector<int>G[N];
vector<vector<int>>ans;
void dfs(int v,int o)
{
for(auto u:G[v])
{
if(u==o) continue;
vector<int>V(n);
FOR(i,0,n-1) V[i]=i;
V[u]=v;
ans.pb(V);
dfs(u,v);
}
if(o!=-1)
{
vector<int>V(n);
FOR(i,0,n-1) V[i]=i;
V[o]=v;
ans.pb(V);
}
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
FOR(i,1,n-1)
{
int a,b;
cin>>a>>b;
G[a].pb(b);
G[b].pb(a);
}
FOR(i,0,n-1) dfs(i,-1);
cout<<sz(ans)<<endl;
for(auto V:ans)
{
for(auto x:V) cout<<x<<" ";
cout<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |