Submission #1059485

#TimeUsernameProblemLanguageResultExecution timeMemory
1059485ThanhsHiperkocka (COCI21_hiperkocka)C++14
110 / 110
29 ms3724 KiB
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define double long double
 
#define endl '\n'
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define setmin(x, y) x = min((x), (y))
#define setmax(x, y) x = max((x), (y))
#define sqr(x) ((x) * (x))
#define fi first
#define se second
#define all(x) x.begin(), x.end()
 
// mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
// int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}

const int NM = 16 + 5;
const int LM = 1e4 + 5;
const int mod = 1e9 + 7;

vector<pair<int, int>> g[NM];
vector<int> v;
int n;

void dfs(int u, int p = -1, int m = 0)
{
    v[u] = m;
    for (pair<int, int> v : g[u])
        if (v.fi != p)
            dfs(v.fi, u, m | (1 << v.se));
}

void solve()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int u, v;
        cin >> u >> v;
        g[u].push_back({v, i});
        g[v].push_back({u, i});
    }
    v.resize(n + 1);
    dfs(0);
    cout << (1 << n - 1) << endl;
    for (int i = 0; i < (1 << n); i++)
        if (__builtin_popcount(i) & 1 ^ 1)
        {
            for (int t : v)
                cout << (t ^ i) << ' ';
            cout << endl;
        }
}

signed main()
{
    fastIO
    if (fopen("in.txt", "r")) 
    {
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
    int tc = 1;
    // cin >> tc;
    while (tc--)
        solve();
}

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:48:21: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   48 |     cout << (1 << n - 1) << endl;
      |                   ~~^~~
Main.cpp:50:35: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   50 |         if (__builtin_popcount(i) & 1 ^ 1)
      |             ~~~~~~~~~~~~~~~~~~~~~~^~~
Main.cpp: In function 'int main()':
Main.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen("in.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:64:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   64 |         freopen("out.txt", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...