#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;
}
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;
MessageBoard(i , U);
}
}
#include "Ioi.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;
}
for(auto p : adj[i]){
if(p == j) continue;
dfs(p, i);
}
}
bool vis[1000000];
bool c[1000000];
long long ans = 0;
void solve(int x , int y){
long long U = (1LL<<label[x]);
U *= c[x];
ans |= U;
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++){
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);
c[P] = V;
solve(P, P);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
53 ms |
47716 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
68 ms |
49760 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
52 ms |
49760 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
54 ms |
49760 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
56 ms |
49760 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |