#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 600005
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define sz(s) (int)s.size()
ll T, n, a[N], t, ans,b[25];
string s, g;
map <string,int> vis;
int main () {
	cin >> n;
	while(n--) {
		cin >> t;
		int ans = t + 1, ans1 = t+1;
		vector <pair<int,int>> answer;
		for(int i = 0; i <= t;i++) {
			int x1 = t - i, x2 = i, new_sz = 0;
			vector<pair<int, int>> add; // sany, name
			while(x1 != x2) {
				if(x1 > x2) {
					add.push_back({x1 / (x2 + 1),1});
					new_sz += (x1/(x2 + 1));
					x1 %= (x2 + 1);
				}
				else {
					add.pb({x2/(x1+1),0});
					new_sz += (x2/(x1 + 1));
					x2 %= (x1 + 1);
				}
			}
			if(x1 == 0 && x2 == 0 && new_sz < ans) {
				ans = new_sz;
				answer = add;
			}
			if (x1 > 0 || x2 > 0)ans1--;
		}
		cout << ans1 << '\n';
		for(auto i:answer) {
			int tp = i.ff;
			while(tp--) {
				cout << i.ss << " ";
			}
		}
		cout << '\n';
	}
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |