제출 #750269

#제출 시각아이디문제언어결과실행 시간메모리
750269ammar124Zalmoxis (BOI18_zalmoxis)C++14
35 / 100
401 ms72948 KiB
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define int long long
using namespace std;
ll power(ll a, ll b) { ll ans = 1; while (b) { if (b % 2) ans *= a; a *= a; b /= 2; } return ans; }
int const maxin = 1e6+6;
ll const mod = 1e9+7;
int arr[maxin];
int a,b;
int meow = 0;
int cnt = 0;
int xx , yy;
int xc = 0 , yc = 0;
map<ll , ll>mp;
void pls_work(int num)
{
    int g = a+b - cnt;
    int g2 = 0,g3 = 0;
    for(int i=0;i<100;i++)
    {
        if(power(2 , i) > g)
            break;
        g2 = power(2,i);
        g3 = i;
    }
    xx = num - g3;
    yy = num - g3 - 1;
    yc = (g - g2)*2;
    xc = g - yc;
    cnt = a+b;
}
void solve(int l , int r , int num)
{
    if(cnt == a + b)
    {
        return;
    }
    int indx = (l+r)/2;
    if(meow == a)
    {
        pls_work(num);
        return;
    }
    if(num < arr[meow])
    {
        mp[indx] = num;
        return;
        cnt++;
    }
    if(num == arr[meow])
    {
        mp[indx] = num;
        meow++;
        cnt++;
        return;
    }
    solve(l , indx , num-1);
    solve(indx , r , num-1);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>a>>b;
    int meow69 = a+b;
    for(int i=0;i<a;i++)
    {
        cin>>arr[i];
    }
    solve(0 , 1e17+5 , 30);
    for(auto it : mp)
    {
        cout<<it.second<<" ";
        meow69--;
        if(meow69 == 0)
            return 0;
    }
    for(int i=0;i<xc;i++)
    {
        cout<<xx<<" ";
        meow69--;
        if(meow69 == 0)
            return 0;
    }
    for(int i=0;i<yc;i++)
    {
        cout<<yy<<" ";
        meow69--;
        if(meow69 == 0)
            return 0;
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...