Submission #370639

#TimeUsernameProblemLanguageResultExecution timeMemory
370639Kevin_Zhang_TW"The Lyuboyn" code (IZhO19_lyuboyn)C++17
100 / 100
274 ms7836 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV 
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T L, T R) { while (L != R) cerr << *L << " \n"[next(L) == R], ++L; }
#else
#define DE(...) 0
#define debug(...) 0
#endif
 
const int MAX_N = 18, MAX_M = 1<<MAX_N;
 
int N, K, T, S;
int nxt[MAX_M];
 
void ob(int x) {
	for (int i = N-1;i >= 0;--i)
		cout << (x>>i&1);
	cout << '\n';
}
 
vector<int> xo;
int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> N >> K >> T;
	{
		string v;
		cin >> v;
		DE(v);
		for (char i : v) 
			S = (S<<1) | (i-'0');
		DE(S);
	}
 
	for (int i = 0;i < 1<<N;++i)
		if (__builtin_popcount(i) == K)
			xo.pb(i);
 
	vector<int> per;
 
	int ind = 0;
 
	vector<int> vis(1<<N);
	for (int i = 0, x = 0;i < 1<<N;++i) {
		per.pb(x);
		vis[x] = true;
		for (int u : xo) 
			if (!vis[x ^ u]) {
				x ^= u;
				break;
			}
		if (x == per.back()) break;
	}
 
	if (per.size() != (1<<N)) return puts("-1"), 0;
 
	cout << per.size() << '\n';
	for (int u : per)
		ob(u ^ S);
}

Compilation message (stderr)

lyuboyn.cpp: In function 'int32_t main()':
lyuboyn.cpp:14:17: warning: statement has no effect [-Wunused-value]
   14 | #define DE(...) 0
      |                 ^
lyuboyn.cpp:36:3: note: in expansion of macro 'DE'
   36 |   DE(v);
      |   ^~
lyuboyn.cpp:14:17: warning: statement has no effect [-Wunused-value]
   14 | #define DE(...) 0
      |                 ^
lyuboyn.cpp:39:3: note: in expansion of macro 'DE'
   39 |   DE(S);
      |   ^~
lyuboyn.cpp:62:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   62 |  if (per.size() != (1<<N)) return puts("-1"), 0;
      |      ~~~~~~~~~~~^~~~~~~~~
lyuboyn.cpp:48:6: warning: unused variable 'ind' [-Wunused-variable]
   48 |  int ind = 0;
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...