# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
173546 | 2020-01-04T14:59:51 Z | mosiashvililuka | "The Lyuboyn" code (IZhO19_lyuboyn) | C++14 | 1000 ms | 6052 KB |
#include<bits/stdc++.h> using namespace std; int a,b,c,d,e,n,k,t,p[(1<<19)],pi,cnt; string ss; bool bo[(1<<19)]; string totwo(int q){ string s; while(q>0){ if(q%2==0) s.push_back('0'); else s.push_back('1'); q/=2; } while(s.size()<n) s.push_back('0'); for(int h=0; h<s.size()/2; h++) swap(s[h],s[s.size()-h-1]); return s; } void dfsk(int q){ pi++; p[pi]=q; bo[q]=1; if(pi==(1<<n)){ cout<<(1<<n)<<endl; for(int h=1; h<=pi; h++) cout<<totwo(p[h])<<endl; exit(0); } for(int h=0; h<=(1<<n)-1; h++){ if(bo[h]==0&&__builtin_popcount((p[pi]^h))==k){ if(pi==(1<<n)-1&&__builtin_popcount((p[1]^h))!=k&&t==1) continue; dfsk(h); } } bo[q]=0; pi--; cnt++; if(cnt>=40){ cout<<-1; exit(0); } } int main(){ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>n>>k>>t; cin>>ss; int hj=0; for(int h=0; h<n; h++){ if(ss[h]=='1') hj+=(1<<h); } dfsk(hj); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | First number in answer is not x 1 2 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output -1 while solution exists |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 70 ms | 888 KB | Ok |
2 | Execution timed out | 1072 ms | 1020 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1077 ms | 5516 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output -1 while solution exists |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1051 ms | 6052 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1077 ms | 5516 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1074 ms | 1524 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |