#include "Joi.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
namespace {
const int N = 10000;
const int k = 60;
int n, m;
vector<int> graph[N];
vector<int> msg;
int ls = 0;
void dfs(int nd){
if(msg[nd] != -1) return;
msg[nd] = ls;
ls++, ls%=k;
for(int x: graph[nd]) dfs(x);
}
}
void Joi(int _n, int _m, int A[], int B[], ll X, int T){
n = _n, m = _m;
for(int i = 0; i < m; i++){
graph[A[i]].push_back(B[i]);
graph[B[i]].push_back(A[i]);
}
vector<int> bin;
for(int i = 0; i < k; i++){
bin.push_back(X%2);
X/=2;
}
msg.assign(n, -1);
dfs(0);
for(int i = 0; i < n; i++) MessageBoard(i, bin[msg[i]]);
}
#include "Ioi.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
namespace {
const int N = 10000;
const int k = 60;
int n, m;
vector<int> graph[N];
vector<int> tree0[N];
vector<int> tree[N];
vector<int> msg;
int ls = 0;
void dfs(int nd, int ss = -1){
if(msg[nd] != -1) return;
if(ss != -1){
tree0[ss].push_back(nd);
tree0[nd].push_back(ss);
}
msg[nd] = ls;
ls++, ls%=k;
for(int x: graph[nd]) dfs(x, nd);
}
}
ll Ioi(int _n, int _m, int A[], int B[], int p, int v, int T){
n = _n, m = _m;
for(int i = 0; i < m; i++){
graph[A[i]].push_back(B[i]);
graph[B[i]].push_back(A[i]);
}
msg.assign(n, -1);
dfs(0);
vector<bool> done(k, 0);
int left = k;
vector<bool> bl(n, 0);
done[msg[p]] = 1;
left--;
bl[p] = 1;
vector<pair<int, int>> nxt;
for(int x: tree0[p]) if(!bl[x]){
bl[x] = 1;
nxt.push_back({x, p});
}
while(left){
int nd = -1, ss = -1;
for(int i = 0; i < nxt.size(); i++) if(!done[msg[nxt[i].first]]){
tie(nd, ss) = nxt[i];
nxt.erase(nxt.begin()+i);
break;
}
if(nd == -1){
assert(!nxt.empty());
tie(nd, ss) = nxt.back();
nxt.pop_back();
}
if(!done[msg[nd]]) left--;
done[msg[nd]] = 1;
bl[nd] = 1;
tree[ss].push_back(nd);
for(int x: tree0[nd]) if(!bl[x]){
bl[x] = 1;
nxt.push_back({x, nd});
}
}
vector<int> bin(k);
bin[msg[p]] = v;
function<void(int, bool)> dfs2 = [&](int nd, bool r = 0){
int sz = tree[nd].size();
//random_shuffle(tree[nd].begin(), tree[nd].end());
for(int x: tree[nd]){
sz--;
bin[msg[x]] = Move(x);
if(sz != 0 || r)
dfs2(x, 1), Move(nd);
else
dfs2(x, 0);
}
};
dfs2(p);
ll X = 0;
for(int i = 0; i < k; i++) if(bin[i]) X+=(1LL<<i);
return X;
}
Compilation message
Ioi.cpp: In function 'll Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:58:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
58 | for(int i = 0; i < nxt.size(); i++) if(!done[msg[nxt[i].first]]){
| ~~^~~~~~~~~~~~
Ioi.cpp:97:11: error: no match for call to '(std::function<void(int, bool)>) (int&)'
97 | dfs2(p);
| ^
In file included from /usr/include/c++/10/functional:59,
from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
from /usr/include/c++/10/algorithm:74,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
from Ioi.cpp:2:
/usr/include/c++/10/bits/std_function.h:617:5: note: candidate: '_Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = void; _ArgTypes = {int, bool}]'
617 | function<_Res(_ArgTypes...)>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/std_function.h:617:5: note: candidate expects 2 arguments, 1 provided