| Task: | Xor sum |
| Sender: | aalto26dm_027 |
| Submission time: | 2026-09-21 17:47:02 +0300 |
| Language: | Java |
| Status: | READY |
| Result: | TIME LIMIT EXCEEDED |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.06 s | details |
| #2 | TIME LIMIT EXCEEDED | -- | details |
Code
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class XorSum {
public static void main(String[] args) {
FastScanner input = new FastScanner(System.in);
int n = input.nextInt();
int q = input.nextInt();
int numbers[] = new int[n];
numbers[0] = input.nextInt();
for (int i = 1; i < n; i++){
numbers[i] = numbers[i-1] ^ input.nextInt();
}
int[] anwsers = new int[q];
for (int i = 0; i < q; i++){
int a = input.nextInt();
int b = input.nextInt();
if (a >= 2){
anwsers[i] = numbers[a-2] ^ numbers[b-1];
} else {
anwsers[i] = numbers[b-1];
}
}
for (int i = 0; i < q; i++){
System.out.println(anwsers[i]);
}
}
static 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 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;
}
}
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 8 36 7 6 4 6 2 9 4 8 1 1 1 2 1 3 ... |
| correct output |
|---|
| 7 1 5 3 1 ... |
| user output |
|---|
| 7 1 5 3 1 ... |
Test 2
Verdict: TIME LIMIT EXCEEDED
| input |
|---|
| 200000 200000 921726510 307633388 992247073 ... |
| correct output |
|---|
| 834756431 130379787 403037296 308618218 784778243 ... |
| user output |
|---|
| (empty) |
