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")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree <pair <int, int>, null_type, less <pair <int, int> >, rb_tree_tag, tree_order_statistics_node_update>
using namespace __gnu_pbds;
#define ll long long
#define db double
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mp make_pair
#define size(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define low_b lower_bound
#define endl "\n"
//#define int long long
using namespace std;
void dout() {
cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
cerr << H << ' ';
dout(T...);
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
int n, k, t, s;
string tobit(int x) {
string res = "";
do {
res += char((x & 1) + '0');
x >>= 1;
} while (x);
while (size(res) < n) {
res += '0';
}
reverse(all(res));
return res;
}
vector <int> vec, ans;
bool used[(1 << 18)];
void dfs(int v) {
ans.pb(v);
used[v] = true;
for (auto i : vec) {
if (!used[v ^ i]) {
dfs(v ^ i);
break;
}
}
}
void solve(int tc) {
// check for (int i = 0; i < n; j++)
cin >> n >> k >> t;
for (int i = 0; i < (1 << n); i++) {
if (__builtin_popcount(i) == k) {
vec.pb(i);
}
}
string tmp;
cin >> tmp;
for (int i = 0; i < size(tmp); i++) {
if (tmp[i] == '1') {
s += (1 << (size(tmp) - i - 1));
}
}
dfs(s);
if (size(ans) < (1 << n)) {
cout << -1;
return;
}
cout << (1 << n) << endl;
for (auto i : ans) {
cout << tobit(i) << endl;
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int tc = 1;
// cin >> tc;
for (int i = 0; i < tc; i++) {
solve(i);
// cleanup();
}
}
# | 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... |