zoj 3811 Untrusted Patrol 图论 The 2014 ACM-ICPC Asia Mudanjiang Regional First Round

本文深入探讨了一种算法,用于解决在有摄像头监控的仓库中,安保人员按照特定路径检查所有货物堆的可能性。通过分析无向图模型,识别关键路径并验证传感器记录的数据一致性,实现高效仓库安全管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3811

Edward is a rich man. He owns a large factory for health drink production. As a matter of course, there is a large warehouse in the factory.

To ensure the safety of drinks, Edward hired a security man to patrol the warehouse. The warehouse has N piles of drinks and M passageways connected them (warehouse is not big enough). When the evening comes, the security man will start to patrol the warehouse following a path to check all piles of drinks.

Unfortunately, Edward is a suspicious man, so he sets sensors on K piles of the drinks. When the security man comes to check the drinks, the sensor will record a message. Because of the memory limit, the sensors can only record for the first time of the security man's visit.

After a peaceful evening, Edward gathered all messages ordered by recording time. He wants to know whether is possible that the security man has checked all piles of drinks. Can you help him?

The security man may start to patrol at any piles of drinks. It is guaranteed that the sensors work properly. However, Edward thinks the security man may not works as expected. For example, he may digs through walls, climb over piles, use some black magic to teleport to anywhere and so on.

Input

There are multiple test cases. The first line of input is an integer T indicates the number of test cases. For each test case:

The first line contains three integers N (1 <= N <= 100000), M (1 <= M <= 200000) and K (1 <= K <= N).

The next line contains K distinct integers indicating the indexes of piles (1-based) that have sensors installed. The following M lines, each line contains two integers Ai and Bi (1 <= Ai, Bi <= N) which indicates a bidirectional passageway connects piles Ai and Bi.

Then, there is an integer L (1 <= L <= K) indicating the number of messages gathered from all sensors. The next line contains L distinct integers. These are the indexes of piles where the messages came from (each is among the K integers above), ordered by recording time.

Output

For each test case, output "Yes" if the security man worked normally and has checked all piles of drinks, or "No" if not.

Sample Input
2
5 5 3
1 2 4
1 2
2 3
3 1
1 4
4 5
3
4 2 1
5 5 3
1 2 4
1 2
2 3
3 1
1 4
4 5
3
4 1 2
Sample Output
No
Yes

Author: DAI, Longao
Source: The 2014 ACM-ICPC Asia Mudanjiang Regional First Round


题意:有一个n<=10^5个点m<=2*10^5条边的无向图。在其中k个点有摄像头。第一次进入有摄像头的点会被记录。有l条记录按照时间顺序给出。问是否存在从某一点开始的一种走法(可以经过重复的点或边)访问了所有点且满足摄像头那些点的限制。

参考了大神的解法...http://www.mahoushojo.com:8080/mediawiki/index.php/14-09-07_Online

解法:如果l<k必然无解。否则先空降第一个点,每次先遍历周围所有不带摄像头的点,再看是否能走到序列中的下一个点。

代码:

#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>

using namespace std;

#define min2(x, y)     min(x, y)
#define max2(x, y)     max(x, y)
#define min3(x, y, z)  min(x, min(y, z))
#define max3(x, y, z)  max3(x, max(y, z))
#define clr(x, y)      memset(x, y, sizeof(x))
#define fr(i,n)        for(int i = 0; i < n; i++)
#define fr1(i,n)       for(int i = 1; i < n; i++)
#define upfr(i,j,n)    for(int i = j; i <= n; i++)
#define dowfr(i,j,n)   for(int i = n; i >= j; i--)
#define scf(n)         scanf("%d", &n)
#define scf2(n,m)      scanf("%d %d",&n,&m)
#define scf3(n,m,p)    scanf("%d %d %d",&n,&m,&p)
#define ptf(n)         printf("%d",n)
#define ptf64(n)       printf("%I64d",n)
#define ptfs(s)        printf("%s",s)
#define ptln()         printf("\n")
#define ptk()          printf(" ")
#define ptc(c)         printf("%c",c)
#define srt(a,n)       sort(a,n)
#define LL long long
#define pi acos(-1.0)
#define inf 1 << 31-1
#define eps 0.00001
#define maxn 100005
#define mod 10000007

vector <int >e[maxn];
int vis[maxn],jianshi[maxn],keda[maxn],id[maxn];
int N,M,K,L;
void bfs(int u)                  //从u开始,走到u周围所有的非监视器的点
{
    jianshi[u] = 0;
    vis[u] = 1;
    queue <int> q;
    q.push(u);
    while(!q.empty())
    {
        int uu = q.front();
        q.pop();
        vis[uu] = 1;
        fr(i, (int)e[uu].size())
        {
            int v = e[uu][i];
            if(!vis[v] && !keda[v])
            {
                keda[v] = 1;        //标记能到达的点
                if(!jianshi[v])
                q.push(v);
            }
        }
    }
}
int main()
{
    int t;
    scf(t);
    while(t--)
    {
        scf3(N, M, K);
        clr(e, 0);
        clr(vis, 0);
        clr(jianshi, 0);
        clr(keda, 0);
        fr(i, K)
        {
            int u;
            scf(u);
            u--;
            jianshi[u] = 1;
        }
        fr(i, M)
        {
            int u, v;
            scf2(u, v);
            u--,v--;
            e[u].push_back(v);
            e[v].push_back(u);
        }
        scf(L);
        fr(i, L)
        {
            scf(id[i]);
            id[i]--;
        }
        if(L < K)                  //监视器都没有走完,必然是No
        {
            printf("No\n");
            continue;
        }
        int ok = 1;
        bfs(id[0]);
        for(int j = 1; j < L && ok; j++)
        {
            if(!keda[id[j]])     //对于给定序列,如果不能到达下一个点,则结果为No
                ok = 0;
            else
                bfs(id[j]);
        }
        fr(i, N)
        if(!vis[i])             //最后遍历一下所有点,判断是否存在未访问到的点
            ok = 0;
        if(ok)
            printf("Yes\n");
        else
            printf("No\n");
    }
    return 0;
}


内容概要:论文提出了一种基于空间调制的能量高效分子通信方案(SM-MC),将传输符号分为空间符号和浓度符号。空间符号通过激活单个发射纳米机器人的索引来传输信息,浓度符号则采用传统的浓度移位键控(CSK)调制。相比现有的MIMO分子通信方案,SM-MC避免了链路间干扰,降低了检测复杂度并提高了性能。论文分析了SM-MC及其特例SSK-MC的符号错误率(SER),并通过仿真验证了其性能优于传统的MIMO-MC和SISO-MC方案。此外,论文还探讨了分子通信领域的挑战、优势及相关研究工作,强调了空间维度作为新的信息自由度的重要性,并提出了未来的研究方向和技术挑战。 适合人群:具备一定通信理论基础,特别是对纳米通信和分子通信感兴趣的科研人员、研究生和工程师。 使用场景及目标:①理解分子通信中空间调制的工作原理及其优势;②掌握SM-MC系统的具体实现细节,包括发射、接收、检测算法及性能分析;③对比不同分子通信方案(如MIMO-MC、SISO-MC、SSK-MC)的性能差异;④探索分子通信在纳米网络中的应用前景。 其他说明:论文不仅提供了详细的理论分析和仿真验证,还给出了具体的代码实现,帮助读者更好地理解和复现实验结果。此外,论文还讨论了分子通信领域的标准化进展,以及未来可能的研究方向,如混合调制方案、自适应调制技术和纳米机器协作协议等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值