MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / main

Method main

src/class152/FollowUp1.java:137–179  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

135 }
136
137 public static void main(String[] args) throws IOException {
138 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
139 StreamTokenizer in = new StreamTokenizer(br);
140 PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
141 in.nextToken();
142 int n = (int) in.nval;
143 in.nextToken();
144 int m = (int) in.nval;
145 for (int i = 1, num; i <= n; i++) {
146 in.nextToken();
147 num = (int) in.nval;
148 add(num);
149 }
150 int lastAns = 0;
151 int ans = 0;
152 for (int i = 1, op, x; i <= m; i++) {
153 in.nextToken();
154 op = (int) in.nval;
155 in.nextToken();
156 x = (int) in.nval ^ lastAns;
157 if (op == 1) {
158 add(x);
159 } else if (op == 2) {
160 remove(x);
161 } else if (op == 3) {
162 lastAns = rank(x);
163 ans ^= lastAns;
164 } else if (op == 4) {
165 lastAns = index(x);
166 ans ^= lastAns;
167 } else if (op == 5) {
168 lastAns = pre(x);
169 ans ^= lastAns;
170 } else {
171 lastAns = post(x);
172 ans ^= lastAns;
173 }
174 }
175 out.println(ans);
176 out.flush();
177 out.close();
178 br.close();
179 }
180
181}

Callers

nothing calls this directly

Calls 9

addMethod · 0.95
removeMethod · 0.95
rankMethod · 0.95
indexMethod · 0.95
preMethod · 0.95
postMethod · 0.95
printlnMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected