//
// A.cpp
// torelax
//
// Created by Rakhman on 1/5/21.
//
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer {cout << "NO"; exit(0);}
#define FOR(i, start, finish, k) for(llong i = start; i <= finish; i += k)
const long long mxn = 1e6 + 110;
const long long mnn = 3e3 + 2;
const long long mod = 1e9 + 7;
const long long inf = 1e18;
const long long OO = 1e9 + 100;
typedef long long llong;
typedef unsigned long long ullong;
using namespace std;
int n, k, t, cnt = 0;
bool used[(1 << 18) + 100];
vector<int> trap;
vector<int> ans;
int to_dec(string s){
int ans = 0;
while(s.size()) {
ans = ans * 2 + s.back()-'0';
s.pop_back();
}
return ans;
}
void outt(int x){
for(int j = n- 1; j >= 0; j--){
if(((1 << j) & x)){
cout << 1;
}else{
cout << 0;
}
}
cout << nl;
}
void rec(int cur){
used[cur] = 1;
cnt++;
ans.push_back(cur);
if(cnt == (1 << n)){
cout << ans.size() << nl;
for(int i = 0; i < ans.size(); i++){
outt(ans[i]);
}
exit(0);
}
for(int i = 0; i < trap.size(); i++){
int lol = trap[i];
if(!used[lol ^ cur]) {
rec(lol ^ cur);
}
}
}
int main() {
cin >> n >> k >> t;
string s;
cin >> s;
int x = to_dec(s);
for(int i = 1; i < (1 << n); i++){
if(__builtin_popcount(i) == k){
trap.push_back(i);
}
}
rec(x);
}
Compilation message
lyuboyn.cpp: In function 'void rec(int)':
lyuboyn.cpp:84:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
84 | for(int i = 0; i < ans.size(); i++){
| ~~^~~~~~~~~~~~
lyuboyn.cpp:89:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
89 | for(int i = 0; i < trap.size(); i++){
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
First number in answer is not x 1 2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
620 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
303 ms |
23264 KB |
Ok |
2 |
Correct |
140 ms |
11620 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Correct |
0 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Ok |
2 |
Correct |
7 ms |
1004 KB |
Ok |
3 |
Correct |
141 ms |
11664 KB |
Ok |
4 |
Correct |
66 ms |
5992 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
6 |
Correct |
2 ms |
492 KB |
Ok |
7 |
Correct |
31 ms |
3180 KB |
Ok |
8 |
Correct |
1 ms |
364 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
301 ms |
23264 KB |
First number in answer is not x 44202 87252 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
303 ms |
23264 KB |
Ok |
2 |
Correct |
140 ms |
11620 KB |
Ok |
3 |
Correct |
1 ms |
364 KB |
Ok |
4 |
Correct |
0 ms |
364 KB |
Ok |
5 |
Correct |
1 ms |
364 KB |
Ok |
6 |
Correct |
0 ms |
364 KB |
Ok |
7 |
Correct |
7 ms |
1004 KB |
Ok |
8 |
Correct |
141 ms |
11664 KB |
Ok |
9 |
Correct |
66 ms |
5992 KB |
Ok |
10 |
Correct |
1 ms |
364 KB |
Ok |
11 |
Correct |
2 ms |
492 KB |
Ok |
12 |
Correct |
31 ms |
3180 KB |
Ok |
13 |
Correct |
1 ms |
364 KB |
Ok |
14 |
Incorrect |
301 ms |
23264 KB |
First number in answer is not x 44202 87252 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
164 ms |
11620 KB |
First number in answer is not x 92826 45741 |
2 |
Halted |
0 ms |
0 KB |
- |