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

Method main

src/class148/FollowUp1.java:218–261  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

216 }
217
218 public static void main(String[] args) throws IOException {
219 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
220 StreamTokenizer in = new StreamTokenizer(br);
221 PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
222 in.nextToken();
223 int n = (int) in.nval;
224 in.nextToken();
225 int m = (int) in.nval;
226 for (int i = 1, num; i <= n; i++) {
227 in.nextToken();
228 num = (int) in.nval;
229 add(num);
230 }
231 int lastAns = 0;
232 int ans = 0;
233 for (int i = 1, op, x; i <= m; i++) {
234 in.nextToken();
235 op = (int) in.nval;
236 in.nextToken();
237 x = (int) in.nval ^ lastAns;
238 if (op == 1) {
239 add(x);
240 } else if (op == 2) {
241 remove(x);
242 } else if (op == 3) {
243 lastAns = rank(x);
244 ans ^= lastAns;
245 } else if (op == 4) {
246 lastAns = index(x);
247 ans ^= lastAns;
248 } else if (op == 5) {
249 lastAns = pre(x);
250 ans ^= lastAns;
251 } else {
252 lastAns = post(x);
253 ans ^= lastAns;
254 }
255 }
256 out.println(ans);
257 clear();
258 out.flush();
259 out.close();
260 br.close();
261 }
262
263}

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected