CF1129E.Legendary Tree

NOI/NOI+/CTSC

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

This is an interactive problem.

A legendary tree rests deep in the forest. Legend has it that individuals who realize this tree would eternally become a Legendary Grandmaster.

To help you determine the tree, Mikaela the Goddess has revealed to you that the tree contains nn vertices, enumerated from 11 through nn. She also allows you to ask her some questions as follows. For each question, you should tell Mikaela some two disjoint non-empty sets of vertices SS and TT, along with any vertex vv that you like. Then, Mikaela will count and give you the number of pairs of vertices (s,t)(s, t) where s∈Ss \in S and t∈Tt \in T such that the simple path from ss to tt contains vv.

Mikaela the Goddess is busy and will be available to answer at most 11 11111\,111 questions.

This is your only chance. Your task is to determine the tree and report its edges.

这是一个交互式问题。

一棵传说中的树深藏于森林之中。传说,凡能识得此树者,将永为“传奇大师”。

为助你确定这棵树,女神米凯拉向你揭示:该树包含 nn 个顶点,编号为 11 至 nn。她还允许你向她提出若干问题,形式如下:对每个问题,你需向米凯拉指定两个互不相交的非空顶点集合 SS 和 TT,以及任一顶点 vv;随后,米凯拉将统计并告诉你满足以下条件的顶点对 (s,t)(s, t) 的数量:其中 s∈Ss \in S、t∈Tt \in T,且从 ss 到 tt 的简单路径经过顶点 vv。

女神米凯拉事务繁忙,最多只愿回答 11 11111\,111 个问题。

这是你唯一的机会。你的任务是确定该树的结构,并报告其所有边。

输入格式

The first line contains an integer nn (2≤n≤5002 \leq n \leq 500) — the number of vertices in the tree.

第一行包含一个整数 nn(2≤n≤5002 \leq n \leq 500)——树中顶点的数量。

输出格式

When program has realized the tree and is ready to report the edges, print "ANSWER" in a separate line. Make sure that all letters are capitalized.

Then, print n−1n-1 lines, each containing two space-separated integers, denoting the vertices that are the endpoints of a certain edge. Each edge should be reported exactly once. Your program should then immediately terminate.

当程序已构建好树并准备报告边时,请在单独一行中输出 “ANSWER”。请确保所有字母均为大写。

然后,输出 n−1n-1 行,每行包含两个以空格分隔的整数,表示某条边的两个端点顶点。每条边必须且仅能报告一次。此后,您的程序应立即终止。

输入输出样例

  • 输入#1

    5
    5

    输出#1

    3
    1 2 3
    2
    4 5
    2
    ANSWER
    1 2
    2 3
    3 4
    2 5

说明/提示

In the sample, the tree is as follows.

n=5n = 5 is given to the program. The program then asks Mikaela a question where S=1,2,3S = {1, 2, 3}, T=4,5T = {4, 5}, and v=2v = 2, to which she replies with 55 (the pairs (s,t)(s, t) are (1,4)(1, 4), (1,5)(1, 5), (2,4)(2, 4), (2,5)(2, 5), and (3,5)(3, 5)).

在样例中,树的结构如下所示。

程序输入 n=5n = 5。随后,程序向米凯拉提出一个问题:其中 S={1,2,3}S = \{1, 2, 3\},T={4,5}T = \{4, 5\},且 v=2v = 2;她回答 55(满足条件的点对 (s,t)(s, t) 为 (1,4)(1, 4)、(1,5)(1, 5)、(2,4)(2, 4)、(2,5)(2, 5) 和 (3,5)(3, 5))。

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

首页