#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define f first
#define s second
#define cbr cerr<<"hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ll(x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x,y) (lower_bound(all(x),y)-x.begin())
#define ubd(x,y) (upper_bound(all(x),y)-x.begin())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return rng() % (y+1-x) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }
using ll=long long;
using ld=long double;
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
using pi=pair<ll,ll>; using spi=pair<ll,pi>; using dpi=pair<pi,pi>;
long long LLINF = 1e18;
int INF = 1e9+1e6;
#define MAXN (200006)
ll n, k, t, s;
int main() {
FAST
cin>>n>>k>>t;
FOR(i,1,n) {
char ch;cin>>ch;
s<<=1,s|=(ch&15);
}
function<vector<ll>(ll,ll)>dp=[&](ll n,ll k){
assert(n>=1);
if(k==1) {
if(n==1) return vector<ll>{0,1};
else {
vector<ll> v;
vector<ll> ret = dp(n-1, k);
for(auto i:ret) v.eb(i<<1);
while(ret.size()) v.eb(ret.back()<<1|1), ret.pop_back();
return v;
}
}
vector<ll> ret = dp(n-2, k-2);
vector<ll> v;
FOR(i,0,siz(ret)-1) if(i%2==0) v.eb(ret[i]<<2); else v.eb(ret[i]<<2|3);
ll bit = -1;
FOR(i,0,17) if((1<<i&ret[0]) == (1<<i&ret.back())) bit = i;
assert(~bit);
FOR(i,0,siz(ret)-1) if(i%2==0) v.eb(((ret[i]^(1<<bit))<<2)|1); else v.eb(((ret[i]^(1<<bit))<<2)|2);
return v;
};
vector<ll> v = dp(n, k);
ll change = 0;
FOR(i,0,n-1) if((1<<i&v[0]) != (1<<i&s)) change|=1<<i;
for(auto&i:v) i^=change;
auto b=[&](ll x){
string s;
DEC(i,n-1,0) if(1<<i&x) s += '1'; else s += '0';
return s;
};
cout<<(1<<n)<<'\n';
for(auto i:v) cout<<b(i)<<'\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
The output is not complete! |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
7504 KB |
Ok |
2 |
Correct |
35 ms |
3928 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Correct |
1 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
The output is not complete! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
1384 KB |
The output is not complete! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
7504 KB |
Ok |
2 |
Correct |
35 ms |
3928 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Correct |
1 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
6 |
Incorrect |
1 ms |
364 KB |
The output is not complete! |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
The output is not complete! |
2 |
Halted |
0 ms |
0 KB |
- |