309946: CF1763E. Node Pairs

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Node Pairs

题意翻译

在一个有向图中,一个节点对 $ ( u , v ) $ 如果满足 $ u \ne v $,$ u $ 能到达 $ v $ 且 $ v $ 不能到达 $ u $,则称其为单向节点对。 如果一个有向图刚好存在 $ p $ 对节点 $ ( u , v) $($ u < v $ 且二者能互相到达),则称这是一个 $ p $ 可达图,求节点最少的 $ p $ 可达图的节点数。 同时,定义图 $ G $ 为在所有节点数最少的 $ p $ 可达图中,单向节点对数量最多的图,求出图 $ G $ 中单向节点对的个数。

题目描述

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.

输入输出格式

输入格式


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 $ . ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1763E/056ef4fb4b6b27a5f901099fab6d214793a2d54c.png)

Input

题意翻译

在一个有向图中,一个节点对 $ ( u , v ) $ 如果满足 $ u \ne v $,$ u $ 能到达 $ v $ 且 $ v $ 不能到达 $ u $,则称其为单向节点对。 如果一个有向图刚好存在 $ p $ 对节点 $ ( u , v) $($ u < v $ 且二者能互相到达),则称这是一个 $ p $ 可达图,求节点最少的 $ p $ 可达图的节点数。 同时,定义图 $ G $ 为在所有节点数最少的 $ p $ 可达图中,单向节点对数量最多的图,求出图 $ G $ 中单向节点对的个数。

加入题单

算法标签: