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

Автор vito1036, история, 3 года назад, По-английски

Hi everyone!

The third round of COCI will be held on January 14th at 14:00 UTC. You can access the judging system here. If you are not familiar with COCI contest format, we encourage you to read the announcement.

The round was prepared by dorijanlendvaj, ppavic, jklepec, psruk, mkisic, mlicul and me.

Feel free to discuss the problems in the comment section after the contest ends.

Hope to see you and good luck!

  • Проголосовать: нравится
  • +120
  • Проголосовать: не нравится

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

Reminder: the contest starts in one hour.

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

Nice problems! May anyone please explain how to solve Skrivaca?

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

Where can I upsolve the problems? I want to submit some code for task Skrivaca.

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

May someone explain how to get full credit on Bamboni? Getting more than half credit with $$$n^2k$$$ dp was pretty trivial... Is there some number theory optimization I missed?

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

what's the idea for Baltazar?

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

    The first observation is that if you want to increase the length of the shortest path in the graph by modifying exactly one edge you need to increase an edge that appears in all the shortest paths, so possible candidates for the solution are all edges that appear in all the shortest paths of the graph. You can check if an edge appears in all shortest paths by running Dijkstra 2 times from nodes 1 and N and also keeping track of the number of shortest paths from the source to some node, not just their length. This number can be very big, so you can keep it modulo some big prime number(for safety and avoiding collisions, you can use more modulo values; I used 4 but I don't know how many are necessary). Now you can check whether an edge appears in all shortest paths by some product of counts(computed with Dijkstra from 1 and N) in its endpoints and comparing that to the number of shortest paths also computed with Dijkstra.

    Further, it's obvious that after you increase an edge of the shortest paths by 2, its new length will also increase by 2, not by 1, so the graph needs to initially have at least one path of length shortest_path + 1. If this is not the case, there is no solution and you print 0 and new line. After that, for all possible edge candidates you need to check if they lie in all paths of length shortest_path + 1. If so, you can not increase that edge, because after that you will no longer have a path of length shortest_path + 1 in the graph. Now this part seems similar to the first part computed with Dijkstra, but how exactly can you do that? Well my approach was to compute dp[node][0 / 1] and cnt[node][0 / 1] = the length and number of shortest paths from source to node such that their length % 2 == 0 / 1. You can do that with Dijkstra as I said earlier. In our problem it is required that the second shortest path of the graph is one unit longer than the shortest one, so it will have a different parity and be the smallest path with this property, so we can extract informations about it from dp and cnt tables(one of them will corespond to the shortest path and the other one to the second shortest). After that you use this tables to solve the problem as I described. Don't forget to compute cnt modulo something and use more modulo values for safety.

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

How to solve 3rd subtask in Dirigent?