#P1892. Maximum Number of Groups in a Balanced Signed Graph

    ID: 15175 Type: Default 1000ms 256MiB

Maximum Number of Groups in a Balanced Signed Graph

Maximum Number of Groups in a Balanced Signed Graph

There are n people, and every pair of people has one of two relationships: friend or enemy. The relationships satisfy the following conditions:

  • The friend of a friend is a friend. In other words, if person A is a friend of person B and person B is a friend of person C, then A and C are friends.
  • The enemy of an enemy is a friend. That is, if person A is an enemy of person B and person B is an enemy of person C, then A and C are friends.

Two people are in the same group if and only if they are friends. Note that every two distinct people have a defined relationship (either friend or enemy). Such a configuration is known as a balanced signed graph in graph theory. A well-known structure theorem tells us that a complete balanced signed graph with at least one enemy edge can be partitioned into exactly 2 groups (if there is more than one person). The only exception is when n = 0 or n = 1.

Task: Given n, determine the maximum possible number of groups. In summary:

  • If n = 0: output 0.
  • If n = 1: output 1.
  • If n \ge 2: output 2.

Mathematically, the answer can be expressed as:

\[ f(n)=\begin{cases} 0, & n=0,\\ 1, & n=1,\\ 2, & n\ge 2. \end{cases} \]

inputFormat

The input consists of a single integer n (0 \le n \le 10^9) representing the number of people.

outputFormat

Output a single integer, which is the maximum possible number of groups.

sample

1
1