Submission #288137

#TimeUsernameProblemLanguageResultExecution timeMemory
288137bensonlzl"The Lyuboyn" code (IZhO19_lyuboyn)C++14
100 / 100
228 ms15952 KiB
#include <bits/stdc++.h> using namespace std; int N, K, T, S; string st; int usable[1000005]; vector<int> kdiff, ans; void dfs(int x){ usable[x] = 0; ans.push_back(x); for (auto it : kdiff){ if (usable[x ^ it]){ dfs(x ^ it); return; } } } string intToString(int x){ string r; for (int i = 0; i < N; ++i){ r = ((x & (1 << i)) ? '1' : '0') + r; } return r; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> N >> K >> T; cin >> st; for (int i = 0; i < (int) st.size(); ++i){ S *= 2; S += (int) (st[i]-'0'); } for (int i = 0; i < (1 << N); ++i){ if (__builtin_popcount(i) == K){ kdiff.push_back(i); } usable[i] = 1; } dfs(S); if ((int) ans.size() != (1 << N)){ cout << -1 << '\n'; } else{ cout << (1 << N) << '\n'; for (auto it : ans){ cout << intToString(it) << '\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...