Submission #290977

# Submission time Handle Problem Language Result Execution time Memory
290977 2020-09-04T15:11:21 Z PeppaPig "The Lyuboyn" code (IZhO19_lyuboyn) C++14
36 / 100
1000 ms 18992 KB
#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();

	char input[100];
	scanf("%d %d %d %s", &n, &k, &t, input);
	for(int i = 0; input[i] != '\0'; i++)
		s = (s << 1) + (input[i] == '1');

	vector<int> base;
	for(int i = 0; i < (1 << n); i++) if(__builtin_popcount(i) == k)
		base.emplace_back(i);

	while(elapsed() <= 800) {
		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)) {
			printf("%d\n", (1 << n));
			for(int x : ans) print(x);
			exit(0);
		}
	}
	printf("-1\n");

	return 0;
}

Compilation message

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   31 |  scanf("%d %d %d %s", &n, &k, &t, input);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 792 ms 640 KB Ok
2 Correct 818 ms 7496 KB Ok
3 Correct 814 ms 4064 KB Ok
4 Correct 786 ms 364 KB Ok
5 Correct 801 ms 384 KB Ok
6 Correct 792 ms 424 KB Ok
7 Correct 800 ms 680 KB Ok
8 Correct 796 ms 3972 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 651 ms 18676 KB Ok
2 Correct 289 ms 9328 KB Ok
3 Correct 2 ms 384 KB Ok
4 Correct 0 ms 256 KB Ok
5 Correct 1 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Ok
2 Correct 19 ms 832 KB Ok
3 Execution timed out 1002 ms 9556 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 738 ms 18912 KB Ok
2 Execution timed out 1094 ms 16624 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 651 ms 18676 KB Ok
2 Correct 289 ms 9328 KB Ok
3 Correct 2 ms 384 KB Ok
4 Correct 0 ms 256 KB Ok
5 Correct 1 ms 256 KB Ok
6 Correct 1 ms 256 KB Ok
7 Correct 19 ms 832 KB Ok
8 Execution timed out 1002 ms 9556 KB Time limit exceeded
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 592 ms 9344 KB Ok
2 Correct 655 ms 18796 KB Ok
3 Correct 680 ms 18796 KB Ok
4 Correct 39 ms 1416 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 339 ms 2600 KB Ok
7 Correct 958 ms 18992 KB Ok
8 Correct 2 ms 384 KB Ok
9 Correct 0 ms 256 KB Ok
10 Correct 2 ms 384 KB Ok
11 Correct 140 ms 4852 KB Ok
12 Correct 409 ms 9472 KB Ok