Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
46 lines (40 loc) · 1.63 KB

File metadata and controls

46 lines (40 loc) · 1.63 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution1 {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner in = new Scanner(System.in);
// Create a list, seqList, of N empty sequences, where each sequence is indexed from 0
// to N -1. The elements within each of the sequences also use 0-indexing.
int N = in.nextInt();
N = (N > (10^5)) ? 10^5 - 1 : N;
int Q = in.nextInt(); // Number of Queries
Q = (Q > (10^5)) ? 10^5 - 1: Q;
List<List<Integer>> seqList = new ArrayList<List<Integer>>(N);
for (int i = 0; i < N; i++) {
seqList.add(new ArrayList<Integer>(N));
}
// Create an integer, lastAnswer, and initialize it to 0
int lastAnswer = 0;
for (int i = 0; i < Q; i++) {
int queryType = in.nextInt();
int x = in.nextInt();
x = (x > (10^9)) ? (10^9 -1) : x;
int y = in.nextInt();
y = (y > (10^9)) ? (10^9 -1) : y;
if(queryType == 1) {
int seqIndex = (x^lastAnswer)%N;
List<Integer> seqElement = seqList.get(seqIndex);
seqElement.add(new Integer(y));
} else if(queryType == 2) {
int seq = (x^lastAnswer)%N;
int element = y%(seqList.get(seq).size());
lastAnswer = seqList.get(seq).get(element);
System.out.println(lastAnswer);
}
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.