| Task: | XOR |
| Sender: | PILIPOJAT!! |
| Submission time: | 2016-09-20 18:57:24 +0300 |
| Language: | Java |
| Status: | READY |
| Result: | WRONG ANSWER |
| test | verdict | time | |
|---|---|---|---|
| #1 | WRONG ANSWER | 0.10 s | details |
| #2 | WRONG ANSWER | 0.10 s | details |
| #3 | WRONG ANSWER | 0.10 s | details |
| #4 | WRONG ANSWER | 0.10 s | details |
| #5 | WRONG ANSWER | 0.11 s | details |
| #6 | WRONG ANSWER | 0.12 s | details |
| #7 | WRONG ANSWER | 0.10 s | details |
| #8 | WRONG ANSWER | 0.10 s | details |
| #9 | WRONG ANSWER | 0.11 s | details |
| #10 | WRONG ANSWER | 0.10 s | details |
| #11 | TIME LIMIT EXCEEDED | -- | details |
| #12 | TIME LIMIT EXCEEDED | -- | details |
| #13 | TIME LIMIT EXCEEDED | -- | details |
| #14 | TIME LIMIT EXCEEDED | -- | details |
| #15 | TIME LIMIT EXCEEDED | -- | details |
| #16 | TIME LIMIT EXCEEDED | -- | details |
| #17 | TIME LIMIT EXCEEDED | -- | details |
| #18 | TIME LIMIT EXCEEDED | -- | details |
| #19 | TIME LIMIT EXCEEDED | -- | details |
| #20 | TIME LIMIT EXCEEDED | -- | details |
| #21 | TIME LIMIT EXCEEDED | -- | details |
| #22 | TIME LIMIT EXCEEDED | -- | details |
| #23 | TIME LIMIT EXCEEDED | -- | details |
| #24 | TIME LIMIT EXCEEDED | -- | details |
| #25 | TIME LIMIT EXCEEDED | -- | details |
| #26 | TIME LIMIT EXCEEDED | -- | details |
| #27 | TIME LIMIT EXCEEDED | -- | details |
| #28 | TIME LIMIT EXCEEDED | -- | details |
| #29 | TIME LIMIT EXCEEDED | -- | details |
| #30 | TIME LIMIT EXCEEDED | -- | details |
| #31 | WRONG ANSWER | 0.10 s | details |
| #32 | WRONG ANSWER | 0.09 s | details |
Code
import java.util.*;
import java.io.*;
public class Main {
private static long sum = 0;
private static List<Long> shit = new ArrayList<Long>();
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
IO io = new IO();
List<Long> data = new ArrayList<Long>();
int nums = io.nextInt();
StringBuilder output = new StringBuilder();
for(int i = 0; i < nums; i++) {
int opcode = io.nextInt();
int parameter = io.nextInt();
if(opcode == 1) {
add(parameter, data);
} else {
output.append(check(parameter, data));
}
}
System.out.println(output.toString().substring(0, output.length() - 1));
}
public static void add(long parameter, List<Long> data) {
data.add(parameter);
if(sum == 0) {
sum = parameter;
} else {
sum ^= parameter;
}
if(sum != parameter) {
data.add(sum);
}
}
public static String check(long parameter, List<Long> data) {
if(parameter == 0) {
return "NO\n";
}
for(Long i : data) {
if(data.contains(i ^ parameter)) {
data.add(parameter);
return "YES\n";
}
}
return "NO\n";
}
private static class IO extends PrintWriter {
private InputStreamReader r;
private static final int BUFSIZE = 1 << 15;
private char[] buf;
private int bufc;
private int bufi;
private StringBuilder sb;
public IO() {
super(new BufferedOutputStream(System.out));
r = new InputStreamReader(System.in);
buf = new char[BUFSIZE];
bufc = 0;
bufi = 0;
sb = new StringBuilder();
}
private void fillBuf() throws IOException {
bufi = 0;
bufc = 0;
while(bufc == 0) {
bufc = r.read(buf, 0, BUFSIZE);
if(bufc == -1) {
bufc = 0;
return;
}
}
}
private boolean pumpBuf() throws IOException {
if(bufi == bufc) {
fillBuf();
}
return bufc != 0;
}
private boolean isDelimiter(char c) {
return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f';
}
private void eatDelimiters() throws IOException {
while(true) {
if(bufi == bufc) {
fillBuf();
if(bufc == 0) throw new RuntimeException("IO: Out of input.");
}
if(!isDelimiter(buf[bufi])) break;
++bufi;
}
}
public String next() {
try {
sb.setLength(0);
eatDelimiters();
int start = bufi;
while(true) {
if(bufi == bufc) {
sb.append(buf, start, bufi - start);
fillBuf();
start = 0;
if(bufc == 0) break;
}
if(isDelimiter(buf[bufi])) break;
++bufi;
}
sb.append(buf, start, bufi - start);
return sb.toString();
} catch(IOException e) {
throw new RuntimeException("IO.next: Caught IOException.");
}
}
public int nextInt() {
try {
int ret = 0;
eatDelimiters();
boolean positive = true;
if(buf[bufi] == '-') {
++bufi;
if(!pumpBuf()) throw new RuntimeException("IO.nextInt: Invalid int.");
positive = false;
}
boolean first = true;
while(true) {
if(!pumpBuf()) break;
if(isDelimiter(buf[bufi])) {
if(first) throw new RuntimeException("IO.nextInt: Invalid int.");
break;
}
first = false;
if(buf[bufi] >= '0' && buf[bufi] <= '9') {
if(ret < -214748364) throw new RuntimeException("IO.nextInt: Invalid int.");
ret *= 10;
ret -= (int)(buf[bufi] - '0');
if(ret > 0) throw new RuntimeException("IO.nextInt: Invalid int.");
} else {
throw new RuntimeException("IO.nextInt: Invalid int.");
}
++bufi;
}
if(positive) {
if(ret == -2147483648) throw new RuntimeException("IO.nextInt: Invalid int.");
ret = -ret;
}
return ret;
} catch(IOException e) {
throw new RuntimeException("IO.nextInt: Caught IOException.");
}
}
public long nextLong() {
try {
long ret = 0;
eatDelimiters();
boolean positive = true;
if(buf[bufi] == '-') {
++bufi;
if(!pumpBuf()) throw new RuntimeException("IO.nextLong: Invalid long.");
positive = false;
}
boolean first = true;
while(true) {
if(!pumpBuf()) break;
if(isDelimiter(buf[bufi])) {
if(first) throw new RuntimeException("IO.nextLong: Invalid long.");
break;
}
first = false;
if(buf[bufi] >= '0' && buf[bufi] <= '9') {
if(ret < -922337203685477580L) throw new RuntimeException("IO.nextLong: Invalid long.");
ret *= 10;
ret -= (long)(buf[bufi] - '0');
if(ret > 0) throw new RuntimeException("IO.nextLong: Invalid long.");
} else {
throw new RuntimeException("IO.nextLong: Invalid long.");
}
++bufi;
}
if(positive) {
if(ret == -9223372036854775808L) throw new RuntimeException("IO.nextLong: Invalid long.");
ret = -ret;
}
return ret;
} catch(IOException e) {
throw new RuntimeException("IO.nextLong: Caught IOException.");
}
}
public double nextDouble() {
return Double.parseDouble(next());
}
}
}
Test details
Test 1
Verdict: WRONG ANSWER
| input |
|---|
| 59 2 549796 1 797427 2 8267 2 94241 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| NO NO NO NO NO ... |
Test 2
Verdict: WRONG ANSWER
| input |
|---|
| 60 2 189273 2 88019 2 110069 1 611607 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| NO NO NO NO NO ... |
Test 3
Verdict: WRONG ANSWER
| input |
|---|
| 86 1 811855 1 110105 2 569085 1 805175 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| NO NO NO NO NO ... |
Test 4
Verdict: WRONG ANSWER
| input |
|---|
| 79 2 204680 2 479640 2 21734 1 822295 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| NO NO NO NO NO ... |
Test 5
Verdict: WRONG ANSWER
| input |
|---|
| 54 2 393529 2 508737 2 279234 1 610723 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| NO NO NO NO NO ... |
Test 6
Verdict: WRONG ANSWER
| input |
|---|
| 76 1 40087 1 746813 1 120910 2 1048513 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| NO NO NO NO NO ... |
Test 7
Verdict: WRONG ANSWER
| input |
|---|
| 73 1 96148 1 881120 1 414495 1 814692 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| NO NO NO NO NO ... |
Test 8
Verdict: WRONG ANSWER
| input |
|---|
| 93 2 458578 1 907441 2 406032 2 72125 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| NO NO NO NO NO ... |
Test 9
Verdict: WRONG ANSWER
| input |
|---|
| 66 1 256689 1 656847 1 204470 1 706678 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| NO NO NO NO NO ... |
Test 10
Verdict: WRONG ANSWER
| input |
|---|
| 90 1 806402 2 212552 2 588349 2 437562 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| NO NO NO NO NO ... |
Test 11
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 1 87911 1 254464 2 936765 2 177725 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 12
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 2 580798 2 711232 1 517084 1 706145 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 13
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 1 890696 1 736663 1 309693 1 877748 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 14
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 2 422535 2 915569 1 799087 1 640406 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 15
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 1 173418 2 945329 1 54964 2 617017 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 16
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 1 193460 2 476498 2 117697 1 176455 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 17
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 2 88645 2 524394 1 545883 2 906204 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 18
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 1 349059 2 820258 1 666916 1 821504 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 19
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 1 55427 1 389186 2 340527 1 451535 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 20
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 2 186 2 572852 2 279886 1 559531 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 21
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 1 759956 2 946637 2 781536 1 211151 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 22
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 2 898884 1 461135 1 129061 2 1011354 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 23
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 1 124677 2 379713 1 1034177 1 152116 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 24
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 2 280923 1 888416 1 301451 2 877860 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 25
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 2 239639 1 863577 2 825271 2 1030489 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 26
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 2 842792 1 280374 2 528173 2 902772 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 27
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 1 769700 2 786489 2 954187 2 213653 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 28
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 2 45666 2 742846 1 870697 2 824087 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 29
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 2 1010353 1 298819 1 946132 2 1017161 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 30
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 500000 2 195272 1 971250 1 118355 2 361142 ... |
| correct output |
|---|
| NO NO NO NO NO ... |
| user output |
|---|
| (empty) |
Test 31
Verdict: WRONG ANSWER
| input |
|---|
| 4 2 0 1 5 1 5 2 0 |
| correct output |
|---|
| NO YES |
| user output |
|---|
| NO NO |
Test 32
Verdict: WRONG ANSWER
| input |
|---|
| 3 2 0 1 0 2 0 |
| correct output |
|---|
| NO YES |
| user output |
|---|
| NO NO |
