#include <bits/stdc++.h>
#include "Joi.h"
using namespace std;
const int maxn = 1e5 + 100;
vector<int> e[maxn];
int n;
int parent[maxn];
int h[maxn];
int get(int x){
return x == parent[x] ? x : parent[x] = get(parent[x]);
}
bool uni(int x, int y){
x = get(x);
y = get(y);
if (x == y)
return 0;
parent[x] = y;
return 1;
}
int poi[maxn];
void predfs(int v, int par){
for (auto i : e[v])
if (i != par)
poi[i] = v, h[i] = h[v] + 1, predfs(i);
}
pair<int, int> mas[maxn];
vector<int> q[maxn];
int pos[maxn];
bool good[maxn];
void make(int v, int par, int st){
q[st].push_back(v);
for (auto i : e[v])
if (i != par && good[i])
make(i, v, st);
}
void Joi(int N, int M, int A[], int B[], long long X, int T){
n = N;
for (int i = 0; i < n; i++)
parent[i] = i;
for (int i = 0; i < M; i++)
if (uni(A[i], B[i])){
e[A[i]].push_back(B[i]);
e[B[i]].push_back(A[i]);
}
predfs(0, -1);
for (int i = 0; i < n; i++)
mas[i] = make_pair(h[i], i);
sort(mas, mas + n);
for (int i = 0; i < 60; i++)
good[mas[i].second] = 1, pos[mas[i].second] = i;
for (int i = 0; i < 60; i++)
make(mas[i].second, -1, mas[i].second);
for (int i = 60; i < n; i++){
int v = poi[i];
q[i] = q[v];
pos[i] = pos[q[i].back()];
q[i].pop_back();
q[i].insert(q[i].begin(), i);
}
for (int i = 0; i < n; i++)
MessageBoard(i, (1ll << pos[i]) & X > 0);
}
#include <bits/stdc++.h>
#include "Ioi.h"
using namespace std;
const int maxn = 1e5 + 100;
vector<int> e[maxn];
int n;
int parent[maxn];
int h[maxn];
int get(int x){
return x == parent[x] ? x : parent[x] = get(parent[x]);
}
bool uni(int x, int y){
x = get(x);
y = get(y);
if (x == y)
return 0;
parent[x] = y;
return 1;
}
int poi[maxn];
void predfs(int v, int par){
for (auto i : e[v])
if (i != par)
poi[i] = v, h[i] = h[v] + 1, predfs(i);
}
pair<int, int> mas[maxn];
vector<int> q[maxn];
int pos[maxn];
bool good[maxn];
void make(int v, int par, int st){
q[st].push_back(v);
for (auto i : e[v])
if (i != par && good[i])
make(i, v, st);
}
ll ans;
void go(int v, int par, vector<int> &g, int id, int val){
ans += (1ll << pos[v]) * val;
if (id < 60){
for (auto i : e[v])
if (i == g[id])
go(i, v, g, id + 1, Move(i)), is = 1;
}
if (par != -1)
Move(par);
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T){
n = N;
for (int i = 0; i < n; i++)
parent[i] = i;
for (int i = 0; i < M; i++)
if (uni(A[i], B[i])){
e[A[i]].push_back(B[i]);
e[B[i]].push_back(A[i]);
}
predfs(0, -1);
for (int i = 0; i < n; i++)
mas[i] = make_pair(h[i], i);
sort(mas, mas + n);
for (int i = 0; i < 60; i++)
good[mas[i].second] = 1, pos[mas[i].second] = i;
for (int i = 0; i < 60; i++)
make(mas[i].second, -1, mas[i].second);
for (int i = 60; i < n; i++){
int v = poi[i];
q[i] = q[v];
pos[i] = pos[q[i].back()];
q[i].pop_back();
q[i].insert(q[i].begin(), i);
}
go(P, -1, q[P], 1, V);
}
Compilation message
Joi.cpp: In function 'void predfs(int, int)':
Joi.cpp:33:45: error: too few arguments to function 'void predfs(int, int)'
poi[i] = v, h[i] = h[v] + 1, predfs(i);
^
Joi.cpp:30:6: note: declared here
void predfs(int v, int par){
^
Joi.cpp: In function 'void Joi(int, int, int*, int*, long long int, int)':
Joi.cpp:76:43: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
MessageBoard(i, (1ll << pos[i]) & X > 0);
^
Ioi.cpp: In function 'void predfs(int, int)':
Ioi.cpp:33:45: error: too few arguments to function 'void predfs(int, int)'
poi[i] = v, h[i] = h[v] + 1, predfs(i);
^
Ioi.cpp:30:6: note: declared here
void predfs(int v, int par){
^
Ioi.cpp: At global scope:
Ioi.cpp:51:1: error: 'll' does not name a type
ll ans;
^
Ioi.cpp: In function 'void go(int, int, std::vector<int>&, int, int)':
Ioi.cpp:54:4: error: 'ans' was not declared in this scope
ans += (1ll << pos[v]) * val;
^
Ioi.cpp:58:46: error: 'is' was not declared in this scope
go(i, v, g, id + 1, Move(i)), is = 1;
^
Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:89:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^