Submission #1090880

#TimeUsernameProblemLanguageResultExecution timeMemory
1090880KKT89"The Lyuboyn" code (IZhO19_lyuboyn)C++17
100 / 100
173 ms32380 KiB
#pragma GCC optimize("Ofast") #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef unsigned long long int ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, k, t; cin >> n >> k >> t; if (k % 2 == 0) { cout << "-1" << endl; return 0; } string s; cin >> s; int init = 0; for (char c : s) { init = init * 2 + c - '0'; } vector<int> v; vector<int> used(1 << n); used[init] = 1; vector<int> u; for (int i = 1; i < (1 << n); i++) { if (__builtin_popcount(i) == k) { u.push_back(i); } } auto dfs = [&](auto dfs) -> void { if (v.size() == (1 << n)) { if (__builtin_popcount(v[0] ^ v.back()) == k) { cout << v.size() << "\n"; for (int i : v) { for (int j = n - 1; j >= 0; --j) { if ((1 << j) & i) cout << 1; else cout << 0; } cout << "\n"; } cout << endl; exit(0); } return; } for (int i : u) { int nx = (v.back() ^ i); if (used[nx]) continue; v.push_back(nx); used[nx] = 1; dfs(dfs); used[nx] = 0; v.pop_back(); } }; v.push_back(init); dfs(dfs); }

Compilation message (stderr)

lyuboyn.cpp: In instantiation of 'main()::<lambda(auto:23)> [with auto:23 = main()::<lambda(auto:23)>]':
lyuboyn.cpp:61:12:   required from here
lyuboyn.cpp:35:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |         if (v.size() == (1 << 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...