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

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

I allways wanted to write an editorial, it seems like that very simple contest is my chance to do so.

1351A - A+B (Trial Problem) This is a most trivial problem, we just need to literaly output what is written in the statement, cout<<a+b<<endl; 79277814

1351B - Square? In this problem we need to observe that we can build a square from the two given rectangles if, and only if the sum of the two smaller sides equals the longer side of one of the rects, and both longer sides are equal.

How to implement this? Well, since there are four cases which sides could be the longer and the shorter ones, we can implement all four cases. Or simpler, change the side lengths of the rectangles if they are not in order. We end up with something like this

bool ans=min(a,b)+min(c,d)==max(a,b) && max(a,b)==max(c,d);

79287825

1351C - Skier First we need to understand that a "segment" in this problem is the way between two points. And the given path denotes the step from a current position to a next one, which uses one segment. We need to observe that it does not make a difference in which direction we use a segment.

For implementation it seems natural to somehow mark the used segments, and on every step check if we use a previously used segment, or a new one. We allways step from a previous position to a current position, and the current position is the previous position of the next step.

Marking a segment works fine by putting the allready seen segments into a map or set. Since a segment can be defined in two ways (the order of the two points) we can put both definitions into the set. Or while querying the set query for both. 79286682

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

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

THANK YOU!

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

I hope this approach for A help others! 79440849

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

I think it's better 79381459 :D

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

Challenge: solve problem A without using any of +-*/ in your code.