# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
838453 | Charizard2021 | Hiperkocka (COCI21_hiperkocka) | C++17 | 50 ms | 8716 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>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> adj[1 + n];
for(int i =0 ; i < n; i++){
int a, b;
cin >> a >> b;
adj[a].push_back(b);
adj[b].push_back(a);
}
vector<int> topo(1 + n, -1);
vector<int> parent(1 + n);
int timer = 0;
queue<int> q;
q.push(0);
topo[0] = timer;
timer++;
while(!q.empty()){
int u = q.front();
q.pop();
for(int v : adj[u]){
if(topo[v] == -1){
topo[v] = timer;
timer++;
parent[topo[v]] = topo[u];
q.push(v);
}
}
}
vector<vector<int> > ans;
vector<int> cur;
cur.push_back(0);
cur.push_back(1);
ans.push_back(cur);
for(int i = 1; i < n; i++){
int curVal = ans.size();
for(int j = 0; j < curVal; j++){
ans.push_back(ans[j]);
for(int k = 0; k < ans[(int)ans.size() - 1].size(); k++){
ans[(int)ans.size() - 1][k] ^= 1 ^ (1 << i);
}
}
for(int j = 0; j < ans.size(); j++){
ans[j].push_back(ans[j][parent[i + 1]] ^ (1 << i));
}
}
cout << ans.size() << "\n";
for(int i = 0; i < ans.size(); i++){
for(int j = 0; j <= n; j++){
cout << ans[i][topo[j]] << " ";
}
cout << "\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |