# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
990897 | ToniB | "The Lyuboyn" code (IZhO19_lyuboyn) | C++17 | 45 ms | 6592 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>
using namespace std;
int n, k, t;
string s;
int toInt(string s) {
int ret = 0;
for (int i = 0; i < s.length(); ++i) {
ret <<= 1;
ret += (s[i] == '1');
}
return ret;
}
string toStr(int x) {
string ret = "";
for (int i = n - 1; i >= 0; --i) {
if (x & 1 << i) ret += '1';
else ret += '0';
}
return ret;
}
vector<int> prufer(int lvl) {
if (lvl == 1) return {0, 1};
vector<int> ret = prufer(lvl - 1);
int sz = (int)ret.size();
for (int i = sz - 1; i >= 0; --i) ret.push_back(ret[i] | (1 << (lvl - 1)));
return ret;
}
vector<int> gen(int lvl) {
if (lvl == k + 1) {
vector<int> ret = prufer(lvl);
int cur = (1 << lvl) - 1;
for (int i = 1; i < (int)ret.size(); i += 2) {
ret[i] ^= cur;
}
return ret;
}
vector<int> sub = gen(lvl - 1);
vector<int> ret = sub;
int cur = 0;
for (int i = lvl - 1; i >= lvl - k; --i) cur |= 1 << i;
int nxt = ret.back() ^ cur;
int dif = sub[0] ^ nxt;
for (int x : sub) {
ret.push_back(x ^ dif);
}
return ret;
}
int main(){
cin >> n >> k >> t >> s;
if (!(k & 1) && t) {
cout << "-1\n"; return 0;
}
vector<int> ans = gen(n);
cout << (1 << n) << "\n";
int xr = toInt(s);
for (int x : ans) {
string cur = toStr(x ^ xr ^ ans[0]);
cout << cur << "\n";
}
return 0;
}
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... |