#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
int peso[1000000] , label[1000000] , pai[1000000];
vector<int> adj[1000000];
int fd(int x){
return pai[x] == x ? x : pai[x] = fd(pai[x]);
}
void join(int u , int v){
u = fd(u) , v = fd(v);
if(peso[u] < peso[v]) swap(u,v);
pai[v] = u , peso[u] += peso[v];
}
void dfs(int i , int j){
if(fd(i) != fd(j) && peso[fd(j)] < 60){
join(i,j);
}
label[i] = peso[fd(i)] - 1;2
for(auto p : adj[i]){
if(p == j) continue;
dfs(p, i);
}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
for(int i = 0 ; i < N ; i++){
pai[i] = i , peso[i] = 1;
}
for(int i = 0 ; i < M ; i++){
if(fd(A[i]) != fd(B[i])){
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
join(A[i] , B[i]);
}
}
for(int i = 0 ; i < N ; i ++){
peso[i] = 1 , pai[i] = i;
}
dfs(0,0);
for(int i = 0 ; i < N ; i ++){
long long Z = X;
long long T = (1LL<<label[i]);
assert(label[i] < 60);
long long U = Z & T;
if(U > 0) U = 1;
MessageBoard(i , U);
}
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
int peso1[1000000] , label1[1000000] , pai1[1000000];
vector<int> adj1[1000000];
set< pair<int,int> > s;
int fd1(int x){
return pai1[x] == x ? x : pai1[x] = fd1(pai1[x]);
}
void join1(int u , int v){
u = fd1(u) , v = fd1(v);
if(peso1[u] < peso1[v]) swap(u,v);
pai1[v] = u , peso1[u] += peso1[v];
}
void dfs1(int i , int j){
if(fd1(i) != fd1(j) && peso1[fd1(j)] < 60){
join1(i,j);
}
label1[i] = peso1[fd1(i)] - 1;
for(auto p : adj1[i]){
if(p == j) continue;
dfs1(p, i);
}
}
bool vis[1000000];
bool c[1000000];
long long ans = 0;
int curr;
void solve(int x , int y){
assert(curr == x);
assert(fd1(x) == fd1(y));
long long U = (1LL<<label1[x]);
U *= c[x];
ans |= U;
vis[x] = true;
for(auto p : adj1[x]){
if(!vis[p] && fd1(p) == fd1(x)){
assert(curr == x);
c[p] = move(p);
curr = p;
solve(p, x);
}
}
if(x == y) return;
else move(y) , curr = y;
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
for(int i = 0 ; i < N ; i++){
pai1[i] = i , peso1[i] = 1;
}
for(int i = 0 ; i < M ; i++){
s.insert(pair<int,int> (A[i] , B[i]));
s.insert(pair<int,int>(B[i] , A[i]));
if(fd1(A[i]) != fd1(B[i])){
adj1[A[i]].push_back(B[i]);
adj1[B[i]].push_back(A[i]);
join1(A[i] , B[i]);
}
}
for(int i = 0 ; i < N ; i ++){
peso1[i] = 1 , pai1[i] = i;
}
dfs1(0,0);
c[P] = V;
curr = P;
solve(P, P);
return ans;
}
Compilation message
Joi.cpp: In function 'void dfs(int, int)':
Joi.cpp:24:2: error: expected ';' before 'for'
for(auto p : adj[i]){
^~~
Joi.cpp:27:2: warning: statement has no effect [-Wunused-value]
}
^