On Luogu, currently only C++ is supported for submissions and evaluation, and it is not recommended to use C++14 (GCC 9) for submissions.
When submitting on Luogu, you do not need to include the library mentioned in the problem and configure anything. You only need to declare the functions from the problem at the beginning of your code as follows:
extern "C" long GetN(void);
extern "C" int Drift(long x, long y, long z);
extern "C" void Answer(long left, long right);
Farmer G has a large pasture-field surrounded by an electric fence. The fence consists of fenceposts and straight-line segments of wires where each segment connects two neighboring posts. The fence is obviously not self-crossing, i.e. no wire-segment crosses any other wire-segment. Farmer G had been informed that a new straight-line road will be built that might cross his field. He went to the field and noticed that the two endpoints of the road have already been marked by two posts, and . He realized that the line of the road splits the interior part of his pasture-field into several disjoint regions.
Farmer G wants to determine how many regions will form on both sides of the road. He finds that none of the fence-posts lay on the line of the road. Moreover, if a wire-segment intersects with the line of the road, then the intersection lays between the endpoints and .
Unfortunately, Farmer G has no instrument to measure the distance of two posts. He can only observe the orientation of the posts, i.e. he can walk to any post (recall that road endpoints are also posts) and, looking towards post , he can see whether a third post stands on his left, or on his right, or whether the three posts are collinear. Fortunately, farmer G has his laptop with him (as usual), so he can do even complex computations.

You are to write a program that computes the number of disjoint regions located on the left and on the right side of the planned road as the result of splitting the pasture-field by the road.
To perform queries, you are given a library with three operations:
Your program is not allowed to read or write files. Input and output is handled by the library.
Instruction for Pascal programmers: include the import statement
uses lookup;
in your source code.
Instructions for C/C++ programmers: use the directive
#include "lookup.h"
in your source code, create a project file in the task directory, add the files fence.c (fence.cpp), lookup.h and lookup.o into this project, and then compile and/or make your program. (Using Dev-C++ IDE, choose the Project/Project Options/Files menu, select the file lookup.o, unset "include in compilation" and set "include in linking").
Command line compilation:
gcc/g++ -O2 –static –o fence fence.c lookup.o -lm
You are provided with a toolset that contains the libraries both for WinXP and Linux. You can download it as a zip archive. Copy the appropriate library files into your task directory.
The toolset includes a test generator to produce the file fence.in containing valid random sample input. needs an integer input parameter, , the approximate number of fence-posts. If then also creates a postscript file fence.ps that visualizes the layout of the fence (you can view it using gsview or another postscript viewer). The generated test data is considerably different for even and odd s; try and see it! Warning: can not generate all possible inputs.
The solution submitted by will be written into the file fence.out.
You can also create your own input by creating a text file fence.in. The first line must contain four integers, the coordinates of the endpoints of the road. The second line must contain , the number of fence-posts. Each of the following lines must contain a pair of integers, (); the pair in line defines the coordinates of the fence-post labeled by .
lookup.ppu and lookup.o for WinXP and lookup.o for Linux.function GetN: longint;
function Drift(x, y, z: longint): integer;
procedure Answer(x, y: longint);
lookup.h, and lookup.olong GetN(void);
int Drift(long x, long y, long z);
void Answer(long left, long right);