MidnightCodeCup's blog

By MidnightCodeCup, history, 13 months ago, In English

The Midnight Code Cup qualification round has ended. Thanks to all participants for giving it your best!

Final rankings are here: https://ranker.codeforces.com/ranklist/602915

Problem statements and materials are available here.

As we only accepted outputs for scoring, we’d love to learn about your solution approaches – please share in the comments!

This round would not have been possible without:

Thank you all!

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

| Write comment?
»
13 months ago, hide # |
 
Vote: I like it +36 Vote: I do not like it

Easy top1!!!

»
13 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

How to solve C2? Tried asking LLM, but I don't find a way to make them understand the code and teach me. Is it expected that the code should be understand by a human?

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it -51 Vote: I do not like it

    I think the contest rules you agreed to during the registration prohibit the use of AI? So it should be.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +18 Vote: I do not like it

    You can introduce your own debugging instructions into the provided code, even if you don't understand it in general. Understanding the structure (function positions and invocations) is enough for that.

    This way you can retrieve the list of those brute-forced "objects" that were considered "good" by the check function. Like this: https://pastebin.com/raw/pAbR5ZVh

    And then you can do "Guessforces". The answer is: these are trees of size n, colored in two colors, such that each subtree has |whiteCount — blackCount| <= 1.

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it +3 Vote: I do not like it

      Thanks!

      I also tried asking AI to help me insert the debug code, but failed that. Looks like I should do it myself after having a pretty high-level understanding of the code.

    • »
      »
      »
      13 months ago, hide # ^ |
      Rev. 2  
      Vote: I like it 0 Vote: I do not like it

      I spent a bit thinking how are ABC-strings related to the trees so you don't have to.

      Consider the string a traversal of a binary tree. A is left child, B is right child, C is a return to the parent. So AC or BC or AACBCC are cycle pathes that start from the root, go through different vertices and return you to the root. That's also why there are A+B = C in terms of number of occurrences.

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        It's indeed that cycle path, but A stands for a white vertex, and B stands for a black vertex.

  • »
    »
    13 months ago, hide # ^ |
    Rev. 4  
    Vote: I like it 0 Vote: I do not like it

    We had people being able to understand what's going on during testing, so that was intended plan for you:). I quite like darnley approach above too though.

    Essentially, when I was writing the Asm code I used similar built-in debug techniques to understand why it doesn't produce the answer I expect it should.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +28 Vote: I do not like it

    It's understandable by a human as well, I solved C1 and C2 by reading the asm code without ever running it (because I couldn't be bothered to install java). Maybe not the fastest way to do it.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Problem A testcase 1: How is 98.736+ points possible!?

»
13 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

Solution for C1 can be found on oeis, if you try to compute answers for 1 1 1, 2 2 2, 3 3 3, 4 4 4 input data and enter it as a sequence. Oeis link

whining

The fun part about getting partial points:

Test 1
Hint
Test 2
Test 6
Test 8

For C2, you can get 120 points by:

Spoiler
»
13 months ago, hide # |
 
Vote: I like it +18 Vote: I do not like it

B1 and B2 are simple, find a way to make the solution traverse as many wrong subsets as possible (about 2^23) before finding the optimal solution:

B1:

15
1 1
...
1 1
9 10

B2 (not the optimal but almost):

65
1 1
...
1 1
50 9

But I don't understand how to make B3 larger than 2^12, can somebody share some tips?

  • »
    »
    13 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    The knapsack problem is quite well-studied, so you may find some pointers in research papers. One particular author to note is David Pisinger, and one of his papers — with a very obvious name — lists a finite number of generators of difficult tests with small weights. Then it's up to you how to search in this space, but if you are lucky enough with the choice, even exhaustive search may bring some improvements over 2^12.

    P.S.: kudos to those who can find the real name of the algorithm behind B3.

  • »
    »
    13 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    I claimed that $$$w_i = v_i$$$ and $$$w_1 = \cdots = w_{n-1}$$$, found a decent test case with $$$9$$$ rows and small $$$W$$$ using simulated annealing, then I generalized it to more rows.

    Before that, I tried simulated annealing with no additional constraints but it gave bad results, then I started adding constraints which seemed reasonable.

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +3 Vote: I do not like it

C1: Guessforces. By using custom invocation, you can see the result of (about) $$$A+B+C \le 6$$$.

Inputs and Outputs

Now you'll find what the task itself is, from above testcases.

step 1
step 2
The task
  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I simply ask Gemini to solve it, lol.

    • »
      »
      »
      13 months ago, hide # ^ |
      Rev. 7  
      Vote: I like it 0 Vote: I do not like it

      That's frustrating and surprising really. I performed testing with chatgpt, dozens of iterations and it seemed conclusive chatgpt shouldn't work. Example: link.. There was some additional hardening to make it unlikely to ever happen.

      However, I was also thinking that's not end of it if people find a way to game C1 by either guessforces or chatgpt or other techniques, because having C1 solved diligently gives a huge boost to solving C2 because most things are literally the same. I think solving C1 with chatgpt actually hurted people's ability to solve C2.

»
13 months ago, hide # |
 
Vote: I like it -17 Vote: I do not like it

MidnightCodeCup Pick me as your wildcard entry, I promise I’m just the right amount of chaos

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +26 Vote: I do not like it

I can't wait for the OEIS CODE CUP world finals!!

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Thank you for the great contest, this was my first time participating in such a heuristic-ish contest and I loved every second of it!

I spent most of my time on problem A trying to deal with the IK solver, and I think I spent too much time on trying to integrate a generic one for the 3-link arm and not enough on actually working on cost optimization. I used a simulated annealing approach with two strategies randomly chosen at every step:

  1. 2-opt swapping (classic TSP strategy)
  2. parity swapping (choosing a different pair of angles for reaching a given strawberry)

And in the end I think I should've spent more time on looking at each test case more carefully to better fine-tune the strategies, especially on cases like test case 8.

  • »
    »
    13 months ago, hide # ^ |
    Rev. 3  
    Vote: I like it +10 Vote: I do not like it

    We just did a greedy solution instead (pick the next target so that the cost of changing the angle is minimal) and it worked pretty good. Also reused the 2-link arm solution for 3-link arms, just checking 1024 angles for the first link and then solving the rest.

»
13 months ago, hide # |
 
Vote: I like it +113 Vote: I do not like it

I think C1/C2 was interesting, but it was very unpleasant to have the VM in Kotlin with no prior notice of it. I don't have any Kotlin setup so I had to run it online which posed runtime and output restrictions. If it's not going to be an easily runnable language like Python, I don't see a reason not to notify people to set it up. I solved C2 about 3 minutes after the end so any slowdown definitely made a huge difference for us.

I know that it's done because Jetbrains is a sponsor, but it also sounds beneficial for them to have everyone set up a Kotlin environment. Now I will just have Kotlin nightmares instead :\

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +10 Vote: I do not like it

    Big thumbs up for this; I have literally spent more than an hour to install all the necessary stuff (apparently I had an outdated Kotlin version or w/e and the code did not want to compile/build). Great task, but giving an example Kotlin and recommending to run it locally would be fair, imo.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    The kotlin version of my local computer (a debian bookworm) is too old to run the code. After spending some time to find a way to upgrade it. I just came up that I can run the program in a docker.

    After random searching on dockerhub, I finally found this to be working.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +10 Vote: I do not like it

    +100 on this; I thought solving C2 20 minutes after the end was bad but I see it could have been way worse... I'm also fairly sure it took me longer than that to run the provided Kotlin code.

    This could have been a good opportunity to get people to try out Kotlin if done right; now I'll just have bad memories of it instead.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    +1 I was running a lot of inputs in custom invocation until I noticed the pattern and figured out the problem but it was quite slow.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    For me this was even funnier. I've read this part in the statement "the solution is written in assembly" and thought that the solution is literally written in assembly. So I've spent several minutes rereading the statement and redownloading zip archive trying to figure out why in the downloaded files there is only some Java-looking code (since I've never seen Kotlin before) and no ASM-looking code.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +8 Vote: I do not like it

    On ubuntu that's just snap install kotlin btw. And for windows/mac any LLM should give you a short instruction to get CLI version.

    I agree that installing it during the contest sucks. But tbh there is no real rule that you should use python/cpp, and using them just because everyone uses them will solidify them without any particular reason.

    My complain about having VM in Kotlin is that it's just an extra layer of abstraction without any particular add-on to the problem. I am not sure it's really possible to distribute an ASM code to everyone so everyone can run it, but my problem is that I need to study this specific machine to verify if my ASM intuition works or not. (and, well, i spent a while decomposing some parts of it).

    Also the single code file is not documented while for any ASM you can find information online. And LLM's are probably better with converting any ASM dialects than with custom emulator. There should be a better sweet spot, but I haven't done my research on that, maybe I'm wrong.

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    That is unfortunate and we apologize for the inconvenience. We will definitely provide better instructions next time.

    We hope you’ll give Kotlin another chance though :)

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Yeah, we are really sorry for this. We had an idea to ask you to do this, or suggest using play.kotlinlang.org, but last several days before the contest too many things were happening and it slipped from our minds :(.

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +9 Vote: I do not like it

pick team testuwuers (reirugan Friedrich Intellegent) as a wildcard! as a team of three (self-identified) anime girls, we will bring a very necessary demographic to the competition

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

hope there is a mirror for the finals!

»
13 months ago, hide # |
 
Vote: I like it +66 Vote: I do not like it

No programming language restrictions, but need to setup a Kotlin environment and run/debug/understand a Kotlin program :(

»
13 months ago, hide # |
 
Vote: I like it +20 Vote: I do not like it

That was really cool! Didn't know optimization contests could be fun for me too!

»
13 months ago, hide # |
 
Vote: I like it +20 Vote: I do not like it

Thank you, I got some really good IPSC vibes from the contest.

It was also interesting to observe that we got quite an amount of points by producing a very small amount of code (C1), or none at all (B1, B2).

»
13 months ago, hide # |
 
Vote: I like it +30 Vote: I do not like it

It is understandable that, given the vast number of qualified contestants (75), it is not a small expense, and we should not take it for granted that all the expenses will be covered.

But on the other hand, it is also disappointing that the main expense for contestants, flight tickets, are not covered (except top 3 teams and students), given the number of sponsors and previously mentioned that "aim to cover trip expenses for the finalists" in the rules and updates.

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +21 Vote: I do not like it

The restrictions on travel expenses are one issue, but it's still a bit difficult to understand why only two nights are covered when the event runs from the morning of one day to the afternoon of the next. Considering that participants might have to stay up all night, it seems a little tough for them, doesn't it? I do understand that accommodating 25 teams is quite a challenge.

»
13 months ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

On one hand, I actually feel relieved knowing that our team's flight tickets won't be covered after finding out that I would probably have to go to another country to apply for Serbian visa.

On the other hand, it feels a bit disappointed with how we've been communicated. I guess the organizers probably wanted to wait until the qualification concluded to estimate the cost they would need to cover (hence, the part "as many of the trip expenses for the finalists as possible"). Something like "we won't guarantee to cover all expenses for finalists" from the beginning would be more transparent.

»
11 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

For the folks who solved problem D in the finals, how did you approach it? We found the problem very interesting and weren’t able to make any use of LLMs to solve it (other than the first input).