For this Question: Given a number N. The task is to generate and print all binary numbers with decimal values from 1 to N.

Try solving this using a queue.The only line of input contains a single integer N.

1 <= N <= 50000Print all binary numbers with decimal values from 1 to N in a single line.Sample Input:
5

Sample Output:
1 10 11 100 101, I have written this Solution Code: #include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int N = 500 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;

void solve(){
	int n;	cin >> n;
	queue<string> q;
	q.push("1");
	while(n--){
		string x = q.front();
		q.pop();
		cout << x << " ";
		q.push(x + "0");
		q.push(x + "1");
	}
}

void testcases(){
	int tt = 1; 
	//cin >> tt;
	while(tt--){
		solve();
	}
}

signed main() {
	IOS;
		clock_t start = clock();

	testcases();

	cerr << (double)(clock() - start)*1000/CLOCKS_PER_SEC << " ms" << endl;
	return 0;
}	, In this Programming Language: C++, Now tell me if this Code is compilable or not?