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

Автор top34051, 7 лет назад, По-английски

Hey Codeforces!

We’re thrilled to invite you guys to Codeforces Round #542, which is going to take place on Sunday, February 24, 2019, at 18:35 MSK. There will be a separate round for each division, and they will be rated!

Problems were prepared by MikeMirzayanov, zoomswk and me. As the round authors, we would like to thank ksun48, isaf27, tuna_salad, and Um_nik for testing the problems; 300iq and KAN for their help and advice in contest preparation; and the invisible MikeMirzayanov for the incredible Codeforces and Polygon platforms.

Each division will be given 6 tasks and 2 hours to solve them. As per the Codeforces tradition, scoring distributions will be revealed shortly before the round.

We wish you the greenest verdicts and hope that you’ll enjoy the tasks.

This round is in honor of Alex Lopashev who has supported Codeforces on its anniversary. Some words from MikeMirzayanov:

Alex Lopashev studied at Programming Competitions Training Center (in Saratov U) headed by me. I was really happy (and even proud!) to see his contribution on the 8th anniversary of Codeforces. I am sure that a large number of young people got a lot from our community, even if they did not achieve high results in competitions. It's great that there are those who remember and appreciate it. Thank you, Alex!

Good luck!

UPD1: Shortly after the contest, we'll be on the community Discord server to discuss the tasks.

UPD2: The score distributions are here!

Div2: 500 – 1000 – 1500 – (1000 – 1000) – 2500 – 3000

Div1: 500 – 1000 – 1500 – 2000 – 2500 – 2500

Note that task D of the second division will have subtasks.

UPD3: Last minute corrections T-T

Each division will be given 5 tasks. Also, task A of the first division will have subtasks like the way task D of the second division round do.

Div2: 500 – 1000 – 1500 – (1000 – 1000) – 2500

Div1: (250 – 250) – 1000 – 1500 – 2250 – 2250

UPD4: The Editorial is ready!

Congratulations to the winners!

Division 2

  1. Markadiusz
  2. kizen
  3. TAISA_
  4. ista2000
  5. OnlyGetAC

Division 1

  1. mnbvmar
  2. LHiC
  3. Errichto
  4. vintage_Vlad_Makeev
  5. V--o_o--V
  • Проголосовать: нравится
  • +248
  • Проголосовать: не нравится

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

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

»
7 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +23 Проголосовать: не нравится

Wish everybody high rating

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

Eagerly waiting

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

You have a mistake. You write Um_Nik, but correct variant is Um_nik))

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

hello codeforces my one suggestion if you want to implement ?? instead of 2 hrs please increase the at least 30 minutes for every round on codeforces. because i think if participants can solve more questions their confidence level will increase. if you have fixed 2 hrs then give me some idea based on what you have fixed 2 hrs for most of the contests. Thanks in advance

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

thank mr. alex

»
7 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится -6 Проголосовать: не нравится

Happy Coding and high rating.

Hoped that everybody( in both div.1 && div.2 ) has good feeling

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

Back to Back contests. Feels Great !

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

Is the div2 of this round available for ratings below 2100? It seems that I cannot register div2 with a rating between 1900 and 2100.

update: I asked this question since last few div2 rounds were available for users whose rating < 2100.

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

I want to say some words about some computer languages. When you use Cpython except classical Python your programm works faster and the syntax of it is not very difficult as the syntax of C++. I commonly use Python because you can not meet Cpython on many olimpiads, but... it is the best computer language in the world (in my opinion). And what do you think about Cpython and other languages?

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

how many problems are shared between the divisions ?

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

Note that task D of the second division will have subtasks.
There will be 4 shared problems!

So that problem Div2-D is shared, but Div.1 players will only solve its second subtask?

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

"Note that task D of the second division will have subtasks."

If one makes two submissions , first to first subtask and second to whole problem , will there be penalty -50 for second submission ?

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

i hope a good contest whithout delay

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

also whith good samples

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

Just curious, what about the hacks for div2D? Will it be possible to lock the first subtask only?

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

What does '(1000 — 1000)' mean ? refer to: "Div2: 500 – 1000 – 1500 – (1000 – 1000) – 2500 – 3000"

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

So In total there will be 7 problems for div2 people. :)

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

I want high rating.

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

How to solve problem C [Connect]

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

    You can use either a DSU or a DFS to find the connected components. Then a brute force search would suffice.

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

    Run a flood fill to assign each land cell to a component. If the start and end position are in the same component, output 0. Else, try building a tunnel between every pair of cells in the components of the start and end positions and take the minimum answer over these.

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

    Use dfs or bfs to find all spots reachable from the start and end. Then, find the cheapest tunnel you can make of all 50^4 possible tunnels that is has 1 side reachable from start, and 1 side reachable from end.

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

    What I did, was to do BFS traversal, but instead of building a graph, I was using the 2D table that was given in the input. From there, you could either move in the 4 directions, such that you move to (i+1, j), (i-1, j), (i, j+1), or (i, j-1), without adding anything to the cost, or you could go to any other place which has land, and the cost would be as in the statement. In order to make sure that you only place a tunnel once, you can only build a tunnel when the previous cost was 0. Have a look at my implementation 50455831

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

    If (r2, c2) can be reached from (r1, c1) the answer is 0.

    Otherwise, put all land cells that can be reached from (r1, c1) (including it) in a vector, say v1. Also, define another vector, say v2, for all land cells that can be reached from (r2, c2).

    Run an O(sz2) algorithm to calculate the minimum cost of building a tunnel between two cells, one from v1 and one from v2, where sz here represents the maximum size of v1 and v2.

    Time complexity: O(sz2) = O((n2)2) = O(n4).

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

    Build directed, weighted graph of 2*n^2 nodes and run dijkstra.

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

Really cool contest, great problems!

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

how to solve D??

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

    I'm not sure if my solution is correct, but it passed pretests: 50458735

    I kept the shortest distance from A to B in a circle for every A(based on all M queries), we can call it dist[A]. Then I started with every i in [1;n] and went a full circle, while updating the answer with answer = max(answer, (q[current] - 1) * n + dist[current] + cnt), where q[A] is the number of candies on station A and cnt is the number of steps we already made, starting from i.

    This solution should take O(N2) time.

    UPD: It passed system tests

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

Pretest 16 for Div 2 D2?

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

What's with the bounds in Div1C? I had to replace maps with vectors, sorting and binary search, and then had to remove the binary search part to pass TL, and now I'm really close to the memory limit

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

How to solve Div.1C? I noticed that overcount only happens when the two substrings are exactly the same. I used interval dynamic programming and hash_map to check out for each substring whether it has appeared before. The time complexity is O(m2), however, the actual running time of my code is rather slow on maximum test, due to the large constant of hash and hash_map. Is there any other solution with better complexity/constant factor? Is it intended by the author that one shouldn't use something like hash_map in this problem?

»
7 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +47 Проголосовать: не нравится

When one minute before the end of the contest you learn that your definition of a "substring" is wrong.

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

Nice constraints in div1 D.

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

Did anyone pass div1C with hashes? Using a big modulo and unordered maps TLEd while using smaller modulo created collisions, even with 2 different moduli

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

Am I right if say in Div2E you always can create array like -1 -1 -1 .... -1 x? With k = 10^9 worked.

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

A1 and A2 are too hard.X( Δ=-100 X(

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

How to solve B? is it greedy??

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

Standings are a bit weird right now. It tells me I got AC on A but shows -1 in the standings (for everyone, really)

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

Today we can see a new legendary grandmaster Errichto

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

How to solve Div2 B? I used greedy approach and sorted the houses based on the tier of cake they are selling and their index value. After this every time I assigned 1st house to Sasha and 2nd house(i.e one selling same tier cake)to Dima. I failed on pretest 10.

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

How to Solve Div 2 C ?

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

    Just by know, what are the positions where we can reach from the first position and second position. and then check which two cells give minimum distance.

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

    Run a flood fill and "color" in the pieces of land in the same region. Then you can brute force and check for the minimum distance between every piece of land in the same region as the start and every piece of land in the same region as the end.

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

    if r1,c1 and r2, c2 in the same component print 0 else

    for x in fields_in_first_component
      for y in fields_second_component:
        an = min(distance(y, x), an);
    

    components can be found using dfs or something like that

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

What is going on with the standings?!

Edit: Fixed

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

I think, it was a very nice experiment with subtasks.

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

Can anyone tell me what the bug in this 50457135.

edit: the Error was fixed its stupid logical error thanks for down vote.

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

Проблема только на телефоне

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

C is actually a bad problem .. 0 thinking it was just coding :/

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

Weird stuff going on in the system testing

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

who is speak turkey

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

Can anyone explain to me the solution of div2 D2 (div1 A2), please? I have one with O(n * log2(n)) that has WA on test 6. Were there any corner cases?

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

    I believe WA on test 6 comes from the incorrect assumption that the last station to be satisfied is one of the stations with the highest number of candies. A counterexample to this would be where you have 4 stations, and say station 1 has two candies to deliver to station 2, and station 4 has a single candy to deliver to station 3. The candy at station 4 will be the last to be delivered, despite there only being 1 candy at the station. Because of this, you can actually brute force check over all the stations that have candy to see the latest time at which all candies will be delivered, and take the max of those.

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

gonna purple yeah!

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

Clean approach for Div2E/Div1C:

We note that Alice's algorithm will fail to take any segment that has a negative prefix sum. Thus, we try to construct an array where the answer is the entire array, and the first element is negative, so Alice's algorithm will not choose it. We make the remaining elements nonnegative.

Let n = 2000, a1 =  - 1. Then, we see that the sum of the remaining 1999 elements (which we will denote as s) multiplied by 1999 will be what Alice's algorithm returns, even though 2000(s - 1) will be the actual answer. Thus, we want to pick an s such that 2000(s - 1) - 1999s = k, which is the same as s = k + 2000. We can thus make the first element of the array -1 and have the rest be a nonnegative sum of integers that is equal to k + 2000.

50450468

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

How much time does it has to pass after the contest is finished to be able to submit a solution of one of the problems? I want to submit my codes for the D1 and D2 problems.

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

I submitted the same code for problems D1 and D2 (Div.2). It got wrong answer in D1, and accepted in D2. Doesn't that mean that the tests for D2 do not cover all the cases, since D1 is a subset of D2?

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

my D1 and D2 code is the same and i got wrong answer in D1 and accepted in D2 :/// please check the test cases :/

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

There are lots of people who submitted the same code at the easier and the harder Div1A(=Div2D) and got Accepted on the hard version, WA on the easy one. In my opinion it is really unfair to keep all these clearly wrong solutions accepted. Will be there any more testings, or anything to make it fair?

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

top34051, I think that the test cases for the "Toy Train" problem are a little weak. My solution got AC on the harder version but failed the simplified version. Here are those:

Hope my rating does not change :)

»
7 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +74 Проголосовать: не нравится

Congratulations Errichto for becoming LGM.

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

Editorial link is redirecting to Announcement page. Please fix it. Edit: Works now. Thanks

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

Very nice contest and problems. Thanks to all the guys that made these problems. Although I didn't manage to solve all of them, I really enjoyed this contest. Thanks to you all again.

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

Good round!

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

i will get out of expert after this :D

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

Chipicao !
Combinația perfectă de mâncare și distracție pentru a avea putere la concurs! :D

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

is problem div2 C solvable using DP ? i write a code that passed 23 tests and take WA on 24 , but i don't know why.. my code : https://mirror.codeforces.com/contest/1130/submission/50521284

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

Update: got it.