5189 | 2023-04-20 18:15:40 | SleepyOverlord | Utazási iroda | cpp17 | Forditási hiba |
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <stack>
#include <list>
#include <numeric>
#include <algorithm>
#include <random>
#include <chrono>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <climits>
#include <cctype>
#include <cmath>
#include <ctime>
#include <cassert>
using namespace std;
#define ULL unsigned long long
#define LL long long
#define PII pair <int, int>
#define VB vector <bool>
#define VI vector <int>
#define VLL vector <LL>
#define VD vector <double>
#define VS vector <string>
#define VPII vector <pair <int, int> >
#define VVI vector < VI >
#define VVB vector < VB >
#define SI set < int >
#define USI unordered_set <int>
#define MII map <int, int>
#define UMII unordered_map <int, int>
#define MS multiset
#define US unordered_set
#define UM unordered_map
#define UMS unordered_multiset
#define UMM unordered_multimap
#define FORN(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define SZ size()
#define BG begin()
#define EN end()
#define CL clear()
#define X first
#define Y second
#define RS resize
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(), x.end()
#define INS insert
#define ER erase
#define CNT count
int n;
LL k;
VVI g;
VI sz;
void df(int node, int p)
{
sz[node] = 1;
for (int next : g[node])
if (next != p)
{
df(next, node);
sz[node] += sz[next];
}
}
int main()
{
cin >> n >> k;
g.RS(n + 1);
sz.RS(n + 1);
FOR(i, 1, n - 1)
{
int x, y;
cin >> x >> y;
g[x].PB(y);
g[y].PB(x);
}
FOR(i, 1, n) sort(ALL(g[i]));
df(1, -1);
int node = (k - 1) / n + 1, parent = -1;
LL sum = LL(node - 1) * n + 1;
VI sol;
sol.PB(node);
while (sum < k)
{
for (int next : g[node])
{
if (next == parent) continue;
int nr = (sz[next] < sz[node]) ? sz[next] : n - sz[node];
if (sum + nr < k) sum += nr;
else
{
parent = node;
node = next;
++sum;
break;
}
}
sol.PB(node);
}
for (int x : sol) cout << x << " ";
return 0;
}
exit status 1
main.cpp: In function 'int main()':
main.cpp:32:12: error: expected primary-expression before 'long'
32 | #define LL long long
| ^~~~
main.cpp:101:18: note: in expansion of macro 'LL'
101 | LL sum = LL(node - 1) * n + 1;
| ^~
Exited with error status 1