当前位置:网站首页>[ybtoj advanced training guide] maximum separation [hash] [Floyd]
[ybtoj advanced training guide] maximum separation [hash] [Floyd]
2022-06-28 09:14:00 【VL——MOESR】

Ideas :
Just use your name hash save , When you meet a new one, open one , then Floyd
This is used here. map
c o d e code code
#include<iostream>
#include<map>
#include<cstring>
#include<cstdio>
using namespace std;
int n, m;
int dis[55][55];
map<string, int> a;
int main()
{
int t=0;
while(1)
{
t++;
scanf("%d%d", &n, &m);
if(n==m&&n==0)
break;
a.clear();
memset(dis, 0x3f3f3f3f3f, sizeof(dis));
for(int i=1; i<=n; i++) dis[i][i]=0;
for(int i=1, j=0; i<=m; i++)
{
string s1, s2;
cin>>s1>>s2;
if(a[s1]==0)
a[s1]=++j;
if(a[s2]==0)
a[s2]=++j;
dis[a[s1]][a[s2]]=dis[a[s2]][a[s1]]=1;
}
for(int k=1; k<=n; k++)
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
if(dis[i][j]>dis[i][k]+dis[k][j])
dis[i][j]=dis[i][k]+dis[k][j];
int ans=0;
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
ans=max(ans, dis[i][j]);
if(ans==1061109567)
printf("Network %d: DISCONNECTED\n", t);
else printf("Network %d: %d\n", t, ans);
}
return 0;
}
/* 4 4 Ashok Kiyoshi Ursala Chun Ursala Kiyoshi Kiyoshi Chun */
边栏推荐
- 小程序 :遍历list里面的某个数组的值,等同于 for=“list” list.comment里面的某一项
- Is it safe for Huatai Securities to open an account online? What is the handling process
- 自动转换之-面试题
- 两道面试小Demo
- 硬盘基本知识(磁头、磁道、扇区、柱面)
- 我想网上注册股票开户,如何操作?在线开户安全么?
- Scenario method and error recommendation method for learning basic content of software testing (2)
- Prototype chain JS
- redis5.0的槽点迁移,随意玩(单机迁移集群)
- Container adapter - stack: stack queue: queue priority_ Queue: priority queue
猜你喜欢

基于宽表的数据建模

SQL 优化经历:从 30248秒到 0.001秒的经历

1182:合影效果

DEJA_ Vu3d - 051 of cesium function set - perfect realization of terrain excavation

从知识到智慧:知识图谱还要走多远?

Music website design based on harmonyos (portal page)

Common tools for interface testing --postman
![1180:分数线划定/P1068 [NOIP2009 普及组] 分数线划定](/img/1a/162b060a6498e58278b6ca50e4953c.png)
1180:分数线划定/P1068 [NOIP2009 普及组] 分数线划定

Guangzhou: new financial activities and new opportunities for enterprises

MATLAB小技巧(20)矩阵分析--主成分回归
随机推荐
Maintenance and protection of common faults of asynchronous motor
APICloud携手三六零天御,助力企业守好App安全“第一关”
怎样在手机上开户?现在网上开户安全么?
Fire fighting work and measures in Higher Vocational Colleges
1. Kimball dimension modeling of data warehouse: what is a fact table?
实现全局双指长按返回桌面
Application of energy management system in iron and steel enterprises
rman備份報ORA-19809 ORA-19804
Error: `brew cask` is no longer a `brew` command. Use `brew <command> --cask` instead.
华泰证券网上开户安全吗 办理流程是什么
Potential safety hazards in elderly care facilities
[share OpenGL tutorial]
Boundary value analysis method for learning basic content of software testing (2)
【大案例】学成在线网站
How to solve the problem of high concurrency and seckill
Characteristics and prevention of electrical fire
为什么SELECT * 会导致查询效率低?
1180: fractional line delimitation /p1068 [noip2009 popularization group] fractional line delimitation
Is it safe for Huatai Securities to open an account online? What is the handling process
Construire le premier réseau neuronal avec pytorch et optimiser