# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1090880 | KKT89 | "The Lyuboyn" code (IZhO19_lyuboyn) | C++17 | 173 ms | 32380 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n, k, t;
cin >> n >> k >> t;
if (k % 2 == 0) {
cout << "-1" << endl;
return 0;
}
string s;
cin >> s;
int init = 0;
for (char c : s) {
init = init * 2 + c - '0';
}
vector<int> v;
vector<int> used(1 << n);
used[init] = 1;
vector<int> u;
for (int i = 1; i < (1 << n); i++) {
if (__builtin_popcount(i) == k) {
u.push_back(i);
}
}
auto dfs = [&](auto dfs) -> void {
if (v.size() == (1 << n)) {
if (__builtin_popcount(v[0] ^ v.back()) == k) {
cout << v.size() << "\n";
for (int i : v) {
for (int j = n - 1; j >= 0; --j) {
if ((1 << j) & i) cout << 1;
else cout << 0;
}
cout << "\n";
}
cout << endl;
exit(0);
}
return;
}
for (int i : u) {
int nx = (v.back() ^ i);
if (used[nx]) continue;
v.push_back(nx);
used[nx] = 1;
dfs(dfs);
used[nx] = 0;
v.pop_back();
}
};
v.push_back(init);
dfs(dfs);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |