Codeforces Round 312 (Div. 2)
D
Guess Your Way Out! II
Codeforces
2300
原题
← CE →
翻译中…

Amr bought a new video game "Guess Your Way Out! II". The goal of the game is to find an exit from the maze that looks like a perfect binary tree of height $*h*$. The player is initially standing at the root of the tree and the exit from the tree is located at some leaf node.

翻译中…

Let's index all the nodes of the tree such that

翻译中…
  • The root is number $1$
  • Each internal node $*i*$ ($*i* ≤ 2^{*h* - 1} - 1$) will have a left child with index = $2*i*$ and a right child with index = $2*i* + 1$
翻译中…

The level of a node is defined as $1$ for a root, or $1$ + level of parent of the node otherwise. The vertices of the level $*h*$ are called leaves. The exit to the maze is located at some leaf node $*n*$, the player doesn't know where the exit is so he has to guess his way out!

翻译中…

In the new version of the game the player is allowed to ask questions on the format "Does the $*ancestor*(*exit*, *i*)$ node number belong to the range $[*L*, *R*]$?". Here $*ancestor*(*v*, *i*)$ is the ancestor of a node $*v*$ that located in the level $*i*$. The game will answer with "Yes" or "No" only. The game is designed such that it doesn't always answer correctly, and sometimes it cheats to confuse the player!.

翻译中…

Amr asked a lot of questions and got confused by all these answers, so he asked you to help him. Given the questions and its answers, can you identify whether the game is telling contradictory information or not? If the information is not contradictory and the exit node can be determined uniquely, output its number. If the information is not contradictory, but the exit node isn't defined uniquely, output that the number of questions is not sufficient. Otherwise output that the information is contradictory.

翻译中…

Input

翻译中…

The first line contains two integers $*h*, *q*$ ($1 ≤ *h* ≤ 50$, $0 ≤ *q* ≤ 10^{5}$), the height of the tree and the number of questions respectively.

翻译中…

The next $*q*$ lines will contain four integers each $*i*, *L*, *R*, *ans*$ ($1 ≤ *i* ≤ *h*$, $2^{*i* - 1} ≤ *L* ≤ *R* ≤ 2^{*i*} - 1$, image), representing a question as described in the statement with its answer ($*ans* = 1$ if the answer is "Yes" and $*ans* = 0$ if the answer is "No").

翻译中…

Output

翻译中…

If the information provided by the game is contradictory output "Game cheated!" without the quotes.

翻译中…

Else if you can uniquely identify the exit to the maze output its index.

翻译中…

Otherwise output "Data not sufficient!" without the quotes.

翻译中…

Note

翻译中…

Node $*u*$ is an ancestor of node $*v*$ if and only if

翻译中…
  • $*u*$ is the same node as $*v*$,
  • $*u*$ is the parent of node $*v*$,
  • or $*u*$ is an ancestor of the parent of node $*v*$.
翻译中…

In the first sample test there are $4$ leaf nodes $4, 5, 6, 7$. The first question says that the node isn't in the range $[4, 6]$ so the exit is node number $7$.

翻译中…

In the second sample test there are $8$ leaf nodes. After the first question the exit is in the range $[10, 14]$. After the second and the third questions only node number $14$ is correct. Check the picture below to fully understand.

翻译中…

image

翻译中…

样例

Input #1
3 1
3 4 6 0
Output #1
7
InputCopy OutputCopy
Input #2
4 3
4 10 14 1
3 6 6 0
2 3 3 1
Output #2
14
InputCopy OutputCopy
Input #3
4 2
3 4 6 1
4 12 15 1
Output #3
Data not sufficient!
InputCopy OutputCopy
Input #4
4 2
3 4 5 1
2 3 3 1
Output #4
Game cheated!
InputCopy OutputCopy
题目信息
题号
558D
时间限制
2 s
内存限制
256 MB
标签
数据结构
模拟
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。