Submission #1162561

#TimeUsernameProblemLanguageResultExecution timeMemory
1162561argoHiperkocka (COCI21_hiperkocka)C++20
0 / 110
0 ms320 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;
map<int, int> numeracja;

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;
        drzewo.pb({min(a, b), max(a, b)});
    }
    for(int i=0;i<=n;i++){
        numeracja[i]=-1;
    }
    numeracja[0]=0;
    sort(all(drzewo));
    for(auto i:drzewo){
        if(numeracja[i.second]==-1){
            numeracja[i.second]=numeracja[i.first]^pot2;
            pot2*=2;
        }
    }
    cout << pot2/2 << endl;
    bool t=1;
    for(int mask=0;mask<(1<<n);mask++){
        t=!t;
        if(t){
            for(int i=0;i<=n;i++){
                cout << (numeracja[i]^mask) << " ";
            }
            cout << endl;
        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...