Submission #19513227


Source Code Expand

Copy
import java.util.*;
import java.io.*;
 
public class Main {
    static FastScanner sc = new FastScanner(System.in);
    static PrintWriter pw = new PrintWriter(System.out);
    static StringBuilder sb = new StringBuilder();
    public static void main(String[] args) throws Exception {
        int n = sc.nextInt();
        int[] a = sc.nextIntArray(n);
        int xor = 0;
        for(int i = 0; i < n; i++) xor ^= a[i];
        if(xor != 0){
            pw.println(-1);
        }else{
            sb.append(0).append("\n");
            for(int i = 1; i < n-1; i++){
                int now = a[i] ^ a[i+1];
                sb.append(now).append("\n");
            }
            sb.append(a[n-1]).append("\n");
            pw.print(sb.toString());
        }
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
        
        public static void save_sort(long[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static long[] shuffle(long[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                long randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

class pair implements Comparable<pair> {
    long x;
    long y;

    public pair(long x, long y) {
        this.x = x;
        this.y = y;
    }

    public String toString() {
        return x + " " + y;
    }

    public boolean equals(Object o) {
        if (o instanceof pair) {
            pair p = (pair) o;
            return p.x == x && p.y == y;
        }
        return false;
    }

    public int hashCode() {
        return new Double(x).hashCode() * 31 + new Double(y).hashCode();
    }

    public int compareTo(pair other) {
        if (this.x == other.x) {
            return Long.compare(this.y, other.y);
        }
        return Long.compare(this.x, other.x);
    }
}

class tuble implements Comparable<tuble> {
    int x;
    int y;
    int z;

    public tuble(int x, int y, int z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    public String toString() {
        return x + " " + y + " " + z;
    }

    public boolean equals(Object o) {
        if (o instanceof tuble) {
            tuble p = (tuble) o;
            return p.x == x && p.y == y && p.z == z;
        }
        return false;
    }

    public int hashCode() {
        return new Double(x).hashCode() * 31 + new Double(y).hashCode() + new Double(z).hashCode() * 31 * 31;
    }

    public int compareTo(tuble other) {
        if (this.x == other.x) {
            if (this.y == other.y) {
                return this.z - other.z;
            }
            return this.y - other.y;
        } else {
            return this.x - other.x;
        }
    }
}

Submission Info

Submission Time
Task B - Your Numbers are XORed...
User shojin_pro
Language Java (OpenJDK 1.8.0)
Score 0
Code Size 5259 Byte
Status WA
Exec Time 221 ms
Memory 45716 KB

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 10
WA × 13
Set Name Test Cases
All subtask0_sample-01.txt, subtask0_sample-02.txt, subtask0_sample-03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt
Case Name Status Exec Time Memory
subtask0_sample-01.txt AC 75 ms 25400 KB
subtask0_sample-02.txt AC 72 ms 25216 KB
subtask0_sample-03.txt AC 74 ms 25188 KB
subtask1_01.txt WA 76 ms 25112 KB
subtask1_02.txt WA 71 ms 25260 KB
subtask1_03.txt WA 67 ms 25368 KB
subtask1_04.txt WA 71 ms 25436 KB
subtask1_05.txt AC 75 ms 25128 KB
subtask1_06.txt AC 74 ms 25272 KB
subtask1_07.txt WA 76 ms 25480 KB
subtask1_08.txt AC 82 ms 25776 KB
subtask1_09.txt WA 119 ms 28132 KB
subtask1_10.txt WA 146 ms 33044 KB
subtask1_11.txt WA 173 ms 37700 KB
subtask1_12.txt AC 141 ms 35352 KB
subtask1_13.txt AC 160 ms 37552 KB
subtask1_14.txt WA 203 ms 45716 KB
subtask1_15.txt AC 173 ms 40612 KB
subtask1_16.txt WA 191 ms 41648 KB
subtask1_17.txt WA 215 ms 45272 KB
subtask1_18.txt AC 177 ms 40284 KB
subtask1_19.txt WA 217 ms 44344 KB
subtask1_20.txt WA 221 ms 44384 KB