답안 #990898

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990898 2024-05-31T17:58:07 Z ToniB "The Lyuboyn" code (IZhO19_lyuboyn) C++17
100 / 100
44 ms 6588 KB
#include <bits/stdc++.h>
using namespace std;

int n, k, t;
string s;

int toInt(string s) {
	int ret = 0;
	for (int i = 0; i < s.length(); ++i) {
		ret <<= 1;
		ret += (s[i] == '1');
	}
	return ret;
}
string toStr(int x) {
	string ret = "";
	for (int i = n - 1; i >= 0; --i) {
		if (x & 1 << i) ret += '1';
		else ret += '0';
	}
	return ret;
}

vector<int> prufer(int lvl) {
	if (lvl == 1) return {0, 1};
	vector<int> ret = prufer(lvl - 1);
	int sz = (int)ret.size();
	for (int i = sz - 1; i >= 0; --i) ret.push_back(ret[i] | (1 << (lvl - 1)));
	return ret;
}

vector<int> gen(int lvl) {
	if (lvl == k + 1) {
		vector<int> ret = prufer(lvl);
		int cur = (1 << lvl) - 1;
		for (int i = 1; i < (int)ret.size(); i += 2) {
			ret[i] ^= cur;
		}
		return ret;
	}
	vector<int> sub = gen(lvl - 1);
	vector<int> ret = sub;
	int cur = 0;
	for (int i = lvl - 1; i >= lvl - k; --i) cur |= 1 << i;
	int nxt = ret.back() ^ cur;
	int dif = sub[0] ^ nxt;
	for (int x : sub) {
		ret.push_back(x ^ dif);
	}
	return ret;
}

int main(){
	cin >> n >> k >> t >> s;

	if (!(k & 1)) {
		cout << "-1\n"; return 0;
	}

	vector<int> ans = gen(n);

	cout << (1 << n) << "\n";
	
	int xr = toInt(s);
	for (int x : ans) {
		string cur = toStr(x ^ xr ^ ans[0]);
		cout << cur << "\n";
	}
	
	return 0;
}

Compilation message

lyuboyn.cpp: In function 'int toInt(std::string)':
lyuboyn.cpp:9:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for (int i = 0; i < s.length(); ++i) {
      |                  ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Ok
2 Correct 0 ms 348 KB Ok
3 Correct 0 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 0 ms 348 KB Ok
7 Correct 0 ms 412 KB Ok
8 Correct 1 ms 344 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 6580 KB Ok
2 Correct 17 ms 3280 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 1 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Ok
2 Correct 1 ms 604 KB Ok
3 Correct 18 ms 3280 KB Ok
4 Correct 9 ms 1752 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 1 ms 348 KB Ok
7 Correct 4 ms 1116 KB Ok
8 Correct 0 ms 348 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 6376 KB Ok
2 Correct 39 ms 6328 KB Ok
3 Correct 37 ms 6588 KB Ok
4 Correct 20 ms 3276 KB Ok
5 Correct 18 ms 3280 KB Ok
6 Correct 9 ms 1752 KB Ok
7 Correct 9 ms 1752 KB Ok
8 Correct 3 ms 1116 KB Ok
9 Correct 3 ms 1116 KB Ok
10 Correct 2 ms 600 KB Ok
11 Correct 0 ms 348 KB Ok
12 Correct 0 ms 348 KB Ok
13 Correct 0 ms 348 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 6580 KB Ok
2 Correct 17 ms 3280 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 1 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 0 ms 348 KB Ok
7 Correct 1 ms 604 KB Ok
8 Correct 18 ms 3280 KB Ok
9 Correct 9 ms 1752 KB Ok
10 Correct 0 ms 348 KB Ok
11 Correct 1 ms 348 KB Ok
12 Correct 4 ms 1116 KB Ok
13 Correct 0 ms 348 KB Ok
14 Correct 44 ms 6376 KB Ok
15 Correct 39 ms 6328 KB Ok
16 Correct 37 ms 6588 KB Ok
17 Correct 20 ms 3276 KB Ok
18 Correct 18 ms 3280 KB Ok
19 Correct 9 ms 1752 KB Ok
20 Correct 9 ms 1752 KB Ok
21 Correct 3 ms 1116 KB Ok
22 Correct 3 ms 1116 KB Ok
23 Correct 2 ms 600 KB Ok
24 Correct 0 ms 348 KB Ok
25 Correct 0 ms 348 KB Ok
26 Correct 0 ms 348 KB Ok
27 Correct 37 ms 6340 KB Ok
28 Correct 18 ms 3204 KB Ok
29 Correct 38 ms 6568 KB Ok
30 Correct 2 ms 600 KB Ok
31 Correct 0 ms 348 KB Ok
32 Correct 1 ms 604 KB Ok
33 Correct 3 ms 1056 KB Ok
34 Correct 0 ms 344 KB Ok
35 Correct 0 ms 348 KB Ok
36 Correct 0 ms 348 KB Ok
37 Correct 0 ms 348 KB Ok
38 Correct 21 ms 3320 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 3276 KB Ok
2 Correct 44 ms 6340 KB Ok
3 Correct 37 ms 6580 KB Ok
4 Correct 2 ms 604 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 4 ms 988 KB Ok
7 Correct 37 ms 6404 KB Ok
8 Correct 0 ms 344 KB Ok
9 Correct 0 ms 344 KB Ok
10 Correct 0 ms 348 KB Ok
11 Correct 9 ms 1948 KB Ok
12 Correct 18 ms 3220 KB Ok