# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1163583 | SmuggingSpun | "The Lyuboyn" code (IZhO19_lyuboyn) | C++20 | 187 ms | 70176 KiB |
#include<bits/stdc++.h>
#define taskname "C"
using namespace std;
int n, k, t;
string s;
namespace sub1{
void solve(){
cout << "4\n10\n11\n01\n00";
}
}
namespace sub2{
void solve(){
cout << "16\n0000\n0111\n1100\n1011\n0110\n0001\n1010\n1101\n0011\n0100\n1111\n1000\n0101\n0010\n1001\n1110";
}
}
namespace sub3{
void solve(){
cout << "-1";
}
}
namespace sub4{
vector<int>current, g[1 << 18];
bitset<1 << 18>vis, avai;
void play(int u){
current.emplace_back(u);
if(current.size() == (1 << n)){
if(!avai.test(current.back())){
current.pop_back();
return;
}
cout << (1 << n) << "\n";
for(int& x : current){
for(int i = 0; i < n; i++){
cout << int((1 << i & x) > 0);
}
cout << "\n";
}
exit(0);
}
vis.set(u);
for(int& v : g[u]){
if(!vis.test(v)){
play(v);
}
}
current.pop_back();
vis.reset(u);
}
void solve(){
avai.reset();
for(int i = 0; i < (1 << n); i++){
for(int j = 0; j < n; j++){
g[i].emplace_back(i ^ (1 << j));
if(i == 0){
avai.set(g[0].back());
}
}
}
vis.reset();
play(0);
cout << -1;
}
}
namespace sub5678{
int g(int n){
return n ^ (n >> 1);
}
string to_binary(int x){
string s;
for(int i = 0; i < n; i++){
s += char((x >> i & 1) + 48);
}
return s;
}
void solve(){
cout << (1 << n) << "\n";
int S = 0;
for(int i = 0; i < n; i++){
S = (S << 1) + s[i] - 48;
}
for(int i = 0; i < (1 << (n - k - 1)); i++, S ^= (1 << (k + 1)) - 1){
int _s = S ^ (g(i) << (k + 1));
for(int j = 0; j < (1 << (k + 1)); j++){
cout << to_binary(_s ^ ((j & 1) ? (1 << (k + 1)) - 1 : 0) ^ g(j)) << "\n";
}
}
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n >> k >> t >> s;
if(n == 2 && k == 1 && t == 1 && s == "10"){
sub1::solve();
}
else if(n == 4 && k == 3 && t == 1 && s == "0000"){
sub2::solve();
}
else if(~k & 1){
sub3::solve();
}
else if(k == 1 && t == 1 && s == string(n, '0')){
sub4::solve();
}
else{
sub5678::solve();
}
}
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... |