一条小小yu 2022-02-13 12:37 采纳率: 0%
浏览 27
已结题

图论题,非常感谢你的帮助

题目描述
题目There is a directed graph with N vertices and N edges. The vertices are numbered 1,2,…,N.
The graph has the following N edges: (p1,1),(p2,2),…,(pN,N), and the graph is weakly connected. Here, an edge from Vertex u to Vertex v is denoted by (u,v), and a weakly connected graph is a graph which would be connected if each edge was bidirectional.
We would like to assign a value to each of the vertices in this graph so that the following conditions are satisfied. Here, ai is the value assigned to Vertex i.
Each ai is a non-negative integer.
For each edge (i,j), ai≠aj holds.
For each i and each integer x(0≤x<ai), there exists a vertex j such that the edge (i,j) exists and x=aj holds.
Determine whether there exists such an assignment.

Constraints
2≤N≤200 000
1≤pi≤N
pi≠i
The graph is weakly connected.
输入
Input is given from Standard Input in the following format:
N
p1 p2 ... pN
输出
If the assignment is possible, print POSSIBLE; otherwise, print IMPOSSIBLE.
样例输入 Copy
4
2 3 4 1
样例输出 Copy
POSSIBLE
提示
The assignment is possible: {ai} = {0,1,0,1} or {ai} = {1,0,1,0}.

  • 写回答

1条回答 默认 最新

  • 有问必答小助手 2022-02-14 14:33
    关注

    你好,我是有问必答小助手,非常抱歉,本次您提出的有问必答问题,技术专家团超时未为您做出解答


    本次提问扣除的有问必答次数,将会以问答VIP体验卡(1次有问必答机会、商城购买实体图书享受95折优惠)的形式为您补发到账户。


    因为有问必答VIP体验卡有效期仅有1天,您在需要使用的时候【私信】联系我,我会为您补发。

    评论

报告相同问题?

问题事件

  • 系统已结题 2月21日
  • 创建了问题 2月13日

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊