| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 378375 | abc864197532 | "The Lyuboyn" code (IZhO19_lyuboyn) | C++17 | 836 ms | 6584 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;
#define lli long long int
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define test(x) cout << "Line(" << __LINE__ << ") " #x << ' ' << x << endl
#define printv(x) {\
for (auto i : x) cout << i << ' ';\
cout << endl;\
}
#define pii pair <int, int>
#define pll pair <lli, lli>
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<typename A, typename B>
ostream& operator << (ostream& o, pair<A, B> a){
return o << a.X << ' ' << a.Y;
}
template<typename A, typename B>
istream& operator >> (istream& o, pair<A, B> &a){
return o >> a.X >> a.Y;
}
const int mod = 1e9 + 7, abc = 864197532, N = 200000, logN = 18, K = 333;
vector <int> gray_code(int n) {
if (n == 1) return {0, 1};
vector <int> under = gray_code(n - 1);
vector <int> ans;
for (int i : under) ans.pb(i);
reverse(all(under));
for (int i : under) ans.pb(i | (1 << n - 1));
return ans;
}
int main () {
ios::sync_with_stdio(false);
cin.tie(0);
int n, k, t;
string str;
cin >> n >> k >> t >> str;
int from = 0;
for (int i = 0; i < n; ++i) from = (from << 1) | (str[i] == '1');
if (k & 1 ^ 1) {
cout << -1 << endl;
return 0;
}
auto output = [&](int v) {
v ^= from;
for (int i = n - 1; ~i; --i) cout << (v >> i & 1);
cout << endl;
};
cout << (1 << n) << endl;
if (k == 1) {
vector <int> ans = gray_code(n);
for (int i : ans) output(i);
return 0;
}
k >>= 1;
vector <int> right = gray_code(k * 2);
vector <int> lefta = gray_code(n - k * 2), leftb = lefta;
int id = 0;
for (int i = 0; i < lefta.size(); ++i) {
if (lefta[i] == (1 << n - k * 2 - 2)) id = i;
}
rotate(leftb.begin(), leftb.begin() + id, leftb.end());
for (int i = 0; i < right.size(); ++i) {
if (i & 1 ^ 1) {
for (int j = 0; j < lefta.size(); ++j) {
output(lefta[j] << (k * 2) | right[i]);
right[i] ^= ((1 << k * 2) - 1);
}
} else {
for (int j = 0; j < leftb.size(); ++j) {
output(leftb[j] << (k * 2) | right[i]);
right[i] ^= ((1 << k * 2) - 1);
}
}
}
}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... | ||||
