답안 #290980

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
290980 2020-09-04T15:13:16 Z PeppaPig "The Lyuboyn" code (IZhO19_lyuboyn) C++14
51 / 100
1000 ms 18988 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(true) {
		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);
		}
		if(elapsed() >= 900) break;
	}
	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);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 899 ms 688 KB Ok
2 Correct 946 ms 7656 KB Ok
3 Correct 898 ms 4180 KB Ok
4 Correct 889 ms 376 KB Ok
5 Correct 897 ms 504 KB Ok
6 Correct 895 ms 504 KB Ok
7 Correct 886 ms 744 KB Ok
8 Correct 910 ms 4088 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 650 ms 18792 KB Ok
2 Correct 300 ms 9456 KB Ok
3 Correct 2 ms 384 KB Ok
4 Correct 0 ms 256 KB Ok
5 Correct 1 ms 256 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Ok
2 Correct 15 ms 896 KB Ok
3 Correct 417 ms 9428 KB Ok
4 Correct 226 ms 4968 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 4 ms 384 KB Ok
7 Correct 86 ms 2648 KB Ok
8 Correct 1 ms 512 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 805 ms 18988 KB Ok
2 Correct 688 ms 18796 KB Ok
3 Execution timed out 1094 ms 15896 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 650 ms 18792 KB Ok
2 Correct 300 ms 9456 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 384 KB Ok
7 Correct 15 ms 896 KB Ok
8 Correct 417 ms 9428 KB Ok
9 Correct 226 ms 4968 KB Ok
10 Correct 1 ms 384 KB Ok
11 Correct 4 ms 384 KB Ok
12 Correct 86 ms 2648 KB Ok
13 Correct 1 ms 512 KB Ok
14 Correct 805 ms 18988 KB Ok
15 Correct 688 ms 18796 KB Ok
16 Execution timed out 1094 ms 15896 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 485 ms 9412 KB Ok
2 Correct 651 ms 18796 KB Ok
3 Correct 696 ms 18768 KB Ok
4 Correct 36 ms 1352 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 94 ms 2536 KB Ok
7 Correct 762 ms 18960 KB Ok
8 Correct 2 ms 384 KB Ok
9 Correct 1 ms 256 KB Ok
10 Correct 2 ms 384 KB Ok
11 Correct 134 ms 4724 KB Ok
12 Correct 372 ms 9332 KB Ok