I guess everyone has to learn this lesson once :)įinally, I was quite excited to come up with a cool solution for problem D inspired by the algorithm described in this post from 9 years ago (see the second solution to problem F). I've noticed that it did agree with my solution for C1 in debug mode, but it produced a different answer in release mode! I went on to debug this for around half an hour, could not find any issues, and finally noticed that compiling from the command line with g++ with optimization on (the release mode mentioned above was compiling with clang++ from within CLion) produces the correct answers, so I've used that to make my submission which turned out to be correct.Īfter the contest I discovered what the problem was using binary search on clang++ flags: in release mode, CLion (which inherits this behavior from CMake as I understand) passes -DNDEBUG flag, which makes assert(f()) statements not execute f() at all, and I've used assertions to verify that the elements that I try to erase from sets are actually found: assert(set.erase(x)). After implementing the solution for C2, I've tried to check it before submitting by feeding it the input from C1 augmented with many random changes. This was not the end of my fight with C++, however. With WSL2 /etc/security/nf does the trick. Do you know how to increase the stack size in the CLion+WSL+clang setup?ĮDIT: this has been resolved in comments, it turns out that I did not double-check enough and I had WSL1. So, I'm turning to the readers of my blog for help. I've found mentions that calling sudo prlimit -stack=unlimited -pid $$ ulimit -s unlimited would help, but it's not clear how to do it when I'm executing my program from within CLion, as I could not find a way to specify that some commands need to be run before my program. I've tried calling setrlimit from within my code, but it did not help either. I've found answers suggesting that the stack size can only be changed in WSL 2, and I double-checked that I do in fact have WSL 2. I've tried editing /etc/security/nf inside WSL, but that did not seem to have any effect. I've tried various compiler/linker flags such as -Wl,-stack_size and -Wl,-stack, but none of them worked. However, I'm still curious how to increase the stack size in my setup, which is CLion that uses WSL as the toolchain, compiling with clang++. In the end I just gave up and submitted by compiling with g++ in the command line (in hindsight, this decision should have come earlier). It seems that I have changed my setup compared to the last year, and now even about 15 minutes of googling during the round and another half an hour after the round did not help me find a way to increase the stack size in the new setup. First, I did run into the stack overflow issues that are a recurring topic for the Hacker Cup. This contest ended up being quite a struggle for me. Congratulations on the clear first place! I am assuming that you can install OpenGL on Ubuntu.Facebook Hacker Cup 2021 Round 2 narrowed the field to 500 qualifiers on Saturday ( problems, results, top 5 on the left, analysis). maroonrk was a lot faster than everybody else, and he also bravely skipped writing a dedicated solution for C1, submitting problem C2 first and then quickly adapting its solution for C1. # glut32.dll must be present in "project-directory/OpenGL/dll/"ĬOMMAND $) # linking opengl libraries to the project ![]() Include_directories(OpenGL/lib) # OpenGL/lib has to contain the required OpenGL's. Include_directories(OpenGL/include) # OpenGL/include has to contain the required OpenGL's. Project(Graphics_Offline_1) # Your Project Name If you can't, there are plenty of tutorials on youtube and StackOverflow. I am assuming you can setup OpenGL on windows. I am assuming that you can write basic OpenGL programs and you have written a file named Here, I am going to show you how to configure the CMakeLists.txt file to compile a OpenGL program which is the main challenge here. So, I am gonna put an end to this problem now and here. Apparently it's not so easy to find after all. ![]() I have made it work in both Windows 10 and Linux (Ubuntu 16.04) after a lot of searching on Google.
0 Comments
Leave a Reply. |