# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
896680 | alexander707070 | Flights (JOI22_flights) | C++17 | 0 ms | 0 KiB |
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<bits/stdc++.h>
#include "Ali.h"
#define MAXN 10007
using namespace std;
namespace{
int n,xx,yy;
vector<int> v[MAXN],w;
int dist[MAXN];
void dfs(int x,int p,int d){
dist[x]=d;
for(int i=0;i<v[x].size();i++){
if(v[x][i]==p)continue;
dfs(v[x][i],x,d+1);
}
}
}
void Init(int N, vector<int> U, vector<int> V){
n=N;
for(int i=0;i<n;i++)v[i].clear();
w.clear();
for(int i=0;i<n-1;i++){
v[U[i]].push_back(V[i]);
v[V[i]].push_back(U[i]);
}
for(int i=0;i<=n-1;i++){
SetID(i,i);
}
}
string SendA(string S){
xx=yy=0;
string res="";
for(int i=0;i<14;i++){
xx*=2;
if(S[i]=='1')xx++;
}
for(int i=0;i<6;i++){
yy*=2;
if(S[14+i]=='1')yy++;
}
for(int i=0;i<8;i++)yy*=2;
for(int i=0;i<=n-1;i++){
if(xx==i)continue;
if((i^yy)>=(1<<8))continue;
w.push_back(i);
}
dfs(xx,0,0);
for(int curr:w){
for(int i=13;i>=0;i--){
if(((1<<i)&curr)>0)res+="1";
else res+="0";
}
for(int i=13;i>=0;i--){
if(((1<<i)&dist[curr])>0)res+="1";
else res+="0";
}
}
return res;
}