답안 #499796

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499796 2021-12-29T13:06:57 Z NachoLibre "The Lyuboyn" code (IZhO19_lyuboyn) C++17
100 / 100
70 ms 7492 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;

string str(int x, int n) {
	string s;
	for(int i = n - 1; i >= 0; --i) { s += '0' + !!(x & 1 << i); }
	return s;
}
int num(string s) {
	int x = 0;
	for(int i = 0; i < sz(s); ++i) { x <<= 1; x |= s[i] == '1'; }
	return x;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k, t;
	string S;
	#ifndef wambule
	cin >> n >> k >> t >> S;
	#else
	n = 18; k = 3; t = 1;
	S = "0";
	#endif
	int s = num(S);
	if(k % 2 == 0) return cout << -1 << endl, 0;
	vector<int> v{0};
	for(int i = 1; i < k + 1; ++i) {
		v.push_back(i);
		for(int j = sz(v) - 2; j >= 0; --j) {
			v.push_back(v[j]);
		}
	}
	vector<int> fp{0};
	for(int i : v) {
		fp.push_back(fp.back() ^ (1 << k + 1) - 1 ^ 1 << i);
	}
	for(int i = k + 1; i < n; ++i) {
		for(int j = sz(fp) - 1; j >= 0; --j) {
			fp.push_back(fp[j] ^ 1 << i ^ (1 << k - 1) - 1);
		}
	}
	for(int i = 0; i < sz(fp); ++i) {
		int x = __builtin_popcountll(fp[i] ^ fp[(i + 1) % sz(fp)]);
		if(x != k) {
			cout << "! ! ! ! !" << endl;
			return 0;
		}
	}
	cout << (1 << n) << endl;
	for(int x : fp) {
		cout << str(x ^ s, n) + "\n";
	}
	return 0;
}

Compilation message

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:41:36: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   41 |   fp.push_back(fp.back() ^ (1 << k + 1) - 1 ^ 1 << i);
      |                                  ~~^~~
lyuboyn.cpp:41:41: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   41 |   fp.push_back(fp.back() ^ (1 << k + 1) - 1 ^ 1 << i);
      |                            ~~~~~~~~~~~~~^~~
lyuboyn.cpp:45:42: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   45 |    fp.push_back(fp[j] ^ 1 << i ^ (1 << k - 1) - 1);
      |                                        ~~^~~
lyuboyn.cpp:45:47: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   45 |    fp.push_back(fp[j] ^ 1 << i ^ (1 << k - 1) - 1);
      |                                  ~~~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 0 ms 204 KB Ok
3 Correct 0 ms 312 KB Ok
4 Correct 0 ms 204 KB Ok
5 Correct 0 ms 204 KB Ok
6 Correct 0 ms 312 KB Ok
7 Correct 0 ms 204 KB Ok
8 Correct 1 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 6364 KB Ok
2 Correct 26 ms 3268 KB Ok
3 Correct 1 ms 300 KB Ok
4 Correct 0 ms 204 KB Ok
5 Correct 0 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 1 ms 460 KB Ok
3 Correct 24 ms 3268 KB Ok
4 Correct 13 ms 1744 KB Ok
5 Correct 1 ms 292 KB Ok
6 Correct 1 ms 288 KB Ok
7 Correct 6 ms 1040 KB Ok
8 Correct 0 ms 304 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 6464 KB Ok
2 Correct 59 ms 6392 KB Ok
3 Correct 52 ms 6372 KB Ok
4 Correct 26 ms 3320 KB Ok
5 Correct 24 ms 3248 KB Ok
6 Correct 12 ms 1744 KB Ok
7 Correct 14 ms 1748 KB Ok
8 Correct 6 ms 1076 KB Ok
9 Correct 5 ms 1100 KB Ok
10 Correct 4 ms 588 KB Ok
11 Correct 1 ms 332 KB Ok
12 Correct 1 ms 332 KB Ok
13 Correct 1 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 50 ms 6364 KB Ok
2 Correct 26 ms 3268 KB Ok
3 Correct 1 ms 300 KB Ok
4 Correct 0 ms 204 KB Ok
5 Correct 0 ms 204 KB Ok
6 Correct 1 ms 204 KB Ok
7 Correct 1 ms 460 KB Ok
8 Correct 24 ms 3268 KB Ok
9 Correct 13 ms 1744 KB Ok
10 Correct 1 ms 292 KB Ok
11 Correct 1 ms 288 KB Ok
12 Correct 6 ms 1040 KB Ok
13 Correct 0 ms 304 KB Ok
14 Correct 47 ms 6464 KB Ok
15 Correct 59 ms 6392 KB Ok
16 Correct 52 ms 6372 KB Ok
17 Correct 26 ms 3320 KB Ok
18 Correct 24 ms 3248 KB Ok
19 Correct 12 ms 1744 KB Ok
20 Correct 14 ms 1748 KB Ok
21 Correct 6 ms 1076 KB Ok
22 Correct 5 ms 1100 KB Ok
23 Correct 4 ms 588 KB Ok
24 Correct 1 ms 332 KB Ok
25 Correct 1 ms 332 KB Ok
26 Correct 1 ms 204 KB Ok
27 Correct 51 ms 7492 KB Ok
28 Correct 24 ms 3300 KB Ok
29 Correct 53 ms 6392 KB Ok
30 Correct 2 ms 588 KB Ok
31 Correct 0 ms 332 KB Ok
32 Correct 2 ms 460 KB Ok
33 Correct 5 ms 1100 KB Ok
34 Correct 0 ms 204 KB Ok
35 Correct 0 ms 316 KB Ok
36 Correct 1 ms 316 KB Ok
37 Correct 0 ms 204 KB Ok
38 Correct 34 ms 3504 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 3528 KB Ok
2 Correct 49 ms 7392 KB Ok
3 Correct 70 ms 6432 KB Ok
4 Correct 2 ms 588 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 5 ms 1136 KB Ok
7 Correct 51 ms 6464 KB Ok
8 Correct 1 ms 332 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 1 ms 332 KB Ok
11 Correct 13 ms 2008 KB Ok
12 Correct 25 ms 3340 KB Ok