I started solving IOI,APIO,EJOI..... problems. And in 60%-70% of problems there is implementation details.For example. In that problem
This
Implementation details
You should implement one function (method):
int[] find_subset(int l, int u, int[] w)
l and u: the endpoints of the detection range,
w: weights of the molecules.
if the required subset exists, the function should return an array of indices
of molecules that form any one such subset. If there are several correct
answers, return any of them.
if the required subset does not exist, the function should return an empty
array.
For the C language the function signature is slightly different:
int find_subset(int l, int u, int[] w, int n, int[] result)
n: the number of elements in w (i.e., the number of molecules),
the other parameters are the same as above.
instead of returning an array of indices (as above), the function should
write the indices to the first cells of array result and then return .
if the required subset does not exist, the function should not write anything
to the result array and it should return .
Your program may write the indices into the returned array (or to the result array
in C) in any order.
[l, u]
l u
n w0,…, wn−1
I = {i1,…,im}
l ≤ wi1 + … + wim ≤ u
l u
u − l ≥ wmax − wmin wmax = max(w0,…, wn−1)
wmin = min(w0,…, wn−1)
m
m m
0
2 / 2
Please use the provided template files for details of implementation in your
programming language.
And there is place:
And this
Sample grader The sample grader reads the input in the following format: line 1: integers , , . line 2: integers: .
What to do in such problems help please!
You should see a file called
grader.zip
below "Attachments" towards the right side of your screen. If you download and unzip that file, it will contain all the files you need. You simply have to navigate tocpp/molecules.cpp
and code your solution in that file (inside the function that has been declared for you, e.g. find_subset in this case).To test your code locally, you simply have to run compile_cpp.sh (you can do this by running
sh compile_cpp.sh
in the terminal) and enter the input according to the format described by the problem statement. (so you first input n, then l, then u, then the array w of n integers). You should never explicitly read input in your own solution, the input is given to you as a set of function parameters.Though personally, the provided
compile_cpp.sh
file never works properly for me, and I'm too lazy to figure out the reason, so I just delete the flag-static
from the file and it somehow works.