- The task is to construct a polygonal containment field to capture a maximum value of cystals while avoiding void mines as much as possible
- This is an NP hard problem and we have tried to find an optimal solution using kadane and dynamic programming
- C++ compiler (g++ recommended)
- Make sure you have C++11 or higher
To compile the program, use the following command:
g++ -o program 57_optimization_code.cppIf you need to specify a specific C++ standard, use:
g++ -std=c++11 -o program 57_optimization_code.cppAfter compilation, run the program using:
./programYou will have to enter the number of test cases in the terminal when asked to.
The program will:
- Read data from all input files
- Process the grid data
- Generate output in separate output files
- Display results in the console
Input files must be named as "input00.txt", "input01.txt" and so on.
Each input file should contain:
- First line: Number N (integer)
- Next N lines: Three space-separated integers (x, y, value)
- Then: Number M (integer)
- Next M lines: Three space-separated integers (x, y, value) Make sure that the input files are in the same directory as the code file
If you encounter errors:
- Check if the input file exists and is correctly formatted
- Ensure you have write permissions in the directory (for output files)
- Make sure you're using a compatible C++ version
The program uses large vectors (10000 x 10000), ensure your system has sufficient memory.