# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
290964 | PeppaPig | "The Lyuboyn" code (IZhO19_lyuboyn) | C++14 | 817 ms | 18916 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, s;
mt19937 rng(time(NULL));
void print(int val) {
vector<int> vec;
for(int i = 0; i < n; i++, val >>= 1)
vec.emplace_back(val & 1);
reverse(vec.begin(), vec.end());
for(int x : vec) printf("%d", x);
printf("\n");
}
chrono::steady_clock::time_point start;
chrono::steady_clock::time_point get_now() {
return chrono::steady_clock::now();
}
int elapsed() {
return (int)chrono::duration_cast<chrono::milliseconds>(get_now() - start).count();
}
int main() {
start = get_now();
scanf("%d %d %d", &n, &k, &t);
for(int i = 0; i < n; i++) {
char c; scanf("%c", &c);
s = (s << 1) + (c == '1');
}
vector<int> base;
for(int i = 0; i < (1 << n); i++) if(__builtin_popcount(i) == k)
base.emplace_back(i);
while(elapsed() <= 500) {
shuffle(base.begin(), base.end(), rng);
vector<int> ans = {s};
for(int j = 0; j < n; j++)
for(int i = (int)ans.size() - 1; ~i; i--)
ans.emplace_back(ans[i] ^ base[j]);
set<int> st(ans.begin(), ans.end());
if((int)st.size() == (1 << n) && (t == 0 || __builtin_popcount(ans[0] ^ ans.back()) == k)) {
printf("%d\n", (1 << n));
for(int x : ans) print(x);
exit(0);
}
}
printf("-1\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... |