| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 1004048 | De3b0o | 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 "Ali.h"
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*x)
#define rc (2*x+1)
using namespace std;
vector<ll> adj[10009];
ll n;
ll ds[10009][10009];
void dfs(ll x , ll p , ll d , ll o)
{
    ds[o][x]=d;
    for(auto it : adj[x])
    {
        if(it==p)
            continue;
        dfs(it,x,d+1,o);
    }
}
void Init(int N, std::vector<int> U, std::vector<int> V)
{
    n=N;
    vector<ll> v;
    for(int i = 0 ; n>i ; i++)
        v.pb(i);
    random_shuffle(v.begin(),v.end());
    for(int i = 0 ; n>i ; i++)
        SetID(i,v[i]);
    for(int i = 0 ; N-1>i ; i++)
    {
        adj[v[U[i]]].pb(v[V[i]]);
        adj[v[V[i]]].pb(v[U[i]]);
    }
}
std::string SendA(std::string S)
{
    ll a3 = 0;
    ll b = 1;
    for(int i = 0 ; 4>i ; i++)
    {
        if(S[i]=='1')
            a3+=b;
        b*=2;
    }
    ll a1 = 0 , a2 = 0;
    b=1;
    for(int i = 4 ; 4+a3>i ; i++)
    {
        if(S[i]=='1')
            a1+=b;
        b*=2;
    }
    b=1;
    for(int i = 4+a3 ; 20>i ; i++)
    {
        if(S[i]=='1')
            a2+=b;
        b*=2;
    }
    ll w = (1<<12);
    set<ll> sum;
    ll po = 20-a3-4;
    for(ll i = 0 ; w>i ; i++)
    {
        ll su = a2+(i<<(po));
        if(2*n-3>=su)
            sum.in(su);
    }
    string s = "";
    for(ll i = 0 ; n>i ; i++)
    {
        ll x = i , y = i+a1;
        if(y>=n)
            break;
        ll su = x+y;
        if(sum.find(su)==sum.end())
            continue;
        dfs(x,-1,0,x);
        b = 1;
        for(int i = 0 ; 15>i ; i++)
        {
            if((x+y)&b)
                s+='1';
            else
                s+='0';
            b*=2;
        }
        b=1;
        for(int i = 0 ; 14>i ; i++)
        {
            if(ds[x][y]&b)
                s+='1';
            else
                s+='0';
            b*=2;
        }
    }
    return s;
}
