41992023-03-16 08:32:581478Utazási irodacpp17Forditási hiba
#include <bits/stdc++.h>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i, e) for (ll i = 0; i < e; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin()                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

vector<priority_queue<int, vector<int>, greater<int>>> adjacent(100000);
int n;
bool solution = 0;
long long k;
int db = 0;
vector<bool> seen(100000);

void dfs(int node, deque<int> kju)
{
    if (kju.size() < k && !solution)
    {
        seen[node] = true;
        db++;
        kju.push_back(node);
        while (!adjacent[node].empty() && !solution)
        {
            if (!seen[adjacent[node].top()])
                dfs(adjacent[node].top(), kju);
            adjacent[node].pop();
        }

        //kju.pop_back();
    }
    if (db == k && !solution)
    {
        //cout << "*" << '\n';
        while (!kju.empty())
        {
            cout << kju.front() << " ";
            kju.pop_front();
        }
        solution = 1;
    }

}

int main()
{
    fast_cin();
    //ifstream cin("in.txt");
    cin >> n;
    cin >> k;
    for (int i = 1; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        adjacent[x].push(y);
        adjacent[y].push(x);
    }
    for(int i=1; i<=n; i++){
        sort(adjacent[i].begin(), adjacent[i].end());
    }

    //cout << n << " " << k << '\n';
    int node;
    if (k % n == 0)
    {
        node = k / n;
        k = n;
    }
    else
    {
        node = k / n + 1;
        k = k % n;
    }
    //cout<<k<<'\n';
    deque<int> kju;
    dfs(node, kju);



    return 0;
}
Forditási hiba
exit status 1
main.cpp: In function 'int main()':
main.cpp:88:26: error: '__gnu_cxx::__alloc_traits<std::allocator<std::priority_queue<int, std::vector<int>, std::greater<int> > >, std::priority_queue<int, std::vector<int>, std::greater<int> > >::value_type' {aka 'class std::priority_queue<int, std::vector<int>, std::greater<int> >'} has no member named 'begin'
   88 |         sort(adjacent[i].begin(), adjacent[i].end());
      |                          ^~~~~
main.cpp:88:47: error: '__gnu_cxx::__alloc_traits<std::allocator<std::priority_queue<int, std::vector<int>, std::greater<int> > >, std::priority_queue<int, std::vector<int>, std::greater<int> > >::value_type' {aka 'class std::priority_queue<int, std::vector<int>, std::greater<int> >'} has no member named 'end'
   88 |         sort(adjacent[i].begin(), adjacent[i].end());
      |                                               ^~~
Exited with error status 1