Submission #338210

# Submission time Handle Problem Language Result Execution time Memory
338210 2020-12-22T17:39:56 Z KWang31 "The Lyuboyn" code (IZhO19_lyuboyn) Java 11
36 / 100
464 ms 42736 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);
            StringBuilder sb=new StringBuilder();
            for (int i = 0; i < (1<<N); i++) {
                sb.append(Integer.toString((1<<N)+(st^cur[i]),2).substring(1)+"\n");
            }
            System.out.println(sb.toString());
        }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);
            StringBuilder sb=new StringBuilder();
            for (int i = 0; i < (1<<N); i++) {
                sb.append(Integer.toString((1<<N)+(st^cur[(sta+i)%(1<<N)]^cur[sta]),2).substring(1)+"\n");
            }
            System.out.println(sb.toString());
        }
    }
    
}
# Verdict Execution time Memory Grader output
1 Correct 113 ms 9708 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 110 ms 9580 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 74 ms 8428 KB Ok
2 Correct 72 ms 8668 KB Ok
3 Correct 75 ms 8668 KB Ok
4 Correct 75 ms 8624 KB Ok
5 Correct 74 ms 8556 KB Ok
6 Correct 70 ms 8528 KB Ok
7 Correct 73 ms 8556 KB Ok
8 Correct 73 ms 8556 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 457 ms 42736 KB Ok
2 Correct 402 ms 25548 KB Ok
3 Correct 159 ms 11580 KB Ok
4 Correct 116 ms 9580 KB Ok
5 Correct 116 ms 9600 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 9580 KB Fail, not exactly k bits are different: line = 124
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 464 ms 42492 KB Ok
2 Correct 463 ms 42536 KB Ok
3 Correct 461 ms 42536 KB Ok
4 Incorrect 401 ms 25368 KB Fail, not exactly k bits are different: line = 131068
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 457 ms 42736 KB Ok
2 Correct 402 ms 25548 KB Ok
3 Correct 159 ms 11580 KB Ok
4 Correct 116 ms 9580 KB Ok
5 Correct 116 ms 9600 KB Ok
6 Incorrect 117 ms 9580 KB Fail, not exactly k bits are different: line = 124
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 388 ms 23696 KB Ok
2 Correct 427 ms 39068 KB Ok
3 Correct 454 ms 41996 KB Ok
4 Correct 353 ms 15616 KB Ok
5 Correct 122 ms 9680 KB Ok
6 Correct 333 ms 15008 KB Ok
7 Correct 454 ms 42664 KB Ok
8 Correct 154 ms 11432 KB Ok
9 Correct 111 ms 9600 KB Ok
10 Correct 155 ms 11304 KB Ok
11 Correct 330 ms 16812 KB Ok
12 Correct 411 ms 24492 KB Ok