Language: C++

#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,x[N],d[20],id,dep;
struct array{
	int L[N],R[N],l[N],r[N],cnt;
	void init(int dep);
}a[20];
void array::init(int dep){
	int dis=d[dep];
	cnt++;L[1]=R[1]=x[1];
	for (int i=2;i<=n;i++){
		if (x[i]<=R[cnt]+dis) R[cnt]=x[i];else
		cnt++,L[cnt]=R[cnt]=x[i];
	}
	int m=a[dep+1].cnt,*ll=a[dep+1].L,*rr=a[dep+1].R;
	l[0]=r[0]=1;
	for (int i=1;i<=cnt;i++){
		for (l[i]=l[i-1];l[i]<m&&rr[l[i]]<L[i];l[i]++);
		for (r[i]=r[i-1];r[i]<m&&ll[r[i]+1]<=R[i];r[i]++);
	}
}
int q[20][N],size[20];
inline void push(int h,int v){
	for (int i=a[h].l[v];i<=a[h].r[v];i++) q[h+1][++size[h+1]]=i;
}
bool check(int h){
	if (!size[h]) return 1;
	if (size[h]>dep-h+1) return 0;
	for (int i=1;i<=size[h];i++){
		size[h+1]=0;
		for (int j=1;j<=size[h];j++)
		if (i!=j) push(h,q[h][j]);
		if (check(h+1)) return 1;
	}
	return 0;
}
bool ans[N],ok[N];
int main()
{
	scanf("%d%d",&n,&d[0]);
	while (d[dep]) d[dep+1]=d[dep]>>1,dep++;
	a[dep].cnt=n;
	for (int i=1;i<=n;i++) scanf("%d",&x[i]),a[dep].L[i]=a[dep].R[i]=x[i];
	for (int i=dep-1;i>=0;i--) a[i].init(i);
	for (int i=1;i<=a[0].cnt;i++){
		size[1]=0;
		for (int j=1;j<=a[0].cnt;j++)
		if (i!=j) push(0,j);
		ok[i]=check(1);
	}
	for (int i=1,p=1;i<=n;i++){
		while (x[i]>a[0].R[p]) p++;
		puts(ok[p]?"Possible":"Impossible");
	}
	return 0;
}

Compiler output:
a.cc:9:6: error: reference to 'array' is ambiguous
    9 | void array::init(int dep){
      |      ^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:99:12: note: candidates are: 'template<class _Tp, long unsigned int _Nm> struct std::array'
   99 |     struct array;
      |            ^~~~~
a.cc:5:8: note:                 'struct array'
    5 | struct array{
      |        ^~~~~
a.cc: In function 'void init(int)':
a.cc:11:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
   11 |         cnt++;L[1]=R[1]=x[1];
      |         ^~~
      |         int
a.cc:11:15: error: 'L' was not declared in this scope
   11 |         cnt++;L[1]=R[1]=x[1];
      |               ^
a.cc:11:20: error: 'R' was not declared in this scope
   11 |         cnt++;L[1]=R[1]=x[1];
      |                    ^
a.cc:17:9: error: 'l' was not declared in this scope; did you mean 'll'?
   17 |         l[0]=r[0]=1;
      |         ^
      |         ll
a.cc:17:14: error: 'r' was not declared in this scope; did you mean 'rr'?
   17 |         l[0]=r[0]=1;
      |              ^
      |              rr
a.cc: In function 'void push(int, int)':
a.cc:25:57: error: reference to 'size' is ambiguous
   25 |         for (int i=a[h].l[v];i<=a[h].r[v];i++) q[h+1][++size[h+1]]=i;
      |                                                         ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:23:14: note:                 'int size [20]'
   23 | int q[20][N],size[20];
      |              ^~~~
a.cc: In function 'bool check(int)':
a.cc:28:14: error: reference to 'size' is ambiguous
   28 |         if (!size[h]) return 1;
      |              ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:23:14: note:                 'int size [20]'
   23 | int q[20][N],size[20];
      |              ^~~~
a.cc:29:13: error: reference to 'size' is ambiguous
   29 |         if (size[h]>dep-h+1) return 0;
      |             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:23:14: note:                 'int size [20]'
   23 | int q[20][N],size[20];
      |              ^~~~
a.cc:30:25: error: reference to 'size' is ambiguous
   30 |         for (int i=1;i<=size[h];i++){
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:23:14: note:                 'int size [20]'
   23 | int q[20][N],size[20];
      |              ^~~~
a.cc:31:17: error: reference to 'size' is ambiguous
   31 |                 size[h+1]=0;
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:23:14: note:                 'int size [20]'
   23 | int q[20][N],size[20];
      |              ^~~~
a.cc:32:33: error: reference to 'size' is ambiguous
   32 |                 for (int j=1;j<=size[h];j++)
      |                                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:23:14: note:                 'int size [20]'
   23 | int q[20][N],size[20];
      |              ^~~~
a.cc: In function 'int main()':
a.cc:47:17: error: reference to 'size' is ambiguous
   47 |                 size[1]=0;
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:23:14: note:                 'int size [20]'
   23 | int q[20][N],size[20];
      |              ^~~~