# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
344894 | bash | "The Lyuboyn" code (IZhO19_lyuboyn) | C++17 | 111 ms | 48864 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n, k, t;
vector <int> tran;
int val(string &s) {
int res = 0;
for (int i = 0; i < s.size(); i++) {
res += ((s[i] - '0') << i);
}
return res;
}
string rev(int x) {
string res;
for (int i = 0; i < n; i++) {
res += (x % 2 + '0');
x /= 2;
}
return res;
}
int used[1 << 18];
int cnt = 0;
vector <int> vec;
int com(string a, string b) {
int res = 0;
for (int i = 0; i < a.size(); i++) {
res += (a[i] != b[i]);
}
return res;
}
void go(int x) {
used[x] = 1;
cnt++;
vec.push_back(x);
if (cnt == (1 << n)) {
if (t == 0 || (com(rev(vec[0]), rev(vec.back())) == k)) {
cout << vec.size() << endl;
for (int to : vec) {
cout << rev(to) << '\n';
}
exit(0);
}
} else {
for (int to : tran) {
if (!used[x ^ to]) {
go(x ^ to);
}
}
}
}
main() {
scanf("%d %d %d", &n, &k, &t);
if (k % 2 == 0) {
puts("-1");
return 0;
}
for (int i = 0; i < (1 << n); i++) {
if (__builtin_popcount(i) == k) {
tran.push_back(i);
}
}
string s; cin >> s;
int x = val(s);
go(x);
}
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... |