#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define fi first
#define se second
#define p_b push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define sset ordered_set
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
const ll MAXN = 1123456;
const ll N = 2e5;
mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count());
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T> void vout(T s){cout << s << endl;exit(0);}
ll Val(string s){
ll ans = 0;
for(auto i : s){
ans *= 2;
ans |= i - '0';
}
return ans;
}
ll n;
string Fst(ll x){
string ans;
for(int i = n - 1; i >= 0; i--){
if((x & pw(i))){
ans += "1";
}else ans += "0";
}
return ans;
}
ll kol(ll a, ll b){
ll ans = 0;
for(int i = 0; i < n; i++){
if((a & pw(i)) != (b & pw(i)))ans++;
}
return ans;
}
int main(){
ios_base :: sync_with_stdio(0);
cin.tie(0);
ll k, t;
cin >> n >> k >> t;
vector <ll> a(pw(n));
for(int i = 0; i < pw(n); i++)a[i] = i;
string st;
cin >> st;
ll s = Val(st);
swap(a[0], a[s]);
while(clock() / (double)CLOCKS_PER_SEC < 0.95){
shuffle(a.begin() + 1, a.end(), rnd);
bool bad = 0;
for(int i = 1; i < pw(n); i++){
if(kol(a[i], a[i - 1]) != k)bad = 1;
}
if(bad)continue;
if(t && kol(a.back(), a[0]) != k)continue;
cout << pw(n) << "\n";
for(auto i : a){
cout << Fst(i) << "\n";
}
return 0;
}
vout(-1);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
424 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
950 ms |
384 KB |
Output -1 while solution exists |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
950 ms |
456 KB |
Ok |
2 |
Correct |
961 ms |
2456 KB |
Ok |
3 |
Correct |
950 ms |
1428 KB |
Ok |
4 |
Correct |
950 ms |
380 KB |
Ok |
5 |
Correct |
950 ms |
412 KB |
Ok |
6 |
Correct |
950 ms |
396 KB |
Ok |
7 |
Correct |
950 ms |
452 KB |
Ok |
8 |
Correct |
953 ms |
1416 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
955 ms |
2520 KB |
Output -1 while solution exists |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
950 ms |
380 KB |
Output -1 while solution exists |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
952 ms |
2464 KB |
Output -1 while solution exists |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
955 ms |
2520 KB |
Output -1 while solution exists |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
951 ms |
1432 KB |
Output -1 while solution exists |
2 |
Halted |
0 ms |
0 KB |
- |