#ifndef safar
#include<Joi.h>
#endif
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 1e4 + 10;
const int Log = 60;
static vector<int> G[N], Gd, T[N], O;
static int mk[N], id[N];
static int fn = 0;
void dfs(int u){
if(fn == Log) return ;
id[u] = fn;
fn ++;
mk[u] = 1;
Gd.pb(u);
for(auto adj : G[u]) if(!mk[adj]) dfs(adj);
}
void DFS(int u){
O.pb(u);
mk[u] = 1;
for(auto adj : G[u]){
if(!mk[adj]) DFS(adj);
}
}
void DFS2(int u){
mk[u] = 1;
for(auto adj : G[u]){
if(!mk[adj]){
T[adj].pb(adj);
for(auto x : T[u]) T[adj].pb(x);
id[adj] = id[T[adj].back()];
T[adj].pop_back();
DFS2(adj);
}
}
}
void Joi(int n, int m, int A[], int B[], ll X, int Tc){
for(int i = 0; i < m; i++){
G[A[i]].pb(B[i]);
G[B[i]].pb(A[i]);
}
dfs(1);
for(auto x : Gd){
fill(mk, mk + N, 1);
for(auto x : Gd) mk[x] = 0;
O.clear();
DFS(x);
for(auto y : O) T[x].pb(y);
}
memset(mk, 0, sizeof mk);
for(auto x : Gd) mk[x] = 1;
for(auto x : Gd) DFS2(x);
assert(n >= 60);
assert(-1 <= Tc);
for(int i = 0; i < n; i++) MessageBoard(i, X >> id[i] & 1);
return ;
}
#ifndef safar
#include<Ioi.h>
#endif
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int N = 1e4 + 10;
const int Log = 60;
static vector<int> G[N], Gd, T[N], O;
static int mk[N], id[N];
static int fn = 0;
void dfs(int u){
if(fn == Log) return ;
id[u] = fn;
fn ++;
mk[u] = 1;
Gd.pb(u);
for(auto adj : G[u]) if(!mk[adj]) dfs(adj);
}
void DFS(int u){
O.pb(u);
mk[u] = 1;
for(auto adj : G[u]){
if(!mk[adj]) DFS(adj);
}
}
void DFS2(int u){
mk[u] = 1;
for(auto adj : G[u]){
if(!mk[adj]){
T[adj].pb(adj);
for(auto x : T[u]) T[adj].pb(x);
id[adj] = id[T[adj].back()];
T[adj].pop_back();
DFS2(adj);
}
}
}
static ll Ans = 0;
void Find(int u){
mk[u] = 1;
for(auto adj : G[u]){
if(mk[adj]) continue;
ll res = Move(adj);
if(res) Ans |= (1ll << id[adj]);
Find(adj);
Move(u);
}
}
ll Ioi(int n, int m, int A[], int B[], ll P, ll V, int Tc){
for(int i = 0; i < m; i++){
G[A[i]].pb(B[i]);
G[B[i]].pb(A[i]);
}
dfs(1);
for(auto x : Gd){
fill(mk, mk + N, 1);
for(auto x : Gd) mk[x] = 0;
O.clear();
DFS(x);
for(auto y : O) T[x].pb(y);
}
memset(mk, 0, sizeof mk);
for(auto x : Gd) mk[x] = 1;
for(auto x : Gd) DFS2(x);
if(V) Ans |= (1ll << id[P]);
assert(n >= 60);
assert(-1 <= Tc);
fill(mk, mk + N, 1);
for(auto x : T[P]) mk[x] = 0;
Find(P);
return Ans;
}
Compilation message
/tmp/ccGGXel6.o: In function `main':
grader_ioi.cpp:(.text.startup+0x36a): undefined reference to `Ioi(int, int, int*, int*, int, int, int)'
collect2: error: ld returned 1 exit status