답안 #290954

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
290954 2020-09-04T15:01:53 Z PeppaPig "The Lyuboyn" code (IZhO19_lyuboyn) C++14
34 / 100
1000 ms 18868 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();

	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() <= 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:30:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   30 |  scanf("%d %d %d", &n, &k, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
lyuboyn.cpp:32:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   32 |   char c; scanf("%c", &c);
      |           ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 384 KB First number in answer is not x 1 2
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 790 ms 628 KB Ok
2 Correct 819 ms 7524 KB Ok
3 Correct 800 ms 4096 KB Ok
4 Correct 798 ms 376 KB Ok
5 Correct 789 ms 384 KB Ok
6 Correct 795 ms 424 KB Ok
7 Correct 797 ms 616 KB Ok
8 Correct 807 ms 3984 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 653 ms 18668 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Ok
2 Correct 22 ms 832 KB Ok
3 Correct 301 ms 9472 KB Ok
4 Correct 159 ms 4836 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 4 ms 512 KB Ok
7 Correct 103 ms 2588 KB Ok
8 Correct 1 ms 384 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 18868 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 653 ms 18668 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 22 ms 832 KB Ok
8 Correct 301 ms 9472 KB Ok
9 Correct 159 ms 4836 KB Ok
10 Correct 1 ms 384 KB Ok
11 Correct 4 ms 512 KB Ok
12 Correct 103 ms 2588 KB Ok
13 Correct 1 ms 384 KB Ok
14 Execution timed out 1071 ms 18868 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 809 ms 4304 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -