#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;
if(U > 0) U = 1;
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){
assert(fd(x) == fd(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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
47 ms |
47712 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
74 ms |
50408 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
45 ms |
50440 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
75 ms |
50492 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
81 ms |
50544 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |