Submission #1143100

#TimeUsernameProblemLanguageResultExecution timeMemory
1143100AgageldiBinary Subsequences (info1cup17_binary)C++17
30.10 / 100
545 ms444 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, b[25]; map <string,int> vis; int main () { cin >> n; while(n--) { cin >> t; int ans = t + 1, ans1 = t+1, bb = 0; for(int i = 0; i <= t;i++) { int x1 = t - i, x2 = i, new_sz = 0; while(x1 != x2) { if(x1 > x2) { new_sz += (x1/(x2 + 1)); x1 = (x1 % (x2+1)); } else { new_sz += (x2/(x1 + 1)); x2 = x2%(x1+1); } } if(x1 == 0 && x2 == 0 && new_sz < ans) { ans = new_sz; bb = i; } } cout << "-1\n"; int x1 = t - bb, x2 = bb, new_sz = 0; while(x1 != x2) { if(x1 > x2) { for(int i= 1;i<=x1 / (x2 + 1); i++) { cout << '1' << " "; } x1 = x1%(x2 + 1); } for(int i = 1; i <= x2 / (x1+1); i++) { cout << '0' << " "; } x2 = (x2 % (x1 + 1)); } cout << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...