QOJ.ac

QOJ

Limite de temps : 3.0 s Limite de mémoire : 512 MB Points totaux : 100

#2194. DevOps 最佳实践

Statistiques

Daisy 是 RainyDay, LLC 的一名高级软件工程师。她刚刚在产品中实现了三个新功能:第一个功能使产品能够工作,第二个功能使产品运行更快,第三个功能使产品更加准确。公司鼓励对新功能进行至少一定程度的测试,因此 Daisy 指派她的实习生 Demid 为这些新功能编写了一些测试。

有趣的是,这三个功能在 Demid 的开发服务器(编号为 1)上都能通过所有测试,但在其他一些服务器上可能会失败。

在 Demid 完成这项任务后,Daisy 指派你将这三个功能部署到公司的所有 $n$ 台服务器上。对于每个功能 $f$ 和每台服务器 $s$,Daisy 都告诉你她是否希望将功能 $f$ 部署到服务器 $s$ 上。如果她希望部署,那么即使功能 $f$ 在服务器 $s$ 上测试失败,也必须进行部署。如果她不希望部署,则不得在该服务器上部署该功能。

公司有两种重要的工具用于向服务器部署新功能:持续部署 (CD) 和持续测试 (CT)。CD 可以在若干服务器对之间建立,形成一个有向图。CT 可以在一组服务器上设置。

如果配置了从服务器 $s_1$ 到服务器 $s_2$ 的 CD,那么每当 $s_1$ 接收到一个新功能 $f$ 时,系统就会启动以下针对 $f$ 到 $s_2$ 的部署过程:

  • 如果功能 $f$ 已经部署在服务器 $s_2$ 上,则不执行任何操作。
  • 否则,如果服务器 $s_1$ 上没有设置 CT,则服务器 $s_1$ 直接将功能 $f$ 部署到服务器 $s_2$,无需任何测试。
  • 否则,服务器 $s_1$ 会对功能 $f$ 进行测试。如果测试在服务器 $s_1$ 上失败,则不执行任何操作。如果测试通过,则服务器 $s_1$ 将功能 $f$ 部署到服务器 $s_2$。

你需要配置 CD/CT 系统,之后 Demid 将在他的开发服务器上部署所有三个功能。你的 CD/CT 系统必须将每个功能精确地部署到 Daisy 想要的服务器集合中。

公司没有太多的计算资源,因此你建立的从一台服务器到另一台服务器的 CD 连接最多只能有 264 条。

输入格式

第一行包含整数 $n$ ($2 \le n \le 256$),表示公司中的服务器数量。

接下来的 $n$ 行,每行包含三个整数。第 $i$ 行的第 $j$ 个整数为 1 表示 Daisy 希望将第 $j$ 个功能部署到第 $i$ 台服务器,否则为 0。

接下来的 $n$ 行,每行包含三个整数。第 $i$ 行的第 $j$ 个整数为 1 表示第 $j$ 个功能在第 $i$ 台服务器上的测试通过,否则为 0。

Demid 的开发服务器编号为 1。保证 Daisy 希望将所有三个功能都部署到 1 号服务器,且所有三个功能在 1 号服务器上的测试均通过。

输出格式

如果无法在最多 264 条 CD 连接的限制下配置 CD/CT 系统,则输出一行 "Impossible"。

否则,输出的第一行必须包含 "Possible"。

下一行必须包含 $n$ 个空格分隔的整数,表示 CT 的配置。如果第 $i$ 台服务器设置了 CT,则第 $i$ 个整数应为 1,否则为 0。

下一行必须包含整数 $m$ ($0 \le m \le 264$),表示你想要设置的 CD 连接数量。

接下来的 $m$ 行,每行描述一个 CD 配置,包含两个整数 $s_i$ 和 $t_i$ ($1 \le s_i, t_i \le n; s_i \neq t_i$),表示建立从服务器 $s_i$ 到服务器 $t_i$ 的自动化功能部署。

样例

输入 1

3
1 1 1
1 0 1
1 1 1
1 1 1
0 0 0
1 0 1

输出 1

Possible
1 1 1
2
3 2
1 3

输入 2

2
1 1 1
0 0 1
1 1 1
1 1 0

输出 2

Impossible

说明

第一个样例的 CD/CT 系统配置如下图所示:

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.