Submission #1162566

#TimeUsernameProblemLanguageResultExecution timeMemory
1162566argoHiperkocka (COCI21_hiperkocka)C++20
110 / 110
51 ms3716 KiB
#include <bits/stdc++.h> #define all(x) x.begin(),x.end() #define inf 1e18 #define mod 1e9+7 #define ll long long #define ld long double #define pb push_back #define em emplace_back #define bll __int128_t using namespace std; template <typename H, typename T> ostream& operator<<(ostream& os, pair<H, T> m){return os <<"("<< m.first<<", "<<m.second<<")";} template <typename H> ostream& operator<<(ostream& os, vector<H> V){os<<"{";for(int i=0; i<(int)V.size(); i++){if(i)os<<" ";os<<V[i];}os<<"}";return os;} void debug(){cerr << "\n";} template<typename H, typename... T> void debug(H h, T... t){cerr << h;if(sizeof...(t)){cerr<<" ";debug(t...);}} #define deb(x...) cerr<<__LINE__ << ": " << #x << " -> ";debug(x);cerr<<endl; int losuj(int a, int b){return rand()%(b-a+1)+a;} #define rozmiar 100100 int n, a, b, pot2=1; vector<pair<int, int>> drzewo; vector<int> graf[30]; map<int, int> numeracja; bool visited[100]; void dfs(int k){ visited[k]=1; for(int i:graf[k]){ if(!visited[i]){ //cout << k << i << endl; numeracja[i]=numeracja[k]^pot2; pot2*=2; dfs(i); } } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> n; for(int i=0;i<n;i++){ cin >> a >> b; graf[a].pb(b); graf[b].pb(a); } numeracja[0]=0; dfs(0); cout << pot2/2 << endl; int t; for(int mask=0;mask<(1<<n);mask++){ t=0; for(int j=1;j<=mask;j*=2){ if(j&mask)t++; } if(t%2==0){ //cout << mask << endl; for(int i=0;i<=n;i++){ cout << (numeracja[i]^mask) << " "; } cout << endl; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...