Codeforces Round 840 (Div. 2) and Enigma 2022 - Cybros LNMIIT
E
Node Pairs
Codeforces
2200
原题
← DF →
翻译中…

Let's call an ordered pair of nodes $(u, v)$ in a directed graph unidirectional if $u \neq v$, there exists a path from $u$ to $v$, and there are no paths from $v$ to $u$.

翻译中…

A directed graph is called $p$-reachable if it contains exactly $p$ ordered pairs of nodes $(u, v)$ such that $u \lt v$ and $u$ and $v$ are reachable from each other. Find the minimum number of nodes required to create a $p$-reachable directed graph.

翻译中…

Also, among all such $p$-reachable directed graphs with the minimum number of nodes, let $G$ denote a graph which maximizes the number of unidirectional pairs of nodes. Find this number.

翻译中…

Input

翻译中…

The first and only line contains a single integer $p$ ($0 \le p \le 2 \cdot 10^5$) — the number of ordered pairs of nodes.

翻译中…

Output

翻译中…

Print a single line containing two integers — the minimum number of nodes required to create a $p$-reachable directed graph, and the maximum number of unidirectional pairs of nodes among all such $p$-reachable directed graphs with the minimum number of nodes.

翻译中…

Note

翻译中…

In the first test case, the minimum number of nodes required to create a $3$-reachable directed graph is $3$. Among all $3$-reachable directed graphs with $3$ nodes, the following graph $G$ is one of the graphs with the maximum number of unidirectional pairs of nodes, which is $0$.

翻译中…

image

翻译中…

样例

Input #1
3
Output #1
3 0
InputCopy OutputCopy
Input #2
4
Output #2
5 6
InputCopy OutputCopy
Input #3
0
Output #3
0 0
InputCopy OutputCopy
题目信息
题号
1763E
时间限制
2 s
内存限制
256 MB
标签
动态规划
图论
数学
数论

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