#include "Joi.h"
#include <vector>
#include <algorithm>
using ll = long long;
const int NMAX = 10'000;
std::vector<int> g[NMAX + 1];
int value[NMAX + 1];
bool vis[NMAX + 1];
std::vector<int> order;
void dfs(int u) {
order.push_back(u);
vis[u] = true;
for (const auto &v : g[u]) {
if (!vis[v]) {
dfs(v);
}
}
}
void Joi(int n, int m, int a[], int b[], long long X, int T) {
for (int i = 0; i < m; i++) {
g[a[i]].push_back(b[i]);
g[b[i]].push_back(a[i]);
}
for (int i = 0; i < n; i++) {
std::sort(g[i].begin(), g[i].end());
}
dfs(0);
for (int i = 0; i < 60; i++) {
value[order[i]] = ((ll) X >> i) & 1LL;
}
for (int i = 0; i < n; i++) {
MessageBoard(i, value[i]);
}
}
#include "Ioi.h"
#include <vector>
#include <algorithm>
using ll = long long;
const int NMAX = 10'000;
std::vector<int> g[NMAX + 1];
int value[NMAX + 1];
bool vis[NMAX + 1];
int parent[NMAX + 1];
std::vector<int> order;
void dfs(int u) {
order.push_back(u);
vis[u] = true;
for (const auto &v : g[u]) {
if (!vis[v]) {
parent[v] = u;
dfs(v);
}
}
}
bool hasSon(int u, int v) { // v e fiu al lui u?
for (const auto &w : g[u]) {
if (v == w) {
return true;
}
}
return false;
}
long long Ioi(int n, int m, int a[], int b[], int P, int V, int T) {
for (int i = 0; i < m; i++) {
g[a[i]].push_back(b[i]);
g[b[i]].push_back(a[i]);
}
for (int i = 0; i < n; i++) {
std::sort(g[i].begin(), g[i].end());
}
dfs(0);
int u = P;
ll answer = 0;
if (u == 0) {
Move(g[0]);
answer = Move(0);
}
while (u != 0) {
u = parent[u];
answer = Move(u);
}
for (int i = 1; i < 60; i++) {
while (!hasSon(u, order[i])) {
u = parent[u];
}
if (Move(order[i])) {
answer |= (1LL << i);
}
u = order[i];
}
return answer;
}
Compilation message
Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:46:13: error: cannot convert 'std::vector<int>' to 'int'
46 | Move(g[0]);
| ~~~^
| |
| std::vector<int>
In file included from Ioi.cpp:1:
Ioi.h:4:14: note: initializing argument 1 of 'int Move(int)'
4 | int Move(int dest);
| ~~~~^~~~