Submission #151252

#TimeUsernameProblemLanguageResultExecution timeMemory
151252andrew"The Lyuboyn" code (IZhO19_lyuboyn)C++17
3 / 100
961 ms2520 KiB
#include <bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("-O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #define fi first #define se second #define p_b push_back #define pll pair<ll,ll> #define pii pair<int,int> #define m_p make_pair #define all(x) x.begin(),x.end() #define sset ordered_set #define sqr(x) (x)*(x) #define pw(x) (1ll << x) using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; const ll MAXN = 1123456; const ll N = 2e5; mt19937_64 rnd(chrono::system_clock::now().time_since_epoch().count()); template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template <typename T> void vout(T s){cout << s << endl;exit(0);} ll Val(string s){ ll ans = 0; for(auto i : s){ ans *= 2; ans |= i - '0'; } return ans; } ll n; string Fst(ll x){ string ans; for(int i = n - 1; i >= 0; i--){ if((x & pw(i))){ ans += "1"; }else ans += "0"; } return ans; } ll kol(ll a, ll b){ ll ans = 0; for(int i = 0; i < n; i++){ if((a & pw(i)) != (b & pw(i)))ans++; } return ans; } int main(){ ios_base :: sync_with_stdio(0); cin.tie(0); ll k, t; cin >> n >> k >> t; vector <ll> a(pw(n)); for(int i = 0; i < pw(n); i++)a[i] = i; string st; cin >> st; ll s = Val(st); swap(a[0], a[s]); while(clock() / (double)CLOCKS_PER_SEC < 0.95){ shuffle(a.begin() + 1, a.end(), rnd); bool bad = 0; for(int i = 1; i < pw(n); i++){ if(kol(a[i], a[i - 1]) != k)bad = 1; } if(bad)continue; if(t && kol(a.back(), a[0]) != k)continue; cout << pw(n) << "\n"; for(auto i : a){ cout << Fst(i) << "\n"; } return 0; } vout(-1); 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...