1227. Rally Championship

博客介绍了Rally Championship,包含输入、输出及示例内容,转载自https://www.cnblogs.com/sdau--codeants/p/3256770.html 。

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

1227. Rally Championship

Time limit: 1.0 second Memory limit: 64 MB
A high-level international rally championship is about to be held. The rules of the race state that the race is held on ordinary roads and the route has a fixed length. You are given a map of the cities and two-way roads connecting it. To make the race safer it is held on one-way roads. The race may start and finish anyplace on the road. Determine if it is possible to make a route having a given length S.

Input

The first line of the input contains the number of cities M, the number of roads N and the length S of the route. 1 ≤ M ≤ 100; 1 ≤ N ≤ 10000; 1 ≤ S ≤ 106. S is integer.
The following N lines describe the roads as triples of integers: P, Q, R. Here P and Q are cities connected with a road, and R is the length of this road. All numbers satisfy the following restrictions: 1 ≤ P, Q  M; 1 ≤ R ≤ 32000.

Output

Write YES to the output if it is possible to make a required route and NO otherwise. Note that answer must be written in capital Latin letters.

Samples

inputoutput
3 2 20
1 2 10
2 3 5
NO
3 3 1000
1 2 1
2 3 1
1 3 1
YES
Problem Source: 2002-2003 ACM Central Region of Russia Quarterfinal Programming Contest, Rybinsk, October 2002
***************************************************************************************
判断环是否存在,同时求路径的长度  不用记录路径,可直接深搜,满足条件返回
***************************************************************************************
 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<string>
 5 #include<vector>
 6 #include<algorithm>
 7 #include<stack>
 8 using namespace std;
 9 long map[1001][1001];//邻接矩阵存图
10 bool  vis[1001]={false};//标记数组
11 bool  gs;
12 int n,m,p,q,i,j,k,start;
13 long ans,s,r;
14 void dfs(int x,long st)//深搜,判断是否存在环,st为长度
15    {
16      ans=st;
17      if(ans>=s)//路径>=s满足条件返回
18      {
19          gs=true;
20          return;
21      }
22 
23      for(int is=1;is<=m;is++)
24       {
25           if(!vis[is]&&map[x][is])
26            {
27                vis[is]=true;
28                long  temp=map[x][is];
29                map[x][is]=map[is][x]=0;
30                if(is==start)//存在环返回
31                 {
32                     gs=true;
33                     return;
34                 }
35             dfs(is,st+temp);
36             map[x][is]=map[is][x]=temp;//还原
37             vis[is]=false;
38             if(gs==true)//为了保险,可能多此一举
39              return;
40 
41            }
42       }
43  }
44  int main()
45  {
46      cin>>m>>n>>s;
47      memset(vis,false,sizeof(vis));
48      memset(map,0,sizeof(map));
49      gs=false;
50      for(i=1;i<=n;i++)
51       {
52           cin>>p>>q>>r;
53           if(map[p][q]==0)
54            map[p][q]=map[q][p]=r;
55           else
56             gs=true;
57       }
58       if(gs==true)
59        {
60            cout<<"YES"<<endl;
61            return 0;
62        }
63        int max1=-1;
64       for(i=1;i<=m;i++)
65        if(!vis[i])
66          {
67              start=i;
68 
69              dfs(i,0);
70              memset(vis,false,sizeof(vis));
71              if(gs==true)
72               {
73                   cout<<"YES"<<endl;
74                   return 0;
75               }
76          }
77           cout<<"NO"<<endl;
78         return 0;
79 
80 
81 
82  }
View Code

 

转载于:https://www.cnblogs.com/sdau--codeants/p/3256770.html

内容概要:本文介绍了奕斯伟科技集团基于RISC-V架构开发的EAM2011芯片及其应用研究。EAM2011是一款高性能实时控制芯片,支持160MHz主频和AI算法,符合汽车电子AEC-Q100 Grade 2和ASIL-B安全标准。文章详细描述了芯片的关键特性、配套软件开发套件(SDK)和集成开发环境(IDE),以及基于该芯片的ESWINEBP3901开发板的硬件资源和接口配置。文中提供了详细的代码示例,涵盖时钟配置、GPIO控制、ADC采样、CAN通信、PWM输出及RTOS任务创建等功能实现。此外,还介绍了硬件申领流程、技术资料获取渠道及开发建议,帮助开发者高效启动基于EAM2011芯片的开发工作。 适合人群:具备嵌入式系统开发经验的研发人员,特别是对RISC-V架构感兴趣的工程师和技术爱好者。 使用场景及目标:①了解EAM2011芯片的特性和应用场景,如智能汽车、智能家居和工业控制;②掌握基于EAM2011芯片的开发板和芯片的硬件资源和接口配置;③学习如何实现基本的外设驱动,如GPIO、ADC、CAN、PWM等;④通过RTOS任务创建示例,理解多任务处理和实时系统的实现。 其他说明:开发者可以根据实际需求扩展这些基础功能。建议优先掌握《EAM2011参考手册》中的关键外设寄存器配置方法,这对底层驱动开发至关重要。同时,注意硬件申领的时效性和替代方案,确保开发工作的顺利进行。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值