Sanae's blog

By Sanae, 7 days ago, In English

Thank you for helping Marisa, Reimu, Cirno, Sanae, Amanojaku and Momoyo!

Leave a comment!

2228A - Marisa Steals Reimu's Takeout

Author: Sanae

Solution: Sanae

Step 1
Step 2
Step 3

2228B - Remilia Plays Soku

Author: Sanae

Solution: Sanae

Solution

2228C1 - Cirno and Number (Easy Version) and 2228C2 - Cirno and Number (Hard Version)

Author: Sanae, Sugar_fan

Solution: Sanae, Sugar_fan

Solution

2228D - Sanae, Cross and Color

Author: Sanae

Solution: Sanae, fanhuaxingyu

Solution 1
Solution 2

2228E1 - Amanojaku and Sequence (Easy Version) and 2228E2 - Amanojaku and Sequence (Hard Version)

Author: Sanae

Solution: Sanae

Tutorial: CirnoNine, fanhuaxingyu

Sanae's Solution
CirnoNine's Solution
fanhuaxingyu's Solution

2228F - Momoyo and the Network

Author: Sanae

Solution: Sanae, juan_123

Sanae's Solution
juan_123's Solution
  • Vote: I like it
  • -144
  • Vote: I do not like it

»
3 hours ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

i feel bad that i missed n=3 case in B :(

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

    I also missed that case n <= 3 I looked for all the options but didn't find a solution.

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

    me also ;( i didn't notice this case even though i found the answer

»
3 hours ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

today is more cheaters in this contest than expected cf should take strict action on this

»
3 hours ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

how did people use fenwick trees for D? I tried this but got 6-7 TLEs / MLEs, despite trying to optimize constant factors, use lighter trees, rewrite in C++, etc

eventually I had to use a prefix/suffix approach to pass

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

    That wasn't even enough for me. I ended up passing with O(n) inner loop and pragma AVX. I'm going to run some benchmarks once practice opens up and will report back

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

    I passed easily with $$$O(n)$$$(without optimizations) and got TLE in Pretest #19 with $$$O(n \log n)$$$. I guess that's normal.

»
3 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

let d be the number of digits of a,can any tell if we generate all possible numbers with the 2 given digits of length=d and check for min difference (2^18, recurrsion), i dont know digit dp, and check for the largest number with (d-1) digits and smallest number with (d+1) digits , will it work??

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

    No because there are up to 10,000 test cases, and you might be doing 2^18 operations for each one

»
3 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I wasted too much time on D because it doesn't allow $$$O(n \log n)$$$ algorithms to pass, so i didn't finish calculating E1's equation :(

Feeling bad because I succeeded to pass the example of E1 ten minutes ago, which is just 25 minutes after the contest :(

Hope that my rating won't decrease for that..

»
3 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Maybe the problem F is so much similar to 2222G - Statistics on Tree?

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

In Problem D, What is the idea behind forcing the constraints that some (N log N) solutions pass and others not ??

If the author think that this kind of forcing constraints will make the problem anti AI, I think he made it harder for humans than AI.

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

    Initially, I only intended for the $$$O(n)$$$ solution to pass...

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

      I feel like a more explicit decision should have been made. As of now, it seems the n log n editorial solution works only when written very tightly and in C, and java/python/etc users also get screwed.

      Also visually n log n with 2 million * 21 looks like it should run fine. Even when I sped up the inner loop to O(n) (but still had std::sort and std::set to do coordinates), I still got TLE.

»
3 hours ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

Make your complaint.

»
3 hours ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

I am a fan of wdoi, but this contest is not good enough.

E is too complex and meaningless as Div2 E. I don't think any problem with difficulty <=3000 should use so looong calculation.
And F has a very classic and simple solution: just use binary search, then use simple dp and sorting to check. You can just pass with $$$\Theta(n\log n\log V)$$$ complexity, or sort before binary search and use two-pointer to get $$$\Theta(n(\log n+\log V))$$$.

Plz bring better problems to participants at next contest of wdoi, and accept suggestions about problem. Thx.

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

    Addition: I expect E2 worth >=2600 difficulty, but 100+ participants pass this problem, and F is easier with less pass. How many cheaters in Div2??? That is insane.
    If an(/a) expert/specialist pass this E2 in 1 hour is common, I think people can still challenge AI :)

»
3 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

my submission:- https://mirror.codeforces.com/contest/2228/submission/374854997

can anybody tell me what's wrong with this

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

    plz mention what approach you are using for anyone to read your code easily.

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

    so first of all we get the string of a and remove first charecter until it is not in D

    then we make two cases

    b > a

    in this case pick sallest number > d if no then don't compute this case and make all other numbers smallest possible

    compute both numbers

    and take abs difference

    same is done with the second case

    now when b has less digit then a just get x = number of digits in a and take maximum digit in d x — 1 time to get this value and again update answer

    the case with more digits is handled this way

    if(d[0] || d[0]==0&&n>1) {
                    ll tr=0;
                    for (int i = 0; i < sz+1;i++) {
                            tr=tr*10+(d[0]==0?d[1]:d[0]);
                    }
                    ans=min(ans,abs(tr-a));
            }
            if(d[0]==0&&n>1){
              
              ll tr = d[1];
              for (int i = 0; i < sz; i++) {
                tr *= 10; 
              }
              ans=min(ans,abs(a-tr));
            
            }
    
    

    here sz is number of digits in a

    • »
      »
      »
      108 minutes ago, hide # ^ |
      Rev. 2  
      Vote: I like it +4 Vote: I do not like it

      605 4 2 5 6 9

      Correct answer: 6

      Use this test case to debug. It is incorrect to remove all the numbers in the beginning that match. There are cases where it is optimal to not match all the beginning digits.

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

Misunderstood B :(

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

    If Remilia does not move at turn 1, k is still 1, so Remilia can move at turn 2. Not "can move before turn k", true is "can move most k turns".

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

    if initially the distance of both sides are the same, The first player stops at its place for 1 round. And then the second player would decrease the distance by moving in either direction. After the 1st round, they start chasing each other in the same direction. So it's still min_dist + k.

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

      Yep! Misunderstood this one, as k is the time going on, Thanks for making it clear!!

    • »
      »
      »
      110 minutes ago, hide # ^ |
      Rev. 3  
      Vote: I like it 0 Vote: I do not like it

      But, somehow I had to add $$$1$$$ to the answer if the $$$\operatorname{abs}(dist1-dist2)\leq1$$$, because $$$\text{Remilia}$$$ would choose not to move in this case, so $$$k$$$ remains the same but the initial $$$min\_dist$$$ decreases by $$$1$$$.

»
2 hours ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

I didn't like this one :(

A was fine B wasted a lot of time because I thought k was the total number of Remilia moves (it's total number of moves Remilia makes where she doesn't stay in place). It's my fault for misreading but still feels bad. C isn't that bad conceptually but it got REALLY bad once I started implementing. idk I find these kinds of questions where there isn't an insight just caseworking super boring. D looks interesting but I didn't get to it because of ABC :(

»
2 hours ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

What was the intended solution for C1? Is it the same as C2? If so, why did you split C into two subtasks? The editorial's solution doesn't seem like it would be more complex to implement for 10 digits instead of 2. I started writing a brute-force solution for C1 (checking all 2^18 possibilities), but then realized that there are 10^4 tests per case and abandoned it.

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

I used binary search for C1 and C2. I don't really know how to explain it look at my submission: 374842701, if you struggled with implementation I would look at it because it's a lot simpler than greedy

would say L contest but I got paid off with expert performance

Also, are hacks disabled for any problems?

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

    Bro wtf is your code doing? please explain

    • »
      »
      »
      58 minutes ago, hide # ^ |
       
      Vote: I like it +2 Vote: I do not like it

      Ok, so first we define a function $$$\operatorname{gen}(x, w, b)$$$ where $$$x$$$ is the list of numbers, $$$w$$$ is the the amount of digits of the generated number, and it finds the $$$b$$$-th smallest number (0-indexed). We can do this by representing $$$b$$$ as a base $$$n = \operatorname{len}(a)$$$ mask, for example:

      $$$\operatorname{gen}([1, 2], 4, 6) = \operatorname{gen}([1,2], 4, 0110_2) = 1221$$$
      $$$\operatorname{gen}([1, 2, 3], 4, 5) = \operatorname{gen}([1, 2, 3], 4, 0012_3) = 1123$$$

      For each $w$ from $$$1$$$ to $$$18$$$, we will binary search for the smallest value greater than $$$a$$$ that can be created from the digits, and use $$$\operatorname{gen}$$$ to create these values. The value with the smallest absolute difference per width will either be the value found from binary search, or the generated value that is just smaller than it.

      Sorry if this is unclear it's a bit difficult to explain as I said

»
2 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

CaseForces

»
2 hours ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

C has many cornercase without effective examples.What a "wonderful" problem.

»
2 hours ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

B was super obvious but unfortunately I spent a lot of time trying to find the n=3 edge case. C1 and C2 are the same solution basically and problems like this are super boring, not creative just implementation hell.

»
115 minutes ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
»
98 minutes ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

E1 we can solve for sum of cubes or higher powers right?

»
71 minute(s) ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

didn't C need some heavier formalism to really define if b = 0 is always a possible solution or not? For me, at least, that wasn't clear at all; but I might be bugging.

»
65 minutes ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

what is the point of asking n=2 soln for c1

»
61 minute(s) ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

So, I did some testing and I don't really like D.

During the round:

  • my first O(n log n) first attempt using sweep line: TLE pretest 19
  • I tightened inner loop to O(n), but I still used std::sort and std::set once at the beginning to filter out duplicate x coordinates: TLE pretest 19
  • Changing set filter to sorting: 0.95s AC
  • This is annoying in my opinion. All I wanted was a sorted list of x coordinates with duplicates removed. Doing that with a set/prio queue method vs sorting and then sweeping should not be that big of a difference. But, at least now we know, std::sort is fast n log n, sets and maps are slow n log n.

After, the round, I tried a true O(n) solution with counting sort: 1.79s AC, actually was worse.

My conclusion is that I feel like the time limits were set WAY too tight, and were not super effective at discriminating between O(n) and O(n log n) at all. This problem felt like constant factor hell in C++ and I'm not sure it's even solvable (in n or n log n) in java/python. One of my friends daniel.glabai had O(n) inner loop in java and TLE19'd as well.