#include "Joi.h"
#include <bits/stdc++.h>
using namespace std;
static int Ps[100000] , Pi[100000];
static vector<int> ad[100000];
static int lJOI[100000];
int findjoi(int x){
return Pi[x] == x ? x : Pi[x] = findjoi(Pi[x]);
}
void joinjoi(int x , int y){
x = findjoi(x) , y = findjoi(y);
if(Ps[x] > Ps[y]) swap(x,y);
Pi[x] = y , Ps[y] += Ps[x];
}
void dfsJOI(int x , int y){
if(findjoi(x) != findjoi(y) && (Ps[findjoi(x)] +Ps[findjoi(y)]) <= 60){
joinjoi(x , y);
}
lJOI[x] = Ps[findjoi(x)] - 1;
for(auto p : ad[x]){
if(p == y) continue;
dfsJOI(p , x);
}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
for(int i = 0 ; i < N ; i ++){
Ps[i] = 1 , Pi[i] = i;
}
for(int i = 0 ; i < M ; i ++){
if(findjoi(A[i]) != findjoi(B[i])){
joinjoi(A[i] , B[i]);
ad[A[i]].push_back(B[i]);
ad[B[i]].push_back(A[i]);
}
}
for(int i = 0 ; i < N ; i ++){
Ps[i] = 1 , Pi[i] = i;
}
dfsJOI(0 , 0);
long long P = 0;
for(int i = 0 ; i < N ; i ++){
int U = (1LL<<(lJOI[i]));
U &= X;
if(U > 0) U = 1;
else U = 0;
P += (1LL<<lJOI[i])*U;
MessageBoard(i , U);
}
}
#include "Ioi.h"
#include <bits/stdc++.h>
using namespace std;
static int pai[100000] , peso[100000] , lioi[100000] ;
static vector<int> adj[100000];
static long long ans = 0;
static bool vis[100000] , c[100000];
int fd(int x ){
return pai[x] == x ? x : pai[x] = fd(pai[x]);
}
void join(int x , int y){
x = fd(x ) ,y = fd(y);
if(peso[x] > peso[y]) swap(x,y);
pai[x] = y , peso[y] += peso[x];
}
void dfs(int x , int y){
if(fd(x) != fd(y) && (peso[fd(x)] + peso[fd(y)]) <= 60){
join(x,y);
}
lioi[x] = peso[fd(x)] - 1;
for(auto p : adj[x]){
if(y == p) continue;
dfs(p , x);
}
}
void solve(int x , int y){
if(x != y){
if(c[x]) ans |= (1LL<<lioi[x]);
}
vis[x] = true;
for(auto p : adj[x]){
if(!vis[p] && fd(p) == fd(x)){
c[p] = Move(p);
solve(p , x);
}
}
if(x != y) Move(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 ++){
peso[i] = 1 , pai[i] = i;
}
for(int i = 0 ; i < M ; i ++){
if(fd(A[i]) != fd(B[i])){
join(A[i] , B[i]);
adj[A[i]].push_back(B[i]);
adj[B[i]].push_back(A[i]);
}
}
for(int i = 0 ; i < N ; i ++){
peso[i] = 1 , pai[i] = i;
}
dfs(0 , 0);
if(V) ans |= (1LL<<lioi[P]);
solve(P,P);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
5472 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
8224 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
8312 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
8312 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
34 ms |
8312 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |