# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
838453 | Charizard2021 | Hiperkocka (COCI21_hiperkocka) | C++17 | 50 ms | 8716 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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";
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |