Submission #1142105

#TimeUsernameProblemLanguageResultExecution timeMemory
1142105AgageldiBinary Subsequences (info1cup17_binary)C++17
0 / 100
1092 ms4152 KiB
#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; s = g = ""; int ans = t + 1; for(int i=1;i<=t;i++) { g+='1'; } for(int i = 0; i <= t;i++) { int x1 = t - i, x2 = i; s = ""; while(x1 != x2) { if(x1 > x2) { x1 -= (x2 + 1); s += '1'; } else { x2 -= (x1 + 1); s += '0'; } } if(x1 == 0 && x2 == 0 && sz(s) < sz(g)) g = s; else ans--; } cout << ans << '\n'; for(int i = 0 ;i<sz(g); i++) { cout << g[i] << " "; } cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...