Submission #155685

#TimeUsernameProblemLanguageResultExecution timeMemory
155685qkxwsm"The Lyuboyn" code (IZhO19_lyuboyn)C++14
100 / 100
280 ms6472 KiB
#include <bits/stdc++.h> using namespace std; template<class T, class U> void ckmin(T &a, U b) { if (a > b) a = b; } template<class T, class U> void ckmax(T &a, U b) { if (a < b) a = b; } #define MP make_pair #define PB push_back #define LB lower_bound #define UB upper_bound #define fi first #define se second #define FOR(i, a, b) for (auto i = (a); i < (b); i++) #define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--) #define SZ(x) ((int) ((x).size())) #define ALL(x) (x).begin(), (x).end() #define MAXN 300013 typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vpi; typedef vector<pll> vpl; int N, K; bool T; int st; int ans[MAXN]; vi arr; bitset<MAXN> vis; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N >> K >> T; string temps; cin >> temps; reverse(ALL(temps)); while(SZ(temps) < N) { temps += '0'; } reverse(ALL(temps)); FOR(i, 0, N) { st *= 2; st += (temps[i] == '1'); } //find N linearly independent vectors vis[0] = true; FOR(i, 0, (1 << N)) { if (__builtin_popcount(i) != K) continue; if (vis[i]) continue; arr.PB(i); FOR(j, 0, (1 << N)) { if (vis[j] || vis[j ^ i]) { vis[j] = true; vis[i] = true; } } } if (SZ(arr) != N) { cout << "-1\n"; return 0; } // cerr << "HEY\n"; FOR(i, 1, (1 << N)) { ans[i] = __builtin_ctz(i); } FOR(i, 1, (1 << N)) { ans[i] = arr[ans[i]]; } // FOR(i, 0, N) // { // cerr << arr[i] << ' '; // } // cerr << endl; ans[0] = st; FOR(i, 1, (1 << N)) { ans[i] ^= ans[i - 1]; } vis.reset(); FOR(i, 0, (1 << N)) { if (vis[ans[i]]) { cout << "-1\n"; return 0; } assert(!vis[ans[i]]); // cerr << ans[i] << ' '; vis[ans[i]] = true; } // cerr << endl; cout << (1 << N) << '\n'; FOR(i, 0, (1 << N)) { FORD(j, N, 0) { cout << ((ans[i] & (1 << j)) ? 1 : 0); } cout << '\n'; } return 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...