//#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);
}
}
}
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();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Ok |
2 |
Correct |
40 ms |
7412 KB |
Ok |
3 |
Execution timed out |
1079 ms |
4088 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
87 ms |
19116 KB |
Ok |
2 |
Correct |
43 ms |
9716 KB |
Ok |
3 |
Correct |
2 ms |
376 KB |
Ok |
4 |
Correct |
2 ms |
376 KB |
Ok |
5 |
Correct |
2 ms |
376 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Ok |
2 |
Correct |
6 ms |
892 KB |
Ok |
3 |
Correct |
138 ms |
9636 KB |
Ok |
4 |
Correct |
62 ms |
5076 KB |
Ok |
5 |
Correct |
2 ms |
376 KB |
Ok |
6 |
Correct |
3 ms |
504 KB |
Ok |
7 |
Correct |
26 ms |
2680 KB |
Ok |
8 |
Correct |
2 ms |
376 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1073 ms |
14316 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
87 ms |
19116 KB |
Ok |
2 |
Correct |
43 ms |
9716 KB |
Ok |
3 |
Correct |
2 ms |
376 KB |
Ok |
4 |
Correct |
2 ms |
376 KB |
Ok |
5 |
Correct |
2 ms |
376 KB |
Ok |
6 |
Correct |
2 ms |
376 KB |
Ok |
7 |
Correct |
6 ms |
892 KB |
Ok |
8 |
Correct |
138 ms |
9636 KB |
Ok |
9 |
Correct |
62 ms |
5076 KB |
Ok |
10 |
Correct |
2 ms |
376 KB |
Ok |
11 |
Correct |
3 ms |
504 KB |
Ok |
12 |
Correct |
26 ms |
2680 KB |
Ok |
13 |
Correct |
2 ms |
376 KB |
Ok |
14 |
Execution timed out |
1073 ms |
14316 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
64 ms |
9660 KB |
Ok |
2 |
Correct |
90 ms |
19056 KB |
Ok |
3 |
Execution timed out |
1086 ms |
14232 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |