| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1294665 | theiulius | 세계 지도 (IOI25_worldmap) | C++17 | 0 ms | 0 KiB |
vector<vector<int>> create_map(int N, int M, vector<int> A, vector<int> B) {
int K = 2*N; // safe for DFS Euler tour
vector<vector<int>> ans(K, vector<int>(K));
vector<vector<int>> adj(N+1);
vector<int> tour;
for (int i = 0; i < M; i++){
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
function<void(int,int)> dfs = [&](int x, int p){
tour.push_back(x);
for (int h : adj[x]){
if (h == p) continue;
dfs(h, x);
tour.push_back(x);
}
};
dfs(1, 0);
int L = tour.size();
for (int i = 0; i < K; i++){
for (int j = 0; j < K; j++){
ans[i][j] = tour[j % L];
}
}
return ans;
}
