#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=10005;
vector<int> adj[MX];
int timer=-1;
vector<int> euler;
int sz[MX], par[MX], tin[MX], tout[MX];
void dfs(int v, int p) {
tin[v]=++timer;
euler.push_back(tin[v]);
sz[v]=1;
par[v]=p;
for(auto u:adj[v]) {
if(u==p) continue;
dfs(u,v);
sz[v]+=sz[u];
}
tout[v]=timer;
}
struct DSU {
int par[MX];
int find(int v) {
return par[v]==v?v:par[v]=find(par[v]);
}
bool merge(int u, int v) {
u=find(u),v=find(v);
if(u==v) return false;
par[u]=v;
return true;
}
void prep(int N) {
for(int i=0;i<N;i++) par[i]=i;
}
} DS;
void Joi(int N, int M, int A[], int B[], long long X, int T) {
vector<pair<int,int>> e;
for(int i=0;i<M;i++) e.push_back({A[i],B[i]});
sort(e.begin(),e.end());
DS.prep();
for(auto [x,y]:e) {
if(DS.merge(x,y)) {
adj[x].push_back(y);
adj[y].push_back(x);
}
}
dfs(0,-1);
for(int i=0;i<N;i++) {
int k=i%60;
MessageBoard(euler[i],X>>k&1);
}
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MX=10005;
vector<int> adj[MX];
int timer=-1;
vector<int> euler;
int sz[MX], par[MX], tin[MX], tout[MX];
void dfs(int v, int p) {
tin[v]=++timer;
euler.push_back(tin[v]);
sz[v]=1;
par[v]=p;
for(auto u:adj[v]) {
if(u==p) continue;
dfs(u,v);
sz[v]+=sz[u];
}
tout[v]=timer;
}
ll get(int x, int y) {
return y*(1LL<<(tin[x]%60));
}
ll res=0, cnt=0;
bool vis[60];
void dfs0(int v, int p) {
if(cnt==60) return;
for(auto u:adj[v]) {
if(u==p) continue;
if(!vis[tin[u]%60]) cnt++;
vis[tin[u]%60]=1;
res|=get(u,Move(u));
dfs0(u,v);
if(cnt==60) return;
Move(v);
}
}
struct DSU {
int par[MX];
int find(int v) {
return par[v]==v?v:par[v]=find(par[v]);
}
bool merge(int u, int v) {
u=find(u),v=find(v);
if(u==v) return false;
par[u]=v;
return true;
}
void prep(int N) {
for(int i=0;i<N;i++) par[i]=i;
}
} DS;
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
// return mst
vector<pair<int,int>> e;
for(int i=0;i<M;i++) e.push_back({A[i],B[i]});
sort(e.begin(),e.end());
DS.prep();
for(auto [x,y]:e) {
if(DS.merge(x,y)) {
adj[x].push_back(y);
adj[y].push_back(x);
}
}
dfs(0,-1);
int k=V;
while(sz[P]<60) {
P=par[P];
k=Move(P);
}
res|=get(P,k);
cnt++;
vis[tin[P]%60]=1;
dfs0(P,par[P]);
return res;
}
Compilation message
Joi.cpp: In function 'void Joi(int, int, int*, int*, long long int, int)':
Joi.cpp:53:17: error: no matching function for call to 'DSU::prep()'
53 | DS.prep();
| ^
Joi.cpp:42:14: note: candidate: 'void DSU::prep(int)'
42 | void prep(int N) {
| ^~~~
Joi.cpp:42:14: note: candidate expects 1 argument, 0 provided
Ioi.cpp: In function 'long long int Ioi(int, int, int*, int*, int, int, int)':
Ioi.cpp:76:17: error: no matching function for call to 'DSU::prep()'
76 | DS.prep();
| ^
Ioi.cpp:63:14: note: candidate: 'void DSU::prep(int)'
63 | void prep(int N) {
| ^~~~
Ioi.cpp:63:14: note: candidate expects 1 argument, 0 provided