I feel like I am missing some corner case but I can’t think of anything else.
Problem Link : here
// Author : Epsilon573
// If it works, don’t touch it.#include <bits/stdc++.h>
using namespace std;typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;const ll mod = 1e9+7;
const ld eps = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf = LLONG_MAX;
const ll minf = LLONG_MIN;#define mp make_pair
#define pb push_back
#define endl “\n”
#define deb(x) cerr << #x << " " << x << endlbool solve()
{
ll n,a,b,c;
cin >> n >> a >> b >> c;if( a+b-c > n ) return false; if(a==1 && b==1 && n!=1) return false; if(n==1) { cout << 1 << endl; } else if(n==2) { if(a==1 && b==1) return false; if(a==2 && b==2){ assert(c==2); cout << "1 1" << endl; } else if(a==1 && b==2){ assert(c==1); cout << "2 1" << endl; } else { assert(c==1); assert(a==2); assert(b==1); cout << "1 2" << endl; } } else { ll leftover = n - (a+b-c); for(ll i=0 ; i<a-c ; ++i) cout << 2 << " "; for(ll i=0 ; i<c ; ++i) cout << 3 << " "; for(ll i=0 ; i<leftover ; ++i) cout << 1 << " "; for(ll i=0 ; i<b-c ; ++i) cout << 2 << " "; cout << endl; } return true;
}
int main()
{
ios_base :: sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);#ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); freopen("error.txt","w",stderr); #endif ll t=1; cin >> t; for( ll i=1 ; i<=t ; ++i) { cout << "Case #" << i << ": "; if(solve()) { NULL; } else { cout << "IMPOSSIBLE" << endl; } } return 0;
}