Fişierul intrare/ieşire:flappybird.in, flappybird.outSursăIIOT 2021-22 Runda 3
AutorStefan DascalescuAdăugată destefdascalescuStefan Dascalescu stefdascalescu
Timp execuţie pe test0.5 secLimită de memorie32768 kbytes
Scorul tăuN/ADificultateN/A

Vezi solutiile trimise | Statistici

Flappybird

After many years of obscurity, the well known mobile game Flappy Bird has finally become downloadable again and Stefan decided to install it on his mobile phone in a quest to relive his old childhood days.

In this version, we are given n pairs of towers, which can be represented as a grid of n lines and an infinite number of columns (unlike the original version of the game, the towers are oriented horizontally, rather than vertically). In this grid, we know for each of the n lines the interval of positions which are accessible by our bird and we want to know whether the bird can win the game, if the player plays the game perfectly.

In order for a bird to pass a pair of towers, it has to be able to move from the current position to any position from the next pair of towers, without having to touch any walls. Furthermore, we will assume that the bird has an infinite speed (it can move instantly to any point from the next pair of free spaces, as long as this is physically possible).

Date de intrare

The first line of the input file flappybird.in contains n, the number of pairs of towers.

The next n lines of the input contain two integers each, a and b, representing that the free spaces are between columns a and b.

Date de ieşire

On the first line of the output file flappybird.out we will print YES or NO based on whether the bird can win the game or not.

Restricţii

  • 1 ≤ n ≤ 10^5
  • 1 ≤ a ≤ b ≤ 10^9

Exemplu

flappybird.inflappybird.out
5
3 6
4 7
2 4
4 5
1 5
YES
flappybird.inflappybird.out
4
4 7
5 6
1 3
3 6
NO
Trebuie sa te autentifici pentru a trimite solutii. Click aici

Cum se trimit solutii?