Submission #338208

# Submission time Handle Problem Language Result Execution time Memory
338208 2020-12-22T17:33:49 Z KWang31 "The Lyuboyn" code (IZhO19_lyuboyn) Java 11
8 / 100
1000 ms 18556 KB
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){
            System.out.println(1<<N);
            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;
                }
            }
            System.out.println(1<<N);
            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));
                
                
            }
        }
    }
    
}
# Verdict Execution time Memory Grader output
1 Correct 73 ms 8448 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 77 ms 8480 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 74 ms 8660 KB Ok
2 Correct 78 ms 8668 KB Ok
3 Correct 74 ms 8556 KB Ok
4 Correct 71 ms 8552 KB Ok
5 Correct 74 ms 8684 KB Ok
6 Correct 73 ms 8684 KB Ok
7 Correct 74 ms 8428 KB Ok
8 Correct 71 ms 8512 KB Ok
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 18500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 82 ms 8480 KB Fail, not exactly k bits are different: line = 124
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1085 ms 18556 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 18500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 15416 KB Time limit exceeded
2 Halted 0 ms 0 KB -