답안 #499789

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499789 2021-12-29T12:54:28 Z NachoLibre "The Lyuboyn" code (IZhO19_lyuboyn) C++17
3 / 100
53 ms 6460 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;
	cin >> n >> k >> t >> S;
	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 x : fp) {
		cout << str(x ^ s, n) + "\n";
	}
	return 0;
}

Compilation message

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:36:36: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   36 |   fp.push_back(fp.back() ^ (1 << k + 1) - 1 ^ 1 << i);
      |                                  ~~^~~
lyuboyn.cpp:36:41: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   36 |   fp.push_back(fp.back() ^ (1 << k + 1) - 1 ^ 1 << i);
      |                            ~~~~~~~~~~~~~^~~
lyuboyn.cpp:40:42: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   40 |    fp.push_back(fp[j] ^ 1 << i ^ (1 << k - 1) - 1);
      |                                        ~~^~~
lyuboyn.cpp:40:47: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   40 |    fp.push_back(fp[j] ^ 1 << i ^ (1 << k - 1) - 1);
      |                                  ~~~~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB The output is neither -1 nor the length of the answer
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 316 KB Expected integer, but "0000" found
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Ok
2 Correct 0 ms 204 KB Ok
3 Correct 1 ms 308 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 268 KB Ok
8 Correct 0 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 6440 KB Expected integer, but "000000000000000000" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Expected integer, but "0000000" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 6460 KB Expected integer, but "010101010011010100" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 51 ms 6440 KB Expected integer, but "000000000000000000" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 3496 KB Expected integer, but "01011001010101101" found
2 Halted 0 ms 0 KB -