POJ2263 Heavy Cargo

本文介绍了一个经典的货运路径规划问题,即如何确定最大载重量使得货车能够从起点城市行驶到终点城市而不违反任何道路的载重限制。通过将城市映射为数字,并使用图论中的最短路径算法变形来解决该问题。

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

                                                                                         Heavy Cargo
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 2412 Accepted: 1321

Description

Big Johnsson Trucks Inc. is a company specialized in manufacturing big trucks. Their latest model, the Godzilla V12, is so big that the amount of cargo you can transport with it is never limited by the truck itself. It is only limited by the weight restrictions that apply for the roads along the path you want to drive.

Given start and destination city, your job is to determine the maximum load of the Godzilla V12 so that there still exists a path between the two specified cities.

Input

The input will contain one or more test cases. The first line of each test case will contain two integers: the number of cities n (2<=n<=200) and the number of road segments r (1<=r<=19900) making up the street network.
Then r lines will follow, each one describing one road segment by naming the two cities connected by the segment and giving the weight limit for trucks that use this segment. Names are not longer than 30 characters and do not contain white-space characters. Weight limits are integers in the range 0 - 10000. Roads can always be travelled in both directions.
The last line of the test case contains two city names: start and destination.
Input will be terminated by two values of 0 for n and r.

Output

For each test case, print three lines:
  • a line saying "Scenario #x" where x is the number of the test case
  • a line saying "y tons" where y is the maximum possible load
  • a blank line

Sample Input

4 3
Karlsruhe Stuttgart 100
Stuttgart Ulm 80
Ulm Muenchen 120
Karlsruhe Muenchen
5 5
Karlsruhe Stuttgart 100
Stuttgart Ulm 80
Ulm Muenchen 120
Karlsruhe Hamburg 220
Hamburg Muenchen 170
Muenchen Karlsruhe
0 0

Sample Output

Scenario #1
80 tons
 
Scenario #2
170 tons

Source

 
 
思路:给出N个地点,然后给出这些地点之间的路径可以承受的汽车最大的压力。首先将这N个地点映射为数字。然后建立矩阵。最后可以用求最短路径的方法进行变形,从而求出答案。
 
 
  1 #include <cstdlib>
  2 #include <iostream>
  3 #include <cstdio>
  4 #include <cstring>
  5 #include <cmath>
  6 #include <string>
  7 #include <map>
  8 
  9 #define MAXINT 99999999
 10 
 11 using namespace std;
 12 
 13 int data[204][204];
 14 int dis[204];
 15 int isVis[204];
 16 
 17 
 18 char maps[204][34];
 19 int length=0;
 20 
 21 
 22 int findv(char str[34])
 23 {
 24     int i;
 25     for(i=1;i<length;i++)
 26     {
 27                          if(strcmp(maps[i],str)==0)
 28                          return i;
 29     }
 30     
 31     
 32 
 33 
 34 
 35 strcpy(maps[length],str);
 36 length++;
 37 
 38 return length-1;
 39 }
 40 
 41 
 42 
 43 int minn(int x,int y)
 44 {if(x>y)
 45 return y;
 46 return x;
 47 }
 48 
 49 
 50 
 51 
 52 
 53 
 54 
 55 int main(int argc, char *argv[])
 56 {
 57               
 58               int i,j,k;
 59               int n,m;
 60               int ncount=0;
 61               
 62               
 63               while(scanf("%d%d",&n,&m)!=EOF)
 64               {
 65                                              if((n==0)&&(m==0))
 66                                              break;
 67                                              
 68                                              length=1;
 69                                              
 70                                              getchar();
 71                                              
 72                                              
 73                                              
 74                                              
 75                                              
 76                                              
 77                                              ncount++;
 78                                              
 79                                              for(i=1;i<=n;i++)
 80                                              for(j=1;j<=n;j++)
 81                                              data[i][j]=0;
 82                                              
 83                                              
 84                                              
 85                                              for(i=1;i<=m;i++)
 86                                              {
 87                                                               char s1[34],s2[34];
 88                                                               int w;
 89                                                               
 90                                                               scanf("%s%s%d",s1,s2,&w);
 91                                                               
 92                                                               getchar();
 93                                                               
 94                                                               
 95                                                               int v1=findv(s1);
 96                                                               int v2=findv(s2);
 97                                                               
 98                                                               
 99                                                               data[v1][v2]=data[v2][v1]=w;
100                                              }
101                                              
102                                              
103                                              char s1[34],s2[34];
104                                              
105                                              scanf("%s%s",s1,s2);
106                                              getchar();
107                                              
108                                              
109                                              int startv=findv(s1);
110                                              int endv=findv(s2);
111                                              
112                                              
113                                              
114                                              
115                                              
116                                              for(i=1;i<=n;i++)
117                                              isVis[i]=0;
118                                              
119                                              for(i=1;i<=n;i++)
120                                              {dis[i]=data[startv][i];}
121                                              
122                                              
123                                              
124                                              int maxdis=0;
125                                              isVis[startv]=1;
126                                              
127                                              for(i=1;i<=n;i++)
128                                              {
129                                                               k=-1;
130                                                               maxdis=0;
131                                                               
132                                                               for(j=1;j<=n;j++)
133                                                               {
134                                                                                if((isVis[j]==0)&&(maxdis<dis[j]))
135                                                                                {k=j;maxdis=dis[j];}
136                                                               }
137                                                               
138                                                               
139                                                               isVis[k]=1;
140                                                               
141                                                              
142                                                               for(j=1;j<=n;j++)
143                                                               {
144                                                                                int tmp=minn(dis[k],data[k][j]);
145                                                                                if((isVis[j]==0)&&(dis[j]<tmp))
146                                                                                {dis[j]=tmp;}
147                                                               }
148                                              }
149                                              
150                                              
151                                              printf("Scenario #%d\n",ncount);
152                                              
153 
154                                              
155                                              printf("%d tons\n\n",dis[endv]);
156 
157               }
158                                              
159                                              
160                                              
161                                                               
162                                                               
163                                              
164                                              
165                                              
166                                              
167                                                               
168                                                               
169                                                               
170                                                               
171                                                                      
172                             
173                             
174                             
175                             
176                             
177     
178     
179     
180     
181     //system("PAUSE");
182     return EXIT_SUCCESS;
183 }

 

转载于:https://www.cnblogs.com/zjushuiping/archive/2012/08/18/2645484.html

内容概要:该研究通过在黑龙江省某示范村进行24小时实地测试,比较了燃煤炉具与自动/手动进料生物质炉具的污染物排放特征。结果显示,生物质炉具相比燃煤炉具显著降低了PM2.5、CO和SO2的排放(自动进料分别降低41.2%、54.3%、40.0%;手动进料降低35.3%、22.1%、20.0%),但NOx排放未降低甚至有所增加。研究还发现,经济性和便利性是影响生物质炉具推广的重要因素。该研究不仅提供了实际排放数据支持,还通过Python代码详细复现了排放特征比较、减排效果计算和结果可视化,进一步探讨了燃料性质、动态排放特征、碳平衡计算以及政策建议。 适合人群:从事环境科学研究的学者、政府环保部门工作人员、能源政策制定者、关注农村能源转型的社会人士。 使用场景及目标:①评估生物质炉具在农村地区的推广潜力;②为政策制定者提供科学依据,优化补贴政策;③帮助研究人员深入了解生物质炉具的排放特征和技术改进方向;④为企业研发更高效的生物质炉具提供参考。 其他说明:该研究通过大量数据分析和模拟,揭示了生物质炉具在实际应用中的优点和挑战,特别是NOx排放增加的问题。研究还提出了多项具体的技术改进方向和政策建议,如优化进料方式、提高热效率、建设本地颗粒厂等,为生物质炉具的广泛推广提供了可行路径。此外,研究还开发了一个智能政策建议生成系统,可以根据不同地区的特征定制化生成政策建议,为农村能源转型提供了有力支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值