Блог пользователя Sanae

Автор Sanae, 4 месяца назад, По-английски

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, SDSXC

Sanae's Solution
juan_123's Solution
SDSXC's solution
Разбор задач Codeforces Round 1098 (Div. 2)
  • Проголосовать: нравится
  • -263
  • Проголосовать: не нравится

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

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

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

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

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

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

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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??

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

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..

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

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

»
4 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

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.

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится -8 Проголосовать: не нравится

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

    • »
      »
      »
      4 месяца назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      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 месяца назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

        I got rid of set and only used sort and that managed to pass. I also think there was a way to remove sets by first storing it in a vector of vectors then later adding it adding precomp of like n but not that much.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Make your complaint.

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    Stupid D.

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится -32 Проголосовать: не нравится

    AI-solveable E.

  • »
    »
    4 месяца назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    I believe the contest was good in it's core, and I am still thinking on F

    but my only complaint is this, in problem E you can't take a question from a combinatorics exam, (I dont really means it's from that but what I am saying is that it's only math and not common one, like the tricks are really just math and not ordinary one, like a question you would see in the end of a combinatorics semester in University)

    and I belive that solving just math, and then saying ohhh segment tree to do it faster is not a true cs question. like I believe everyone which is above like 1600 understood that once you solve E1 segment tree will solve E2.

    so thats the only thing that bothered me just because I was hoping for something beautiful and got a page of math instead :(

    anyhow, thanks for the contest it had been a lot of fun!

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +42 Проголосовать: не нравится

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.

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится +20 Проголосовать: не нравится

    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 :)

    • »
      »
      »
      4 месяца назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Strongly agree that F is easier and requires significantly less time than E (even a single E1). The amount of AC's is probably caused by nominal problem difficulty. E.g. I spent 40+ minutes on E1 (without success) and read F just 5 minutes before contest end. Finally solving F took me 50 minutes, but for E1 I spent half of next day and still confused with tons of formulas, still no AC. But in overall I liked problem F, I think it's suitable as Div2E. E is a math problem, not very good for a programming contest at all.

    • »
      »
      »
      3 месяца назад, скрыть # ^ |
      Rev. 3  
      Проголосовать: нравится 0 Проголосовать: не нравится

      E makes me vomit, the hell is this calculation. I thought the same thing as tutorial but couldn't collect patience to sit and write all this.

      (though so much to learn)

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Someone passed in 30min.

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    In the testing, the average time to solve is E is within 1h.

    • »
      »
      »
      4 месяца назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Oh, crazy. But I think, if the same difficulty (E1+E2 worth 3500 points, same as F) costs very different time, this is unacceptable for participants who try E and ignore F most of the time.
      And, someone passed in 30min can't show anything. The implementation complexity is very different for rating<2100 and rating>=2800. (Maybe same as C2, it also needs clear thinking and implement.) Many of the hard problem can be solved in 30min, but if participants fall into cases of counting and coding in this problem, it is normal to spend >=1.5 hour.

      (By the way: I think may be more CNOI style than Codeforces style, as you can spend more time on a difficult problem, because most of CNOI contests have 4 problems and >=4 hours.)

      Thx for your reply.

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится +8 Проголосовать: не нравится

    f looks so classic.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

my submission:- https://codeforces.me/contest/2228/submission/374854997

can anybody tell me what's wrong with this

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

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

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    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

    • »
      »
      »
      4 месяца назад, скрыть # ^ |
      Rev. 2  
      Проголосовать: нравится +8 Проголосовать: не нравится

      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.

    • »
      »
      »
      4 месяца назад, скрыть # ^ |
       
      Проголосовать: нравится +1 Проголосовать: не нравится

      correct testcase pointed out by pancakes. Another simple testcase could be:

      149 0,1,4,5 Answer = 150-149=1 If we try to match the longest prefix, we have to make 145 as the closest possible number. Then, you will report 149-145=4 as your answer.

      One good advice for these adhoc problems is trying to prove whatever you assumed as your solution. Or even trying to find testcases where your solution might not work. If you find a suitable test case, you will end up finding the solution by just trying to solve the problem for that test case.

»
4 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Misunderstood B :(

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +22 Проголосовать: не нравится

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 :(

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

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.

»
4 месяца назад, скрыть # |
Rev. 3  
Проголосовать: нравится +1 Проголосовать: не нравится

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?

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Bro wtf is your code doing? please explain

    • »
      »
      »
      4 месяца назад, скрыть # ^ |
       
      Проголосовать: нравится +14 Проголосовать: не нравится

      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

    • »
      »
      »
      4 месяца назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      https://www.youtube.com/watch?v=AzvIHqztzKg

      He as the same idea for C(1/2) like sc3developer. Maybe the video will help!

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

CaseForces

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

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

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

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.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

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.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

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

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

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.

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится -8 Проголосовать: не нравится

    Java can pass and it’s fast enough.

    https://codeforces.me/contest/2228/submission/374837428

    • »
      »
      »
      4 месяца назад, скрыть # ^ |
      Rev. 2  
      Проголосовать: нравится +3 Проголосовать: не нравится

      I'm not sure how that runs so fast. Is it the manual input reader?

      I'm not sure how everyone else feels, but in general, problems where a correct approach TLEs or runs in very borderline time aren't interesting or fair in my opinion. It seems like many people with valid O(n) or O(n log n) approaches get TLE. What was gained by using 2 million instead of 1 million, or even 200k (I don't think there is any sqrt decomposition that needed to be killed)?

      PS: I hope you're not taking the negative feedback too personally. I am aware of and deeply respect the insane amount of effort it takes to write a round. Maybe I should put my money where my mouth is and start testing rounds :p (but I'm not sure if that's something you can just volunteer for)

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    yeah, i failed with O(nlogn) during contest as well with TLE in TC19. just a tiny bit disappointed as well because O(n) passed in 1.75s which is not super comfortable.

    But yeah, good to learn that if n ≤ 2e6, then O(nlogn) might not be a safe option, and if you can think of O(n) approach, you should go with that implementation.

    Here is my side by side O(n) and O(nlogn) implementation (commented out the O(nlogn) one): 375001273

    • »
      »
      »
      4 месяца назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Yeah, I think here it was sets being too slow since the fastest solution I had still had overhead from sorting. I guess it makes sense since mergesort is extremely cache friendly (I'm not sure that's the one std::sort uses but theirs is probably even faster) vs lots of address dereferences and cache misses when walking down tree nodes full of pointers.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone share their soln. to C1? Or it would be wonderful if you could point out the problem in mine..

https://codeforces.me/contest/2228/submission/374822532

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I feel in B there is a mistake for example let's take the case of 6 1 4 3

so now both are at a max possible distance and according to the submitted soln the ans comes out to be 6 but that's incorrect because when x2 moves in whichever direction x1 will move in the same and the suddenly their difference in distance decreased by 2.

so answer should be 4 instead of 6. pls correct me anyone if this is wrong !

Thanks !

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

CirnoNine's solution to E1 asserts that:

For all weak compositions of $$$N$$$ into $$$k$$$ parts, we have

$$$\sum_{\text{valid $$$x$$$}} x_p(x_p-1) = C \frac{2N(N-1)}{k(k+1)}$$$

and for $$$p \neq q$$$,

$$$\sum_{\text{valid $$$x$$$}} x_px_q = C \frac{N(N-1)}{k(k+1)}$$$

Why do these properties hold? Or are these just "well-known" identities of weak compositions? (If it's the latter, any reference?)

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Wait I can't really understand question D's second solution, can someone pls explain to me? Thx

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    hi sir if u have time could you please help me i want to get a good job i just want to ask:- 1. how many problem should i solve a day 2. what to do when i am not able to solve low rated problem 3. any secret for faster progress?

    • »
      »
      »
      4 месяца назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Just do more problems, learn some Data Structures, and actually reason them out and understand what they mean. If you can't solve low rated problems just do more of them. Took me around 200 questions to build intuition for around 800-1200 range. For low rating problem just stack all your free time solving them and try to get them as fast as possible.

      • »
        »
        »
        »
        4 месяца назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

        Thanks for the advice, The 200-question milestone gives me a realistic target to shoot for. I'll start stacking my free time and grinding the low rated ones to build that speed and intuition.

»
4 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

In 2228B lets say n=7 x1=1 x2=4 and k=2

1st second

-Now Remilia moves to x2=5 from x2=4 optimally, this is the optimal move for Remilia because going to x2=3 will decrease the distance between the two.

-Since Remilia chose x2=5, Reimu will try to minimize distance so he will come to x1=7 from x1=1 optimally.

2nd second -Now Remilia moves to x2=4 from x2=5 optimally.

-Since Remilia chose x2=4, Reimu will try to minimize distance so he will come to x1=6 from x1=7 optimally.

further seconds

Now Remilia cannot move anymore so she will stay at x2=4 and Reimu is at x1=6 and the difference between then is 2

So ans is 2(initial second) + 2(last differene between the two after Remilia is out of moves)=4

But according to this tutorial ans = min(7-(4-1),(4-1))+k = min(4,3)+2 = 3+2 = 5

Why?

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

This might be the worst contest of all time, the one that eats up your rating by providing garbage trash test cases, it seemed like intentional and of no use except giving you a -50, makes you feel like trash after the contest and ruins your day, fuckass implementation problems, all the future contest makers should take a learning from this shit

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I solved 4 problems, thank you for the competition, I liked it

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

It may be easier to understand D after discretisation? Because the number of ways to place a dividing line would just be Max — Min. We can sort all points in increasing order of x and then iterate the position of horizontal line. Then the number of valid, distinct ways to place vertical line will be max(0, min(prefMax, suffMax) — max(prefMin, suffMin)). prefMax is the maximum y, after discretisation, of all points on the left of horizontal line, and similarly for suffMax, prefMin, suffMin.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In problem B, Lets say n=4, x1=2, x2=4 and k>0, won't the distance between them reduced by 1? Help me understand this situation.

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    My interpretation was, as long as the one being chase has a remaining move k yet, the min distance will not decease, only when k becomes zero the distance will start closing in. So in other words the total distance is actually k + the minimum distance.

            long n = in.nextLong(), x1 = in.nextLong(), x2 = in.nextLong(), k = in.nextLong();
     
            if (n <= 3) {
                out.println(1);
                return;
            }
     
            long d1 = Math.abs(x1 - x2);
            long d2 = Math.abs(n - d1);
            long d = Math.min(d1, d2);
     
            out.println(d + k);
    
  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Yeah that's what I thought. Let me know if u find understand this bit

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Liked the problems a lot. Great contest

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I hated the constraints in D, you can use O(nlogn) but not so much.

Also missed a very crucial case for C1 and C2, took very long to find. example: 1 99 3 0 1 2 I hate that I noticed the case where I could be getting the bug and proceeded to fix it incorrectly.

Lets not talk about A :(

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone explain me in question B if the distance is going to decrease if remelia moves either way then won't the answer be max(D1,D2)-2+k. In the case 4 1 3 1. In first move distance decreases by 2

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is it only me to pass C by digit DP lol :(

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

does anyone has a more in depth explanation or tutorial of C1 & C2? or a visual explanation? I don't get how we got the longest common prefix of a and b when we still don't know what b is? or are we building b as we read the digits of a from the most significant digit to the least significant digit? In O(n log a) I assume the n part is iterating the digits of b? or a? and in log a is it a binary search? and what are we searching here exactly?

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    yes , the longest common prefix is match a and b from high to low. b can longer or more less to the a,and use the min di or max di get two possible b.if a , b have the same length. we need to from high of a and find the char in d.it use log10 (a) times,log a is mean the digits of the a.and we can use the way of tutorial.the way means find all possible close numeber to a.and write a function to find the closest b.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

well I have a doubt regarding problem b in the case suppose if n = 4 and they are in opposite positions ex 1 and 3 and k is 2 so in the first step rameilia skips and reimu goes to 2 and then again rameilia goes to 4 and reimu goes to 3. time is 2 sec till now and in next second she will catch rameilia so ans is 3 in this case but according to k + min(n-abs(x-y),abs(x-y)) comes out to be 4 so am I wrong somewhere in my resoning please help me

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

it was impossible to get accepted on D in python :( nobody succeeded

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For problem C:

I know the thinking for greedy to solve it, but I really don't want to think. So I use binary search to solve it.

We could calc the k-th smallest digit we can constructe. So it's possible to find the two digit greater and less than a nearest.

However, if d[0] is $$$0$$$, things will become very troublesome. In the end, the competition was not resolved.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

The problem C sucks.

»
4 месяца назад, скрыть # |
Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится

My answer to Problem C1:

someone explain me more easy approach for this

Spoiler
»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

for Problem B If the two paths from Reimu to Remilia have the same length (i.e., the distance is exactly n/2 and n is even), then Remilia cannot make the shortest distance longer by moving. Her best move is actually to stay. So her k moves don't help at all, and the answer should just be that distance, not distance + k. Am I wrong? Thanks.

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    if the both paths between them has same distance (leaving n=2 and n=3 cases), for that particular moment Remilia will stay but Reimu will move to any one of the two paths to catch her, then Remilia will shift again to make distance of both paths equal (she can do this k times). so eventually answer is k shifting + shortest distance between both (that is n/2 in this case for n even).

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In B

if diff1 and diff2 are same then why answer is not k + diff — 1

cause for 1st sec --> Remilia will not move

cause if she moves ---> new diff will become worse

so she wont move then --> diff--

then normal operations again !!

what did i missed then ???

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

SDSXC what is dep in your solution to F?

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hi, could you please elaborate on the O(n) solution for problem D?

I understand the O(n log n) idea, and I can imagine getting O(n) if we use counting sort because coordinates are in [1, n]. But I do not understand the intended O(n) observation from the editorial.

Specifically:

  1. What exactly are "the two groups determined by the smaller y-coordinate"?

  2. What does it mean that a valid dividing line must cross one of these groups?

  3. What point are we enumerating?

  4. What is the "appropriate pre-computation"? Which values should be precomputed?

  5. How do these precomputed values give the feasible vertical dividing position x?

  • »
    »
    4 месяца назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    You can implement this in O(n) with count sort but here is my idea to visualise better and has O(nlogn) complexity. Sort all the points based on their x co-ordinate. Now, imagine there is a set "Y" that contains all the y co-ordinates from the n points. Now, we iterate over all the points in sorted order and when we see that the current points' x co-ordinate is greater than the last one, that means, we can draw a vertical line between current and previous point.

    Vertical Line image

    Now, we will add the number of ways we can add a horizontal line for this vertical line to the answer. To calculate number of horizontal lines, we keep two multisets y1 and y2. y1 = multiset of y co-ordinate to the right of our vertical line y2 = multiset of y co-ordinate to the left of our vertical line Initially y2 = all y co-ordinates, y1 = empty When we move to points, we move its y co-ordinate from y2 to y1

    Now, for calculating number of horizontal lines, let's take a cut at y=a, then y1 will be divided into 2 parts, all points less than 'a' and all points greater than 'a'. Lets call these as left and right part of y1. Similarly for y2. We need to choose 'a' such that the left and right parts of y1 and y2 are not empty (to make sure that no quadrant is empty).

    Example: y1 = [1, 2, 5, 8], y2 = [3, 6, 7], Y = [1, 2, 3, 5, 6, 7, 8] In this example, we need to make cuts in Y. So if we make cut between 2 and 3 (a = 2.5), y2 will be cut such that its left part if empty ([] and [3, 6, 7]). If we make cut between 3 and 5, y1 cuts as [[1, 2] and [5, 8]] and y2 cuts like this [[3], [6, 7]]. basically element ≤ 3 will be in first part, and elements ≥ 5 will be in other part and we want both parts to have atleast one element to make sure all quadrants have some points In above example, the quadrants will have following y co-ordinates: 1st [1 and 2] 2nd [5 and 8] 3rd [3] 4th [6 and 7]

    Lets call e = max(min(y1), min(y2)) and f = min(max(y1), max(y2)). To achieve the above, we need to make cuts in Y between e and f. Let: pos[x] = position of x in set Y. Number of possible cuts = pos[f] — pos[e] We add this to answer.

    Here is my O(nlogn) submission: 374843238

  • »
    »
    3 месяца назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    Bro, I solved this problem in O(n). But, I always try to understand and learn from editorial. And, guess what? I'm trying to understand Solution 2 from last 30 minutes but literally can't get a single word of this solution. I think, this is the most terrible solution of a problem I've ever seen.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For C1/C2, even the $$$10^{17}$$$ seems too much. In some cases, you need to take a number which has more digits than $$$a$$$, which leads the numbers go above the upper bound for long long. My solution passed after finally using __int128_t. This affected my score very badly. I got 10 unsuccessful submissions before realizing long long wasn't enough. For a Div. 2 C1/C2, requiring __int128_t just because of unexpected intermediate overflows feels incredibly misleading.

  • »
    »
    4 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I also used __int128, but later realized that the only case when __int128 is needed is a = exactly 10^17 and only when trying to use b composed of 18 digits. However, if a = exactly 10^17, using 18 digits for b is never optimal, because, for example, using a 16 digits (or even 1 digit) b is clearly better. Thus, to avoid __int128, just handling "a = 10^17" separately (skipping 18 digits attempt) should be enough.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is it only me or did C1 feel quite more difficult compared to other Div 2 contests?

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

C killed me... but please share code for C, I would love to see if there is a simpler way to code it.

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

This is such an excellent contest! I love it(only except the problem D with a tight time limit).

»
4 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can someone explain to me in detail about the problem D im a bit of confused and didnt get clear about that :( TMT

»
4 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I thought you were supposed to brute force c1? since per test case n=2 gives you about 2^17+2^18+2^19 operations. (brute forcing on the length of b, from a.size-1 to a.size+1. wasn't that the point?

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

horrible to put such difficult to calculate in E,and meaningless to divide it E1,E2

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is there code for juan_123's solution for Problem F? If so, please link me to it, can't find it in juan_123's submissions.

»
3 месяца назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

Is the "first solution" of F an intended solution? I was barely able to pass (2800ms) and that is with some optimizations. Edit: nvm optimizing to 1 log is trivial.

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

i struggled very hard to solve problems and i solved 5 out of 8. previously i got a rating of 744 now it became zero(unrated in my account) why i don't know.

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Guys, I solved problem D in O(n) time complexity. 377025802. After that, I'm trying to understand the editorial of this problem. Solution 1 is very clear. But, I'm not getting anything of Solution 2. Can anyone explain Solution 2 properly?

»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For B, if the distance between the two is n/2 exactly when n is even, then would it not be optimal for x2 to not move initially?