fbrunodr's blog

By fbrunodr, history, 5 days ago, In English

I got this message today from system:

Attention! Your solution 295598611 for the problem 2040C significantly coincides with solutions fbrunodr/295598611, gunjackk28/295637944. Such a coincidence is a clear rules violation. Note that unintentional leakage is also a violation. For example, do not use ideone.com with the default settings (public access to your code). If you have conclusive evidence that a coincidence has occurred due to the use of a common source published before the competition, write a comment to post about the round with all the details. More information can be found at http://mirror.codeforces.com/blog/entry/8790. Such violation of the rules may be the reason for blocking your account or other penalties. In case of repeated violations, your account may be blocked.

I use my personal laptop to code (so this is not unintentional leakage) and haven't provided my source code to anyone. The only thing I can think of is that someone abused the hacking feature of codeforces to leak my source code to a friend (as leaking their own source code would be to obvious, right?). The user who copied my code is gunjackk28 from India. He submitted the problem in the very last minute of the contest (01:59:05). Checking my room in the contest, only 3 other people got AC on the copied problem (problem C); one of them, HardikChoudhary, is also from India and got AC at (01:55:53), just 3 minutes before gunjackk28 submitted an exact copy of my source code. I think this is highly suspicious and should be investigated.

I never violated a single rule in codeforces and now I am being threatened to be blocked/banned because someone else cheated, this is completely unfair. I think the best solution in this case would be to remove the hacking during contest feature, as has already been suggested in another post.


Just before someone suggests it might be a coincidence, it is impossible in this case, as I use a highly specific .cpp file as template (which can be found in my GitHub). You can check the submissions here and see that there is no explanation other than the guy simply copied my source code:

My submission: https://mirror.codeforces.com/contest/2040/submission/295598611

gunjackk28 submission: https://mirror.codeforces.com/contest/2040/submission/295637944

Edit. 1: As some people have commented in this thread, it is impossible for HardikChoudhary to have leaked my code, as he did not lock problem C. That said I have no idea how this could have happened. I have already changed my password on Codeforces and I will just pray this won't repeat. I don't have any extensions set on my browser and all the extensions on my VScode are safe (either from Microsoft or with 1M+ downloads).

Edit. 2: This is especially disheartening was this was the first contest done on my new laptop (M3 MacBook) :(

Full text and comments »

  • Vote: I like it
  • +28
  • Vote: I do not like it

By fbrunodr, history, 2 weeks ago, In English

Problem to be addressed

On Linux it is pretty straightforward to set up the debugger for C++ on VSCode. The workflow is:

  • Write your code

  • Go to the [Run and Debug] VSCode section

  • Click on run active file or something similar

  • Debug your code

On macOS you will run into a lot of silly problems, such as:

  • Can't find #include<bits/stdc++.h>

  • Installed g++ and got the debugger running, buck can't write input to std::cin in the integrated terminal, because it says

Build finished successfully.
 *  Terminal will be reused by tasks, press any key to close it. 

and then closes the terminal, making it impossible to write to std::cin.

After some time browsing the internet I found the solution for all those problems and got my setup working just like on linux.

Solution

Let's brake the solution step by step, from a almost brand new macOS.

  1. Install Homebrew

  2. Install g++ (brew install gcc)

  3. Download VSCode

  4. Install C++ extension on VSCode

  5. On VSCode type ⌘+shift+p to open up the command palette. Then write C/C++ Edit Configurations (UI). A window will open up, then you must set Compiler path to /opt/homebrew/bin/g++-14 (or whatever version is installed; you can see the files inside the dir /opt/homebrew/bin/ by running ls /opt/homebrew/bin/ on your terminal and from there you can figure it out yourself). Still on this window set C++ standard to c++23 for latest features.

  6. Install extension CodeLLDB.

Okay, now let's say you created a /codeforces directory on your home, where you will run some c++ files. Inside this directory create a .vscode directory if one does not exist already. Then create a tasks.json file and put this code inside it:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++-14 build active file",
            "command": "/opt/homebrew/bin/g++-14",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "$$${fileDirname}/$$${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

The only purpose of this task called "C/C++: g++-14 build active file" is to build the c++ code in the current active file (as the name suggests).

In the same .vscode dir create another file called launch.json and write this code inside it:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug C++",
            "program": "$$${fileDirname}/$$${fileBasenameNoExtension}",
            "args": [],
            "cwd": "${fileDirname}",
            "preLaunchTask": "C/C++: g++-14 build active file",
        }
    ]
}

This prelaunch task is necessary, so it compiles the code before running it, otherwise you will have to compile and then run the debugger every single time, which is annoying and error prone. Also mind you that the name of the preLaunchTask is exactly the same as the label of the task we created previously, so be mindful if you change names.

After all that setup you should be able to go to your [Run and Debug] VSCode section and choose Debug C++, which will behave exactly like it did on linux.

If you have any questions feel free to ask!

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it