#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#include "Joi.h"
int par[10001];
int find(int no){
if(par[no]==no){
return no;
}
no=find(par[no]);
return no;
}
vector<int> adj2[10001];
long long xx;
int co=0;
void dfs3(int no,int par2=-1){
if((xx)&((llo)((llo)1<<co))){
MessageBoard(no,1);
}
else{
MessageBoard(no,0);
}
co=(co+1)%60;
for(auto j:adj2[no]){
if(j==par2){
continue;
}
dfs3(j,no);
}
}
void Joi(int N, int M, int A[], int B[], long long X, int T) {
xx=X;
for(int i=0;i<N;i++){
par[i]=i;
}
for(int i=0;i<M;i++){
int x=find(A[i]);
int y=find(B[i]);
if(x!=y){
par[x]=y;
adj2[A[i]].pb(B[i]);
adj2[B[i]].pb(A[i]);
}
}
dfs3(0);
}
#include <bits/stdc++.h>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#include "Ioi.h"
vector<int> adj[10001];
int par3[10001];
int find5(int no){
if(par3[no]==no){
return no;
}
no=find5(par3[no]);
return no;
}
int ss[10001];
int par4[10001];
int cur[10001];
int co2=0;
void dfs2(int no,int par2=-1){
cur[no]=co2;
co2=(co2+1)%60;
par4[no]=par2;
ss[no]=1;
for(auto j:adj[no]){
if(j==par2){
continue;
}
dfs2(j,no);
ss[no]+=ss[j];
}
}
long long ans=0;
int cop=0;
multiset<int> kk;
int kol=0;
void dfs(int no,int par2=-1){
cop+=1;
kk.insert(cur[no]);
for(auto j:adj[no]){
if(j==par4[no]){
continue;
}
if(cop<60){
int x=Move(j);
kol=j;
ans+=((llo)(1<<cur[j]))*x;
dfs(j);
int y=Move(no);
kol=no;
}
}
}
long long Ioi(int N, int M, int A[], int B[], int P, int V, int T) {
for(int i=0;i<N;i++){
par3[i]=i;
}
for(int i=0;i<M;i++){
int x=find5(A[i]);
int y=find5(B[i]);
if(x!=y){
par3[x]=y;
adj[A[i]].pb(B[i]);
adj[B[i]].pb(A[i]);
}
}
dfs2(0);
int cot=P;
int val=V;
while(ss[cot]<60){
cot=par4[cot];
val=Move(cot);
}
ans+=((llo)(1<<cur[cot]))*val;
kol=cot;
dfs(cot);
if(kol!=cot){
while(true){
continue;
}
}
//cout<<kk.size()<<endl;
return ans;
}
/*
g++ -std=c++14 -O2 -o aa grader.cpp Joi.cpp Ioi.cpp
*/
Compilation message
Ioi.cpp: In function 'void dfs(int, int)':
Ioi.cpp:51:8: warning: unused variable 'y' [-Wunused-variable]
int y=Move(no);
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1412 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
178 ms |
3436 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
1288 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
159 ms |
3468 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
192 ms |
3440 KB |
Wrong Answer [7] |
2 |
Halted |
0 ms |
0 KB |
- |