Submission #1102229
Source Code Expand
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { PrintWriter out = new PrintWriter(System.out); new Main(new FastScanner(System.in), out); out.close(); } public Main(FastScanner in, PrintWriter out) { int N = in.nextInt(); int canTake = 0; int xor = 0; while (N-->0) { int v = in.nextInt(); xor ^= v; canTake |= v; } int res = 0; while (xor > 0) { int pos = Integer.highestOneBit(xor); if ((pos&canTake) > 0) { xor ^= pos|(pos-1); } else { out.println(-1); return; } res++; } out.println(res); } } class FastScanner{ private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; public FastScanner(InputStream stream) { this.stream = stream; } int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars){ curChar = 0; try{ numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } boolean isSpaceChar(int c) { return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1; } boolean isEndline(int c) { return c=='\n'||c=='\r'||c==-1; } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } String next(){ int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do{ res.appendCodePoint(c); c = read(); }while(!isSpaceChar(c)); return res.toString(); } String nextLine(){ int c = read(); while (isEndline(c)) c = read(); StringBuilder res = new StringBuilder(); do{ res.appendCodePoint(c); c = read(); }while(!isEndline(c)); return res.toString(); } }
Submission Info
Submission Time | |
---|---|
Task | C - Cheating Nim |
User | tehqin |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 2478 Byte |
Status | WA |
Exec Time | 200 ms |
Memory | 24296 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 97 ms | 8016 KB |
001.txt | AC | 95 ms | 8148 KB |
002.txt | AC | 191 ms | 23804 KB |
003.txt | AC | 160 ms | 17072 KB |
004.txt | WA | 163 ms | 15796 KB |
005.txt | WA | 153 ms | 13916 KB |
006.txt | AC | 170 ms | 23348 KB |
007.txt | AC | 167 ms | 23048 KB |
008.txt | AC | 168 ms | 23232 KB |
009.txt | AC | 172 ms | 23236 KB |
010.txt | AC | 169 ms | 23364 KB |
011.txt | AC | 169 ms | 23352 KB |
012.txt | AC | 168 ms | 23220 KB |
013.txt | AC | 170 ms | 23220 KB |
014.txt | AC | 169 ms | 23224 KB |
015.txt | AC | 200 ms | 24168 KB |
016.txt | WA | 171 ms | 23216 KB |
017.txt | WA | 172 ms | 23344 KB |
018.txt | AC | 170 ms | 23100 KB |
019.txt | AC | 170 ms | 23480 KB |
020.txt | WA | 170 ms | 23356 KB |
021.txt | WA | 128 ms | 9940 KB |
022.txt | AC | 129 ms | 10324 KB |
023.txt | WA | 195 ms | 24296 KB |
example0.txt | AC | 96 ms | 8144 KB |
example1.txt | AC | 97 ms | 8016 KB |