답안 #467334

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
467334 2021-08-22T16:23:36 Z phathnv Pastiri (COI20_pastiri) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "testlib.h"
using namespace std;

const int N = 500007;

int n, k, d[N], trace[N], numNode;
vector<int> adj[N], sheep, child[2 * N];
bool vst[N];

int main() {
    cin >> n >> k;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    sheep.assign(k, 0);
    for (int &x : sheep)
        cin >> x;
    for (int i = 1; i <= n; i++)
        d[i] = 1e9;
    queue<int> qu;
    for (int x : sheep) {
        d[x] = 0;
        trace[x] = ++numNode;
        qu.push(x);
    }
    while (!qu.empty()) {
        int u = qu.front();
        qu.pop();
        for (int v : adj[u]) {
            if (d[v] > d[u] + 1) {
                d[v] = d[u] + 1;
                trace[v] = trace[u];
                qu.push(v);
            } else if (d[v] == d[u] + 1) {
                int newNode = ++numNode;
                child[newNode].push_back(trace[u]);
                child[newNode].push_back(trace[v]);
                trace[v] = newNode;
            }
        }
    }
    map<int, int> nodeToVex;
    for (int i = 1; i <= n; i++)
        nodeToVex[trace[i]] = i;
    vector<int> answer;
    for (int i = 1; i <= numNode; i++)
        for (int v : child[i])
            vst[v] = true;
    for (int i = 1; i <= numNode; i++)
        if (!vst[i])
            answer.push_back(nodeToVex[i]);
    cout << answer.size() << '\n';
    for (int x : answer)
        cout << x << ' ';
    cout << '\n';
}

Compilation message

pastiri.cpp:2:10: fatal error: testlib.h: No such file or directory
    2 | #include "testlib.h"
      |          ^~~~~~~~~~~
compilation terminated.