This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Alicelib.h"
#include <bits/stdc++.h>
using namespace std;
void Alice( int N, int M, int A[], int B[] ){
int v[10];
for(int i=0;i<10;i++){
v[i]=0;
for(int j=1;j<=N;j++){
v[i]+=((j>>i)&1);
}
}
int g=N+10;
for(int i=0;i<10;i++)g+=v[i];
InitG(N+12,M+g);
int c;
for(c=0;c<M;c++)MakeG(c,A[c],B[c]);
for(int i=0;i<N;i++,c++)MakeG(c,N,i);
for(int i=N+1;i<N+10;i++,c++)MakeG(c,i,i+1);
for(int i=0;i<10;i++){
for(int j=1;j<=N;j++){
if((j>>i)&1)MakeG(c,j-1,N+1+i),c++;
}
}
MakeG(c,N,N+11);
}
#include "Boblib.h"
#include <bits/stdc++.h>
using namespace std;
void Bob( int V, int U, int C[], int D[] ){
int bt[10],deg[V],val[V],usa[V];
vector<int>ad[V],v(V);
V-=12;
for(int i=0;i<10;i++){
bt[i]=0;
for(int j=1;j<=V;j++){
bt[i]+=((j>>i)&1);
}
}
int g=V+10;
for(int i=0;i<10;i++)g+=bt[i];
InitMap(V,U-g);
for(int i=0;i<V+12;i++)deg[i]=val[i]=usa[i]=0;
for(int i=0;i<U;i++){
deg[C[i]]++;
deg[D[i]]++;
ad[C[i]].push_back(D[i]);
ad[D[i]].push_back(C[i]);
}
queue<int>q;
int a=-1,b=-1;
for(int i=0;i<V+12;i++)
if(deg[i]==1){
if(a==-1)a=i;
else b=i;
}
if(deg[ad[a][0]]==V+1)a=ad[a][0];
else b=ad[b][0],swap(a,b);
for(auto i:ad[a])v[i]=1,usa[i]=1;
for(int i=0;i<V+12;i++)if(!usa[i]&°[i]==bt[9]+1)b=i;
v[b]=1;
for(int i=9;0<=i;i--){
if(i!=9)for(auto j:ad[b])if(v[j]==0){
b=j;
v[b]=1;
break;
}
for(auto j:ad[b])val[j]+=(1<<i);
}
for(int i=0;i<U;i++){
if(usa[C[i]]&&usa[D[i]])MakeMap(val[C[i]]-1,val[D[i]]-1);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |