| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1294662 | theiulius | 세계 지도 (IOI25_worldmap) | C++17 | 0 ms | 0 KiB |
// #include "worldmap.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
vector<int> v[102];
const int K = 102;
int j = 0;
vector<std::vector<int>> ans(K, vector<int> (K, 1));
void dfs(int x, int last){
ans[0][j] = x;
for (auto h : v[x]){
if (last != h){
j++;
dfs(h, x);
}
}
ans[0][j] = x;
if (j >= K){
j--;
return;
}
j++;
}
std::vector<std::vector<int>> create_map(int N, int M, std::vector<int> a, std::vector<int> b) {
for (int k = 0; k < M; k++){
v[a[k]].pb(b[k]);
v[b[k]].pb(a[k]);
}
dfs(1, 0);
for (int k = 1; k < K; k++){
for (int j = 0; j < K; j++){
ans[k][j] = ans[0][j];
}
}
return ans;
}
main(){
auto v = create_map(4, 3, {1, 1, 3}, {2, 3, 4});
cout << v[0].size() << endl;
for (auto h : v){
for (auto g : h){
cout << g << " ";
}
cout << endl;
}
}
