7070.Mex Grid Queries

Time Limit: 1s Memory Limit: 512MB

Consider a two-dimensional grid whose rows and columns are $1$ -indexed. Each square contains the smallest nonnegative integer that does not appear to the left on the same row or above on the same column.

Your task is to calculate the value at square $(y,x)$ .

Input Format(From the terminal/stdin)

The only input line contains two integers $y$ and $x$ .

  • $1 \le y,x \le 10^9$

Output Format(To the terminal/stdout)

Print one integer: the value at square $(y,x)$ .

Sample Input

Copy
3 5
 · \n

Sample Output

Copy
6
 \n
Source: CSES, Additional Problems II, 1157

Submit

请先 登录

© 2025 FAQs