Submission #1000716
Source Code Expand
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskC solver = new TaskC(); solver.solve(1, in, out); out.close(); } static class TaskC { public void solve(int testNumber, InputReader in, PrintWriter out) { int n = in.nextInt(); int[] arr = new int[n]; int curxor = 0; for (int i = 0; i < n; i++) { int x = in.nextInt(); curxor ^= x; arr[i] = x ^ (x - 1); } if (curxor == 0) { out.println(0); } int count = 0; for (int i = 0; i < 60; i++) { for (int j = 0; j < n; j++) { if ((curxor ^ arr[j]) < curxor) { curxor ^= arr[j]; count++; } } } if (curxor == 0) { out.println(count); } else { out.println(-1); } } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }
Submission Info
Submission Time | |
---|---|
Task | C - Cheating Nim |
User | lewin |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 2434 Byte |
Status | WA |
Exec Time | 259 ms |
Memory | 23800 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 | 8404 KB |
001.txt | AC | 100 ms | 8400 KB |
002.txt | WA | 247 ms | 23596 KB |
003.txt | WA | 202 ms | 17872 KB |
004.txt | AC | 196 ms | 16788 KB |
005.txt | AC | 191 ms | 15320 KB |
006.txt | WA | 242 ms | 23348 KB |
007.txt | WA | 230 ms | 23356 KB |
008.txt | WA | 247 ms | 23356 KB |
009.txt | WA | 255 ms | 23584 KB |
010.txt | WA | 247 ms | 23420 KB |
011.txt | WA | 240 ms | 23452 KB |
012.txt | WA | 246 ms | 23000 KB |
013.txt | WA | 252 ms | 22804 KB |
014.txt | WA | 249 ms | 23572 KB |
015.txt | WA | 259 ms | 23500 KB |
016.txt | AC | 238 ms | 23632 KB |
017.txt | AC | 246 ms | 23620 KB |
018.txt | WA | 233 ms | 23368 KB |
019.txt | WA | 242 ms | 23800 KB |
020.txt | AC | 236 ms | 23568 KB |
021.txt | AC | 149 ms | 12368 KB |
022.txt | AC | 160 ms | 12100 KB |
023.txt | AC | 257 ms | 23168 KB |
example0.txt | AC | 97 ms | 8400 KB |
example1.txt | AC | 95 ms | 8400 KB |