제출 #1249601

#제출 시각아이디문제언어결과실행 시간메모리
1249601Ghulam_JunaidWorld Map (IOI25_worldmap)C++20
0 / 100
2 ms584 KiB
#include <bits/stdc++.h>
#include "worldmap.h"
using namespace std;

const int N = 41, K = 240;
int n, m, h[N];
vector<int> g[N];

vector<vector<int>> ans;
void dfs(int v, int p = -1){
    vector<int> vec;
    for (int u : g[v]){
        vec.push_back(v);
        vec.push_back(u);
    }
    ans.push_back(vec);
    ans.push_back({v});

    for (int u : g[v]){
        if (!h[u]){
            h[u] = h[v] + 1;
            vec.push_back({u});
            dfs(u, v);
            vec.push_back({v});
            continue;
        }
    }
}

vector<vector<int>> create_map(int nn, int mm, vector<int> a, vector<int> b) {
    ans.clear();
    n = nn, m = mm;
    for (int i = 0; i < m; i ++){
        g[a[i]].push_back(b[i]);
        g[b[i]].push_back(a[i]);
    }
    h[1] = 1;
    dfs(1);

    int mx = ans.size();
    for (int i = 0; i < ans.size(); i ++)
        mx = max(mx, (int)ans[i].size());
    while (ans.size() < mx)
        ans.push_back({1});
    for (int i = 0; i < ans.size(); i ++)
        while (ans[i].size() < mx)
            ans[i].push_back(ans[i][0]);

    memset(h, 0, sizeof h);
    for (int i = 0; i <= n; i ++)
        g[i].clear();
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...