Kogut_Ivan's blog

By Kogut_Ivan, history, 18 months ago, translation, In English

Hello, Codeforces!

The TG channel team @KogutIvanTutoring is pleased to invite you to participate in Codeforces Round 1016 (Div. 3) on Apr/08/2025 17:35 (Moscow time) — another Codeforces round for the third division. This round will feature 7 problems selected in difficulty to create an interesting competition for participants with ratings up to 1600. However, anyone with a rating of 1600 or higher can register for the round out of competition.

The round will follow the rules of educational rounds. Thus, during the round, the problems will be tested on preliminary tests, and after the round, there will be a 12-hour phase of open hacking. After this phase, all successful attempts will be retested on successful hacks. We have tried to create decent tests — just like you, we will be disappointed if many solutions fail after the contest ends.

You will be offered 7 problems and 2 hours 15 minutes to solve them.

The penalty for an incorrect attempt in this round will be 10 minutes.

We remind you that only reliable participants of the third division will be included in the official results table. As stated in the link — this is a necessary measure to combat unsportsmanlike behavior. To qualify as a reliable participant of the third division, you must:

  • participate in at least five rated rounds (and solve at least one problem in each of them)
  • not have a rating point of 1900 or higher.

Regardless of whether you are a reliable participant of the third division or not, if your rating is below 1600, the round will be rated for you.

The problems were conceived and prepared by part of our team: fstilus, EzikBro, _icy_, Boodoochai, pskobx, gravitsapa

Also, a big thank you to:

Good luck to everyone!

UPD. Editorial is out!

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

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

As a tester, problems are very interesting!

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

As a tester, I can assure you that the problemset is interesting, and the round will be enjoyable.

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

cry disappeared

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

As a tester, you will enjoy solving the problems..

»
18 months ago, hide # |
Rev. 2  
Vote: I like it -23 Vote: I do not like it

why isn't there any grey(gray) testing of the round considering its div3?

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

Finally

Out-of-Competition

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

Finally excited for my first unrated contest

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

Yes, I’m ready to be back to CYAN, inshaAllah!

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

I'll try imitate rainboy in this round.

»
18 months ago, hide # |
 
Vote: I like it -11 Vote: I do not like it

As a tester, problems are very interesting!

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

hopefully my journey of ending failure will start from this contest

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

I am excited to participate with my new monitor set-up today..!

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

    And guess, what a CodeForces night I am having..! Solved 5 out of 7 problems within just 101 minutes, Siuuu..!

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

Why did this dude TrinhTranPhuongTuan banned? Cause he got top 1???

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

In G are the sample testcases correct?

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

first time ak div3! ヾ(^∀^)ノ

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

Perfecto

»
18 months ago, hide # |
 
Vote: I like it -10 Vote: I do not like it

I am never writing a div3 or div4 again.

»
18 months ago, hide # |
 
Vote: I like it -14 Vote: I do not like it

Although i didn't participate in this round, i've read the problems and i think it is one of the best div3s i remember

»
18 months ago, hide # |
Rev. 5  
Vote: I like it +4 Vote: I do not like it

The hardest div3 I have ever seen(for me)... can't solve G, get plenty on C E and F stuck on B for 10min, F for 1 hour, I'm too weak :(

So can anyone tell me how to solve G?

UPD: now I know why I can't solve G.

Well, I now know why I couldn't solve G. I was stuck on calculating the maximal dissimilarity group and kept thinking about the following:

maintains a ds such that it supports the following operations:

  • inserts an element
  • deletes an element
  • queries for the maximal value of the xor of each pair of elements in the set

But really, you just need to two pointer scan the array, and then deal with the contribution to the answer from the element currently pointed to by the right pointer, which is a classic 01-Trie problem. Regardless, the quality of the questions in this game was very high and I love it very much!

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

    I think perception makes a big difference. Specifically, I would probably normally spend more time than I did on F if my speed were on par. But I solved A-E very slowly because of mistakes and thus knew I had to get F quickly, so I did in 20 mins.

    To solve G, we use a trie to get the max xor, then iterate over l and find the nearest r to get that max xor value.

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

Is O(N * M * M) solution feasible in problem F ?? This is equivalent to 1e8 operations. One of the codes passed the TCs but I doubt about strength of TCs.

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

    Expected solution is in $$$O(n*m)$$$. Actually, F was easier than D, E, and even C in my opinion, because there is no edge case.

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

    yes.

    I overkilled F in O(n*m*m) although couldn't solve in contest courtesy to D.

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

Good quality problems. I made so many stupid mistakes lol and so I didn't get time for G, but I knew immediately that we can just use a trie to get the max XOR, then iterate over l and find the nearest r such that a[l]^a[r] = max_xor.

I do have one contention though -- tries in div 3 problems. It's not that tries are too difficult for div 3, but rather there are much better alternatives, like some graph problem or something. This is probably the third time I've seen a trie in div 3.

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

D was very wrong placed , i spend my entire time on d why there are lots of ac in d ??

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

    there are too many cheaters ...i looked at the number of submissions while i was solving c,i was dumbfounded -_-

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

      yes, you need some serious practice to solve d fast because there is very large scope of errors and i wonder people solving it very dammm fast

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

        although i couldnt solve D ,but a lot of people solved E before D , so i think the position of the problem wasn't right...and yeah people just solving the probs damn fast

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

    D is actually an easy problem, but i didn't want to write a dfs so i skipped it first, but i didn't realize the binary research at first so i wrote D 40 min later and then go to E. /Cry/

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

Why my 314649703 for E — Min Max MEX TLE?

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

    I haven't looked specifically at your code, but I got TLE 2 times before realizing that we should ensure we are only ever checking the predicate for mex values <= n/k, which will ensure a O(k*mex_val) predicate is O(n) at most.

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

    check my way of knowing mex till now -> intialize set and intialize mex with 0 and just do while(set.count(mex))mex++; and as u go left to right just add elements in set

»
18 months ago, hide # |
 
Vote: I like it -9 Vote: I do not like it

I wonder, don’t you have any testers to tell you that this contest is bad? I’d like to know what you were thinking when you included problems C and D. Problem E was much easier, except for the text of problem F. Are we here so you can test our ability to read English?

This contest was a waste of time.

When I’m not good at something, I leave it to someone else.

»
18 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it
4 5
a s k A
d s D t
O R i A
a X b Y
b a k A
u s k J  
why is answer to this 8 not 10
  • »
    »
    18 months ago, hide # ^ |
     
    Vote: I like it +8 Vote: I do not like it
    1. Choose 5.
    2. Choose 5.
    3. Choose 5.
    4. Choose 5. $$$(bakA)$$$
    5. Clear 1. $$$(*akA)$$$
    6. Choose 3. $$$(aakA)$$$
    7. Clear 2. $$$(a*kA)$$$
    8. Choose 5. $$$(askA)$$$
  • »
    »
    18 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it
    • Operation 1 on b a k A 4 times
    • Operation 2 on d s D t with $$$j=2$$$
    • Operation 1 on d s D t
    • Operation 2 on a X b Y with $$$j=1$$$
    • Operation 1 on a X b Y
  • »
    »
    18 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Set all c to the network 5 (u, s, k, J) => 4 ops

    Replace j = 1 (*, s, k, J) => 1

    Select network 3 (a, s, k, J) => 1

    Replace j = 4 (a, s, k, *) => 1

    Select network 2 (a, s, k, A) => 1

    total = 4 + 1 + 1 + 1 + 1 = 8

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

wtf was D bro I wasted 1.5hrs on it. I should have solved E before it was simple binary search

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

I feel like my solution for E is hackable because I used sets instead of arrays to track which elements have been filled so far. More than 1000ms in C++ is not good news...

Link to my submission

Hacks appreciated

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

E was easier than B

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

It was more of a div4 than a div3.

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

Why the authors in recent div3's have removed the notes section from problem statement $$$?$$$ In today's contest, there were no notes except for task $$$D$$$.

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

What is the corner case in G? I'm creating a trie of all seen numbers and searching as follows:

if k has this bit 0 and we can make this bit 1, then simply return the max index of any number seen so far that does so, otherwise continue down the tree.

if k has bit 1, make sure to take the branch which makes this bit 1, if there is no such branch, then return -1. If we reach end of the tree then return the max idx as we must have atleast matched the value of k.

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

    Lets say you are in position i currently, and looking for the j-th bit of v[i]. Assume that j-th bit of k is 0, then there is a chance to get xor value bigger than k. But in that case your program immediately returns biggest such position p1. Maybe there is index j2 < j, where j2-th bit of k is also zero and you have a chance to make xor bigger than k as well, and there is a position p2 > p1 which satisfies this conditoin. In that case you miss better answer of i-p2+1, and take just i-p1+1.

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

I read this probelm is very intersting but i found some cheater in this contest. How can report them?

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

In problem c, is there exist any prime number greater than 1000? someone pls help...:(

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

Problem D is litteraly to toxic to put in a D div 3 i think even G is more straight forward and easier than D (although i didn't solve G cause i ran out of time)

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

Why the problems dont have notes to explain the example test

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

nice Codeforces round!!!

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

Was problem $$$G$$$ solvable using Trie and two-pointers ?

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

Today's G was so similar to this problem: https://oj.uz/problem/view/IZhO12_xor

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

Here is my screencast of this contest along with the solution ideas and thought process: https://youtu.be/6suW6LZyYtY

I am planning to do more of these videos if my schedule allows it.

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

Lol this absolute bruteforce passed for C

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

what is the possibility that using unordered_map in E causes hack?

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

We have numerous "unexpected verdict" E hacks, which usually indicates std also fails lmao

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

    It's more likely that one of the testers' solution failed. It happens when anything that's marked as correct on Polygon fails, not just the main solution.

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

Hi friends, it was a good contest, thanks to all friends

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

Hoping to reach pupil after rating changes. Wasted too much time debugging D.

»
18 months ago, hide # |
 
Vote: I like it +10 Vote: I do not like it
Funny C thing, and why k <= 7
Extra Details
  • »
    »
    18 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    This is exactly what I found during the contest as well as I thought there must be some corner cases with n = 1. Fortunately, I later saw that k is restricted to just 7 and I could just use the naive is_prime routine for all cases.

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

      This is why I specifically mentioned "basic and direct bruteforce".

      This manages to run in polynomial time relative to the length of the number, rather than the expected exponential for the intended solution (which uses the fact that the number does not have to be iterated over.)

      I'm not sure if those bases alone are enough to catch the edge cases (since the solution is actually probabilistic in nature and is only guaranteed to work because of the usual compprog bounds) but this solution would in theory be able to catch the edge cases I mentioned. If k instead allows for the 4th edge case to happen (see the sequence for what k this is), you might need a slight improvement in the code to get this to work (or they need to set t <= 10). Either way, this version of the problem would be around Div3F because you either need to googleforces or run this optimized bruteforce.

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

    Here's a list of valid k's with x = 1

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

    didnt see the extra details, sorry

»
18 months ago, hide # |
Rev. 3  
Vote: I like it -10 Vote: I do not like it

Please make Div3 and Div4 contests unrated. Today, most of the D problem solvers used AI, and on the other hand, G was also solved by AI. With this rising amount of piracy, most of the noobs are just rushing for ratings.Or use some ide so that copying statement becomes impossible.

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

    Yeah, I tried it with claude after the contest got over. It solved the problem in one go.314662411

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

    D is a pure implementation problem, why would it have more AI usage than the other problems? G is also a very classic problem, you really don't need much to solve it (just knowing that pairwise xor problems sometimes can be solved using a trie is enough).

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

    I cannot understand arguments like this. Should we unrate div1 and div2s as well? LLMs can usually solve problems A through E in a div2, which is more than enough to carry anyone to master.

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

      I didn't mean to support the argument to unrate the div3 and div4, I was just agreeing on the part that D was solved by AI. I don't think we can do much about cheaters, we just can enjoy solving problems.

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

One of the best div3s <3

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

the writers of problems can't get the time complexity right and exclude wrong solution, but let others hack the accepted codes after contest, this is so rediculous

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

    I mean, I am doing ACM, not OI. If my solution is completely wrong in time complexity, I get penalty, not first "Accepted" but then "solved -1". Try to imagine that if a question tells you to calculate a * b, but you mistakenly put a + b. However all of tests of "a b" are "2 2" or "0 0", and you got accepted and didn't notice the mistake. Then after the contest, you code is hacked. Of course it's partly my own fault, but don't you think that's a little bit irresponsible?

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

how the hell did this submission get hacked? Isn't it n(logn)(logn) Link

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

    maybe not TLE but WA

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

    There are a lot of solutions using std::set<> or std::map<> getting hacked.

    Not sure what the case is exactly. The slowest case I can think of is $$$n=2×10^5$$$, $$$k=1$$$, $$$a = [0, 1, 2, 3, ..., n-1]$$$ but if I run your code locally it only takes like 800 ms.

    Maybe the CodeForces judging machines are especially slow when it comes to dynamic memory allocation or something like that.

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

      Yes exactly, at worst there are n elements in the map taking logn time and the binary search adds another log factor. 2×10⁵×(log(2×10⁵))²~~10⁷. Are the machines this slow?

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

        creating multiple sets requires more overhead space(setup cost is higher) as compared to creating single one storing it all, also using unordered_set was a much better choice over given n and max value of a[i].

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

          I just made a single map for each search, I can understand it is a bit inefficient but I looked at the boundaries and did not much care about these little things. Looking at the number of hacks in E, something seems wrong

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

      For reference, here is a similar submission but in python look at the difference in execution time

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

      While practicing problems on Codeforces, I’ve noticed that in some cases, especially when there are many duplicates, using set & map often gives better TC than unordered_set & unordered_map, so I’ve generally preferred them. However, in this contest's E, my solution got a TLE on test case 67 during internal testing, possibly due to test cases added through hacks. After system testing, I tried replacing set with unordered_set, and surprisingly, it got accepted. It felt a bit odd, and I’m still not entirely sure why that happened.

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

        std::unordered_set<> and std::unordered_map<> are backed by hashtables so insertion and deletion take $$$O(1)$$$ time on average, which is faster than std::set<> and std::map<>, which are backed by balanced binary search trees, which take $$$O(\log n)$$$ time on average.

        Usually the unordered variants are also faster in practice. However, the unordered versions are vulnerable to hacking due to hash collisions, see e.g. this blog post: https://codeforces.me/blog/entry/62393

        For this particular problem it's not really a concern, because the attack requires inserting elements that are a multiple of the bucket count, while in this problem, the elements of the set are smaller than the maximum size of the set, so the attacker cannot create many collision.

        However, in general, it's best to avoid using plain std::unordered_set<> and std::unordered_map<> in contests that allow hacking. (Or at least harden them with randomization as explained in the blog post.)

        Python doesn't suffer from this because its hash tables have randomization built in. Java's hash tables revert to using balanced search trees when too many keys collide, so e.g. HashMap eventually reverts to the performance of TreeMap in the worst case.

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

          So, in general, what's the thumb rule (or is it entirely constraint dependent) for these kinds of problems? I usually stick to using set and map instead of their unordered variants, but in this case it was topsy turvy.

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

            For this problem, you could just use a vector<char> or vector<bool> to mark elements which you've already seen.

            That's what I did: 314567229, search for can_solve().

            This technique is generally useful when you have a set or map where the keys are a small range of integers, or something that can easily be mapped to a small range of integers.

            You just have to be careful about how you initialize/clear the vector, since it can be larger than the input you are processing.

            For example, suppose you are given a problem where you get arrays of integers, and you have to output for each array how many distinct values it contains. It's easy to implement this with a std::set or std::unordered_set. But you can also maintain the set in a vector or bool array.

            C++ code

            The solution is strictly O(n) per case, and while that's technically the same as if you'd used a std::unordered_set<>, you'll find that it's much faster in practice because indexing an array has a significantly lower constant overhead than finding an entry in a hash table.

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

with due respect, problems $$$D$$$ is not a good problem

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

great contest, A-E were great, the only nitpick is that i wish D was placed at E

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

I have huge problems with Problem D...

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

Never saw such an easy F. Literally it was easier than C

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

I think future problem authors could notice a small problem.

When we think about the MEX of an array $$$a$$$ of length $$$n$$$, it is obvious that we only need to focus on value $$$a_i$$$, which is less than $$$n$$$.

So problems like E have no necessity to make $$$a_i\le 10^9$$$.

Some participants, like me, may ignore the range, using int c[200005] to save the occurrence of a value. And get RE as a result.

But I don't think this is an interesting thing.

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

    Nope,this is called coordinate condensation,and also a technique.Some problem like segmenttree/mo'algorithm also met the same problem,for n only up to 2e5 but the element up to 1e9 this require you using hashing technique

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

Could anyone please explain problem D? Spent so much time on it but still couldn't figure it out :( TIA

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

Auto comment: topic has been updated by Kogut_Ivan (previous revision, new revision, compare).

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

yehhh, this is a first contest i can clear on time

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

Got hacked in E

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

Who thought F should be F among the testers (and D be D). Meet me personally

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

Fucking E, set got TLE :)?

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

I personally found particularly D, F and G really fun and educational. Thank you :)

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

i feel F is the easiest of all C,D,E,F

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

E is exactly the type of codeforces question that makes me want to quit sometimes. I used a (properly randomized) set to keep track of items in the current subarray, and I got AC, with a runtime of 1700ms. I assumed that the test setters had created strong test cases, so I moved on to F, and after getting it I finished 180th in the contest. This morning, I found out that I had been hacked.
Apparently, the intended solution was to use a boolean array instead of set. However, both solutions worked during the contest, and they both have the optimal space/time complexity. Is there any way during the contest to figure out that a set is in fact slightly too slow, or is it just luck of the draw? Kogut_Ivan y'all need to make better testcases...

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

    no in div-3 you can't expect the perfect test cases , it test cases had to be perfect there would have been no point of hacking phase , as your solution(1700 ms) was too close to time limit , you should have optimised your solution during contest

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

      What's the point of having a time limit then? With the weak testcases they had, even a 1000ms solution wouldn't have been guaranteed to pass. If they're going to set the time limit low enough that a very natural solution to the problem (with the right space/time complexity) doesn't pass, they should at least make testcases that exclude that type of solution instead of letting us find out 10 hours later during the hacking phase, with no chance to correct our code.

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

Accidentally spotted very suspicious participant: https://codeforces.me/submissions/KS_star/contest/2093 Obfuscated code with names a,b,c,...: 314628685 314630580 314632645, and all solutions submitted within couple minutes

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

Problem D giving TLE in test case 4...can anyone help me with this recursive approach.

#include <bits/stdc++.h>
using namespace std;




long long solveCoords(int n, long long start,int row, int col, int& i, int& j,int len){
    if(n==1){
        if(row==i && col==j) return start;
        else if(row+1==i && col+1==j) return start+1;
        else if(row+1==i && col==j) return start+2;
        else return start+3;
    }

  
    long long total = len*len;
    long long subTotal = total/4;

    
    
    int x = len/2 -1;
    int y = len/2 -1;
    if(i<=row+x && j<=col+y) return solveCoords(n-1,start,row,col,i,j,len/2);

    x = len/2;
    y = len/2;
    if(i>=row+x && j>=col+y) return solveCoords(n-1,start+subTotal,row+x,col+y,i,j,len/2);

    x = len/2;
    y = len/2-1;
    
    if(i>=row+x && j<=col+y) return solveCoords(n-1,start+2*subTotal,row+x,col,i,j,len/2);

    x = len/2-1;
    y = len/2;
    if(i<=row+x && j>=col+y) return solveCoords(n-1,start + 3*subTotal,row,col+y,i,j,len/2);

    return -1;
}



pair<int,int> solveNum(int n, long long start, int row, int col, long long& d,int len){
    if(n==1){
       if(d==start) return {row,col};
       else if(d==start+1) return {row+1,col+1};
       else if(d==start+2) return {row+1,col};
       else if(d==start+3) return {row,col+1}; 
    }

    long long total = len*len;
    long long subTotal = total/4;

    if(d < start + subTotal) return solveNum(n-1, start, row, col, d, len/2); // Q0
    else if(d < start + 2*subTotal) return solveNum(n-1, start + subTotal, row + len/2, col + len/2, d, len/2); // Q1
    else if(d < start + 3*subTotal) return solveNum(n-1, start + 2*subTotal, row + len/2, col, d, len/2); // Q2
    else return solveNum(n-1, start + 3*subTotal, row, col + len/2, d, len/2); // Q3
}


int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        int n,q;
        cin>>n>>q;
        int len = 1<<n;
        for(int j=0;j<q;j++){
            string s;
            cin>>s;
            if(s[0]=='-'){    
                int x,y;
                cin>>x>>y;
                int i = x-1;
                int j = y-1;
                cout<<solveCoords(n,1,0,0,i,j,len)<<endl;
            }
            else{
                long long num=0;
                cin>>num;
                auto it = solveNum(n,1,0,0,num,len);
                cout<<it.first+1<<" "<<it.second+1<<endl;
            }
        }
    }
    
}
»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

thanks for such interesting problems . i just love this contest

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

Hello Codeforces Team,

I am writing to sincerely apologize for unintentionally violating the rules during Codeforces Round 1016 (Div. 3), significantly coincides with solutions Samad_2g/314636123, RubayetRafsan/314640595.specifically for problem 2093D.

Both of the accounts Samad_2g and RubayetRafsan belong to me. I submitted the same type solution from both accounts during the contest without realizing that this was a rules violation. It was a mistake from my side due to a lack of understanding, and I had no intention to gain an unfair advantage.

I now fully understand that participating with multiple accounts is strictly prohibited. I assure you that I will never repeat such a mistake again.

I kindly request that you keep my main account "RubayetRafsan" active, and I’m completely okay with "Samad_2g" being blocked or deactivated if necessary.

Please accept my sincere apologies, and thank you for your time and understanding.

Sincerely, RubayetRafsan