# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
336377 | 2020-12-15T05:55:17 Z | tengiz05 | "The Lyuboyn" code (IZhO19_lyuboyn) | C++17 | 1000 ms | 94664 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(auto x : v)cout << x << ' ';cout << '\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; } int D = toint(v.back()); // cout << tobin(D) << '\n'; for(int j=0;j<n;j++){ int d = D; d ^= (1<<j); if(used[d])continue; v.pb(tobin(d)); used[d] = true; rec(i+1); v.pop_back(); used[d] = false; } } 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 | 1 ms | 364 KB | Ok |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 392 KB | Output -1 while solution exists |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1085 ms | 2408 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1100 ms | 94664 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1002 ms | 364 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1097 ms | 78280 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1100 ms | 94664 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1064 ms | 39396 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |