A15489 | Node Pairs
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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 < 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.
A directed graph is called $p$ -reachable if it contains exactly $p$ ordered pairs of nodes $(u, v)$ such that $u < 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.
输入格式
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.
输出格式
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.
输入输出样例
输入 #1
3
输出 #1
3 0
输入 #2
4
输出 #2
5 6
输入 #3
0
输出 #3
0 0
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$ .


C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted