in‑page selection · template

Mini-Competition 3

Frog Jumping

I expect ALL of you to solve this trivial task.

Sample code: abs(A-B);

Mean

This is a normal task, but slightly harder than previous.

You should create an array to store the numbers.
Then, while inputting the numbers, calculate the sum.
calculate mean=sum/n.
Then, loop through the whole array, cnt+=(a[i]>=mean).

String Scramble

First, verify $S$ by directly scanning S[i]and S[S.size()-i-1].

DO NOT FORGET THE -1

Create a cnt, a pos, if not equal then let cnt++,pos=i
if flag is 0, then output 0.
else: if cnt >2, output -1
else: output pos+1

Hand In Your Homework

Please refer to this link for solution.

Double Elimination

For those who know priority_queue, this task should be trivial.
However, if you don't know, you can still get 88 points.
Looking at this problem, you know that you should maintain the previous position of insertion.
Therefore, create priority_queue,vector>,greater>> to sort coordinates according to the x cor then y cor.
Then, create a unordered_mapum to store the status of the number.
let input number be x. If um[x] is true, then we set it to 0, find pos in pq and set it to 0 also.

If um[x] is false, then set it to 1, find pos in pq and set it to the element. push into pq
Note that the priority_queue should initially store all vertex.?

Army

Please refer this link for solution.