| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 529636 | topovik | Hiperkocka (COCI21_hiperkocka) | C++14 | 19 ms | 12620 KiB | 
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>
#define pb push_back
#define f first
#define s second
using namespace std;
typedef long long ll;
typedef long double ld;
const ll oo = 1e18 + 7;
const ll N = 5e5 + 10;
const ll M = 1000;
const ll M1 = 1e6;
int n;
bool mrk[N];
vector <int> a[N];
vector <int> ans;
vector <vector <int> > ans1;
bool check(int x)
{
    for (int i = 0; i < n; i++)
        if (x == (1 << i)) return 1;
    return 0;
}
void Rec(int x, int y, int prv)
{
//    cout << x << " " << y << " " << prv << endl;
    ans[y] = x;
    mrk[x] = 1;
    for (auto i : a[y])
        if (i != prv)
    {
        for (int j = 1; ; j <<= 1)
            if (!mrk[j ^ x])
        {
            mrk[j ^ x] = 1;
            Rec(j ^ x, i, y);
            break;
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    srand(time(NULL));
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        a[x].pb(y);
        a[y].pb(x);
    }
    ans.resize(n + 1);
    Rec(0, 0, 0);
//    cout << "Yes\n";
    ans1.pb(ans);
    for (int x = 0; x < (1 << n); x++)
    {
        bool g = 1;
        for (int i = 0; i <= n; i++) g &= !mrk[ans[i] ^ x];
        if (g)
        {
            ans1.pb(ans);
            for (int i = 0; i <= n; i++) ans1.back()[i] ^= x;
            for (int i = 0; i <= n; i++) mrk[ans1.back()[i]] = 1;
        }
    }
    cout << ans1.size() << endl;
    for (auto i : ans1)
    {
        for (auto j : i) cout << j << " ";
        cout << endl;
    }
}
/*
5 3
2 1 1 2 2 3
2 3 3 4 4 5
4 1 1 2 2 3 3 4 4 5
*/
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
