import java.util.*; import java.io.*;
public class lyuboyn {
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
}
public static void main(String[] args) {
FastReader br=new FastReader();
int N=br.nextInt(); int K=br.nextInt(); int T=br.nextInt();
if((K&1)==0){
System.out.println("-1");return;
}
int[] cur=new int[1<<(K+1)];//Start with (K,K+1)
for (int i = 1; i < 1<<(K+1); i++) {
int j=0; while((i&(1<<j))==0){j++;}
cur[i]=((1<<(K+1))-1-cur[i-1])^(1<<j);
}
//System.out.println(Arrays.toString(cur));
for(int B=K+2; B<=N; B++){
int[] nxt=new int[1<<B];
nxt[1]=(1<<(B-1))+(1<<(K-1))-1;
for(int j=2; j<=(1<<(B-1)); j++){
nxt[j]=nxt[1]^cur[j-1];
}
for(int j=(1<<(B-1))+1; j<(1<<B); j++){
nxt[j]=cur[(1<<B)-j];
}
cur=new int[1<<B]; for(int i=0;i<(1<<B); i++) {cur[i]=nxt[i];}
}
//System.out.println(Arrays.toString(cur));
int st=Integer.parseInt(br.next(),2);
if(T==1){
for (int i = 0; i < (1<<N); i++) {
System.out.println(Integer.toString((1<<N)+(st^cur[i]),2).substring(1));
}
}else{
if(K==1 && N==2){
System.out.println(-1);return;
}
int sta=0;
for (int i = 0; i < (1<<N); i++) {
if(cur[i]==(1<<K)-4 || cur[i]==(1<<K)-1){
cur[i]+=cur[(i+2)%(1<<N)]; cur[(i+2)%(1<<N)]=cur[i]-cur[(i+2)%(1<<N)]; cur[i]-=cur[(i+2)%(1<<N)];
sta=(i+3)%(1<<N); break;
}
}
for (int i = 0; i < (1<<N); i++) {
System.out.println(Integer.toString((1<<N)+(st^cur[(sta+i)%(1<<N)]^cur[sta]),2).substring(1));
}
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
76 ms |
8936 KB |
The output is neither -1 nor the length of the answer |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
71 ms |
8556 KB |
Expected integer, but "0000" found |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
8556 KB |
Ok |
2 |
Correct |
71 ms |
8428 KB |
Ok |
3 |
Correct |
72 ms |
8620 KB |
Ok |
4 |
Correct |
72 ms |
8556 KB |
Ok |
5 |
Correct |
74 ms |
8680 KB |
Ok |
6 |
Correct |
71 ms |
8412 KB |
Ok |
7 |
Correct |
70 ms |
8428 KB |
Ok |
8 |
Correct |
74 ms |
8684 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1102 ms |
18996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
79 ms |
8684 KB |
Expected integer, but "0000000" found |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1092 ms |
18996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1102 ms |
18996 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1094 ms |
15320 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |