Language: C++

#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }


const int MAX = 210000;
int N, L;
int a[MAX];
bool dp[MAX];
int prev[MAX];

int main() {
    while (cin >> N >> L) {
        memset(dp, 0, sizeof(dp));
        memset(prev, -1, sizeof(prev));
        dp[0] = true;
        for (int i = 0; i < N; ++i) cin >> a[i];
        for (int i = 0; i <= N; ++i) {
            //cout << i << ": " << dp[i] << endl;
            if (!dp[i]) continue;
            if (i+1 < N && a[i] + a[i+1] >= L) {
                dp[i+2] = true;
                prev[i+1] = i;
            }
            if (i+2 < N && a[i] + a[i+1] >= L) {
                dp[i+3] = true;
                prev[i+3] = i+2;
                prev[i+2] = i;
            }
            if (i+2 < N && a[i+1] + a[i+2] >= L) {
                dp[i+3] = true;
                prev[i+3] = i+1;
                prev[i+1] = i;
            }
        }
        if (dp[N]) {
            puts("Possible");
            int st = N;
            bool used[MAX];
            for (int i = 0; i < N; ++i) used[i] = false;
            while (st != 0) {
                st = prev[st];
                if (st > 0) {
                    cout << st << endl;
                    used[st] = true;
                }
            }
            for (int i = 1; i < N; ++i) {
                if (!used[i]) cout << i << endl;
            }
        }
        else {
            puts("Impossible");
        }
    }
}


















Compiler output:
a.cc: In function 'int main()':
a.cc:24:16: error: reference to 'prev' is ambiguous
   24 |         memset(prev, -1, sizeof(prev));
      |                ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 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_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:5: note:                 'int prev [210000]'
   19 | int prev[MAX];
      |     ^~~~
a.cc:24:33: error: reference to 'prev' is ambiguous
   24 |         memset(prev, -1, sizeof(prev));
      |                                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:5: note:                 'int prev [210000]'
   19 | int prev[MAX];
      |     ^~~~
a.cc:32:17: error: reference to 'prev' is ambiguous
   32 |                 prev[i+1] = i;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:5: note:                 'int prev [210000]'
   19 | int prev[MAX];
      |     ^~~~
a.cc:36:17: error: reference to 'prev' is ambiguous
   36 |                 prev[i+3] = i+2;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:5: note:                 'int prev [210000]'
   19 | int prev[MAX];
      |     ^~~~
a.cc:37:17: error: reference to 'prev' is ambiguous
   37 |                 prev[i+2] = i;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:5: note:                 'int prev [210000]'
   19 | int prev[MAX];
      |     ^~~~
a.cc:41:17: error: reference to 'prev' is ambiguous
   41 |                 prev[i+3] = i+1;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:5: note:                 'int prev [210000]'
   19 | int prev[MAX];
      |     ^~~~
a.cc:42:17: error: reference to 'prev' is ambiguous
   42 |                 prev[i+1] = i;
      |                 ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:5: note:                 'int prev [210000]'
   19 | int prev[MAX];
      |     ^~~~
a.cc:51:22: error: reference to 'prev' is ambiguous
   51 |                 st = prev[st];
      |                      ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:244:5: note: candidates are: 'template<class _BidirectionalIterator> constexpr _BidirectionalIterator std::prev(_BidirectionalIterator, typename iterator_traits<_Iter>::difference_type)'
  244 |     prev(_BidirectionalIterator __x, typename
      |     ^~~~
a.cc:19:5: note:                 'int prev [210000]'
   19 | int prev[MAX];
      |     ^~~~