#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;
vector<int>v(1e7 + 6 , -1);
int meow = 0;
int cnt = 0;
int xx , yy;
int xc = 0 , yc = 0;
void solve(int l , int r , int num)
{
if(cnt == a + b)
{
return;
}
int indx = (l+r)/2;
if(meow == a)
{
int g = a+b - cnt;
int g2;
int g3;
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;
return;
}
if(num < arr[meow])
{
v[indx] = num;
return;
cnt++;
}
if(num == arr[meow])
{
v[indx] = arr[meow];
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;
for(int i=0;i<a;i++)
{
cin>>arr[i];
}
solve(0 , 1e7+5 , 30);
for(int i=0;i<1e7+6;i++)
{
if(v[i] != -1)
cout<<v[i]<<" ";
}
for(int i=0;i<xc;i++)
{
cout<<xx<<" ";
}
for(int i=0;i<yc;i++)
{
cout<<yy<<" ";
}
return 0;
}
Compilation message
zalmoxis.cpp: In function 'void solve(long long int, long long int, long long int)':
zalmoxis.cpp:35:18: warning: 'g3' may be used uninitialized in this function [-Wmaybe-uninitialized]
35 | xx = num - g3;
| ~~~~^~~~
zalmoxis.cpp:37:17: warning: 'g2' may be used uninitialized in this function [-Wmaybe-uninitialized]
37 | yc = (g - g2)*2;
| ~~~^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
129 ms |
87148 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
131 ms |
87280 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
127 ms |
87248 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
137 ms |
87224 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
138 ms |
87244 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
122 ms |
87048 KB |
Unexpected end of file - int32 expected |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
141 ms |
87116 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
129 ms |
87144 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
154 ms |
87292 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
141 ms |
87300 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
130 ms |
87284 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
133 ms |
87172 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
129 ms |
87288 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
143 ms |
87292 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
131 ms |
86300 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
122 ms |
83404 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
122 ms |
84568 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
114 ms |
82588 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
104 ms |
82808 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
103 ms |
82604 KB |
not a zalsequence |