답안 #343821

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
343821 2021-01-04T14:12:30 Z Tosic "The Lyuboyn" code (IZhO19_lyuboyn) C++14
66 / 100
1000 ms 23648 KB
#include <bits/stdc++.h>
#define maxn 400010
using namespace std;

int n, k, t, ans;
vector<int> curR,masks;
bool was[maxn];

int bD(int a, int b){
	return __builtin_popcount(a^b)==k;
}


void printR(){
cout << (1<<n) << '\n';
	for(auto i : curR){
		bitset<32> tmp = i;
		//cout << tmp;
		for(int j = n-1; j >= 0; --j){
			cout << tmp[j];
		}
		cout << '\n';
	}
	exit(0);
}

void getR(int x){
	if(was[curR.back()]){
		return;
	}
	if(x == (1<<n)){
		if(t == 1 and bD(curR[0],curR.back())){
			printR();
		}
		if(!t and !bD(curR[0],curR.back())){
			printR();
		}
		return;
	}
	
	was[curR.back()] = 1;
	for(auto i : masks){
		curR.push_back(curR.back()^i);
		getR(x+1);
		curR.pop_back();
	}
	was[curR.back()] = 0;
}

int main(){
	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	string s;
	cin >> n >> k >> t >> s;
	int res = 0;
	for(int i =0 ; i < s.length(); ++i){
		res *= 2;
		res += (s[i]-'0');
	}
	for(int i = 0; i < (1<<n); ++i){
		if(bD(0, i)){
			masks.push_back(i);
		}
	}
	curR.push_back(res);
	getR(1);
	cout << -1;
}

Compilation message

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:57:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |  for(int i =0 ; i < s.length(); ++i){
      |                 ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1076 ms 620 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 306 ms 23212 KB Ok
2 Correct 169 ms 11716 KB Ok
3 Correct 1 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 8 ms 1004 KB Ok
3 Correct 144 ms 11756 KB Ok
4 Correct 70 ms 6000 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 2 ms 492 KB Ok
7 Correct 34 ms 3308 KB Ok
8 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 318 ms 23520 KB Ok
2 Correct 310 ms 23264 KB Ok
3 Correct 302 ms 23400 KB Ok
4 Correct 145 ms 11876 KB Ok
5 Correct 144 ms 11756 KB Ok
6 Correct 69 ms 6028 KB Ok
7 Correct 68 ms 6000 KB Ok
8 Correct 33 ms 3180 KB Ok
9 Correct 33 ms 3308 KB Ok
10 Correct 16 ms 1772 KB Ok
11 Correct 1 ms 364 KB Ok
12 Correct 1 ms 364 KB Ok
13 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 306 ms 23212 KB Ok
2 Correct 169 ms 11716 KB Ok
3 Correct 1 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 1 ms 364 KB Ok
7 Correct 8 ms 1004 KB Ok
8 Correct 144 ms 11756 KB Ok
9 Correct 70 ms 6000 KB Ok
10 Correct 1 ms 364 KB Ok
11 Correct 2 ms 492 KB Ok
12 Correct 34 ms 3308 KB Ok
13 Correct 1 ms 364 KB Ok
14 Correct 318 ms 23520 KB Ok
15 Correct 310 ms 23264 KB Ok
16 Correct 302 ms 23400 KB Ok
17 Correct 145 ms 11876 KB Ok
18 Correct 144 ms 11756 KB Ok
19 Correct 69 ms 6028 KB Ok
20 Correct 68 ms 6000 KB Ok
21 Correct 33 ms 3180 KB Ok
22 Correct 33 ms 3308 KB Ok
23 Correct 16 ms 1772 KB Ok
24 Correct 1 ms 364 KB Ok
25 Correct 1 ms 364 KB Ok
26 Correct 1 ms 364 KB Ok
27 Correct 309 ms 23380 KB Ok
28 Correct 146 ms 11896 KB Ok
29 Correct 311 ms 23520 KB Ok
30 Correct 16 ms 1772 KB Ok
31 Correct 1 ms 364 KB Ok
32 Correct 8 ms 1004 KB Ok
33 Correct 35 ms 3180 KB Ok
34 Correct 1 ms 364 KB Ok
35 Correct 1 ms 364 KB Ok
36 Correct 1 ms 364 KB Ok
37 Incorrect 1 ms 364 KB Output -1 while solution exists
38 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 144 ms 11756 KB Ok
2 Correct 310 ms 23272 KB Ok
3 Correct 304 ms 23264 KB Ok
4 Correct 16 ms 1772 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 33 ms 3180 KB Ok
7 Correct 309 ms 23648 KB Ok
8 Correct 1 ms 364 KB Ok
9 Correct 1 ms 364 KB Ok
10 Correct 1 ms 364 KB Ok
11 Correct 69 ms 6000 KB Ok
12 Correct 145 ms 11728 KB Ok