CF1763E.Node Pairs

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

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

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

我们称有向图中的一对有序节点 (u,v)(u, v) 是单向的(unidirectional),如果 u≠vu \neq v,存在一条从 uu 到 vv 的路径,但不存在从 vv 到 uu 的路径。

若一个有向图恰好包含 pp 个满足 u<vu \lt v 且 uu 与 vv 相互可达(即存在从 uu 到 vv 的路径,也存在从 vv 到 uu 的路径)的有序节点对 (u,v)(u, v),则称该有向图为 pp-可达的(pp-reachable)。求构造一个 pp-可达有向图所需的最少节点数。

此外,在所有具有最少节点数的 pp-可达有向图中,设 GG 为其中单向节点对数量最多的一个图。求该最大数量。

输入格式

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

第一行且唯一一行包含一个整数 pp(0≤p≤2⋅1050 \le p \le 2 \cdot 10^5)—— 表示节点的有序对数量。

输出格式

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

输出一行,包含两个整数——构造一个 pp-可达有向图所需的最少节点数,以及在所有具有该最少节点数的 pp-可达有向图中,单向节点对的最大数目。

输入输出样例

  • 输入#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 33-reachable directed graph is 33. Among all 33-reachable directed graphs with 33 nodes, the following graph GG is one of the graphs with the maximum number of unidirectional pairs of nodes, which is 00.

在第一个测试用例中,构造一个 33-可达有向图所需的最少节点数为 33。在所有含 33 个节点的 33-可达有向图中,下图 GG 是具有最多单向节点对数量(即 00)的图之一。

输入解题思路,AI测评打分。不知道怎么写?

首页