Codeforces Round #368 Div. 2 review

Link

 

A. Brain’s Photos

Just need to check if color (Cyan, Magenta or Yellow) exists or not in the photo.

 

B. Bakery

The problem sentence looks long, but after summarize, you just need to find the path between flour storage city and non flour storage city with minimum distance.

But to find out these city path, I was using vector which is not fast enough and I got TLE during contest.

 

We can make search fast, in constant time by using Array to set a type of city.

 

C. Pythagorean Triples

Consider some cases to get answer.

If \(n >= 3\), there exists answer. And we can show one representative answer.

 

D. Persistent Bookcase

  • DFS with forward&backward operation
  • Problem

This problem focuses how to make persistent data structures. I imagine the data management of git (branch) also works in similar way.

We cannot have all the time of book shelf state in the memory, so how to achive the operation 4 is the problem. We can do it by using Depth First Search, and after dfs we need to “rollback” the operation to get previous shelf state.

 

Here I decided to use C scanf() and printf() function instead of C++ cin/cout function. Because I noticed there is quite a big difference in the speed. See below post for detail.

 

Sponsored Links

Leave a Reply

Your email address will not be published.