# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
336365 | 2020-12-15T05:41:55 Z | tengiz05 | "The Lyuboyn" code (IZhO19_lyuboyn) | C++17 | 1000 ms | 2304 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #define all(x) (x).begin(), (x).end() #define pb push_back #define pii pair<int, int> #define ff first #define ss second #define PI acos(-1) #define ld long double const int mod = 1e9+7, N = 2e5+5; int msb(int val){return sizeof(int)*8-__builtin_clzll(val);} int T, n, m, k; string start; vector<string> v; vector<string> ans = {"-1"}; int pw; int toint(string s){ reverse(all(s)); int res = 0; int p=1; for(auto x : s){ res += (x-'0')*p; p*=2; }return res; } map<int, bool> used; int count(string &s1, string &s2){ int ans = 0; assert(s1.size() == s2.size()); for(int i=0;i<s1.size();i++){ if(s1[i] != s2[i])ans++; }return ans; } string tobin(int a){ string res; for(int i=0;i<n;i++){ res += a%2+'0'; a>>=1; }reverse(all(res)); return res; } void rec(int i=1){ if(i == (1<<n)){ for(int j=1;j<v.size();j++){ if(count(v[j-1], v[j]) != k)return; } if(T == 1)if(count(v[0], v.back()) != k)return; ans = v; return; } for(int d=0;d<(1<<n);d++){ if(used[d])continue; v.pb(tobin(d)); used[d] = true; rec(i+1); v.pop_back(); used.erase(d); } } void solve(int test_case){ int i, j; cin >> n >> k >> T; cin >> start; pw = 1; for(i=0;i<n;i++)pw*=2; used[toint(start)] = true; v.pb(start); rec(1); if(ans[0] == "-1"){ cout << -1 << '\n'; return; } cout << pw << '\n'; for(auto x : ans)cout << x << '\n'; return; } signed main(){ FASTIO; #define MULTITEST 0 #if MULTITEST int ___T; cin >> ___T; for(int T_CASE = 1; T_CASE <= ___T; T_CASE++) solve(T_CASE); #else solve(1); #endif return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 364 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1086 ms | 364 KB | Time limit exceeded |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1050 ms | 1768 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1065 ms | 2024 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1080 ms | 364 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1093 ms | 2148 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1065 ms | 2024 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1081 ms | 2304 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |