Submission #320496

# Submission time Handle Problem Language Result Execution time Memory
320496 2020-11-08T21:24:48 Z qpwoeirut Binary Subsequences (info1cup17_binary) C++17
0 / 100
900 ms 844 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int T, K;
string table[10001];
ll ct(string s) {
    set<string> ans;
    const int N = s.size();
    for (int i=1; i<(1 << N); ++i) {
        string t;
        for (int j=0; j<N; ++j) {
            if ((i >> j) & 1) t += s[j];
        }
        ans.emplace(t);
    }
    return ans.size();
}

int L;
void gen(const string s) {
    if (s.size() == L) {
        table[ct(s)] = s;
        return;
    }
    gen(s + '0');
    gen(s + '1');
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> T;

    for (L=20; L>0; --L) {
        gen("");
    }

    for (int i=0; i<T; ++i) {
        cin >> K;

        if (table[K].size()) {
            cout << "-1\n" << table[K] << '\n';
        } else {
            cout << "-1\n-1\n";
        }
    }
}

Compilation message

binary.cpp: In function 'void gen(std::string)':
binary.cpp:24:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |     if (s.size() == L) {
      |         ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1055 ms 844 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 740 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1056 ms 620 KB Time limit exceeded
2 Halted 0 ms 0 KB -