Calling Circles

光栅衍射有入射角时_偏振光栅的衍射角度及衍射效率测量 偏振光栅是一种基于入射光的偏振态实现选择性分光的衍射光学元件,衍射角度取决于光栅线数。通过控制入射光的偏振态,偏振光栅能够调控正一阶和负一阶之间的能量分布。当入射光束偏振态不同时,偏振光栅具有不同的衍射特性。理想的偏振光栅:当入射光为右旋圆偏振光时,只有+1级衍射光,衍射光为左旋圆偏振光。当入射光为左旋圆偏振光时,只有-1级衍射光,衍射光为右旋圆偏振光。当入射光为非圆偏振光时,偏振光栅同... 阅读详情

If you’ve seen television commercials for long-distance phone companies lately, you’ve noticed that
many companies have been spending a lot of money trying to convince people that they provide the
best service at the lowest cost. One company has “calling circles.” You provide a list of people that
you call most frequently. If you call someone in your calling circle (who is also a customer of the same
company), you get bigger discounts than if you call outside your circle. Another company points out
that you only get the big discounts for people in your calling circle, and if you change who you call
most frequently, it’s up to you to add them to your calling circle.
LibertyBell Phone Co. is a new company that thinks they have the calling plan that can put other
companies out of business. LibertyBell has calling circles, but they figure out your calling circle for
you. This is how it works. LibertyBell keeps track of all phone calls. In addition to yourself, your
calling circle consists of all people whom you call and who call you, either directly or indirectly.
For example, if Ben calls Alexander, Alexander calls Dolly, and Dolly calls Ben, they are all within
the same circle. If Dolly also calls Benedict and Benedict calls Dolly, then Benedict is in the same
calling circle as Dolly, Ben, and Alexander. Finally, if Alexander calls Aaron but Aaron doesn’t call
Alexander, Ben, Dolly, or Benedict, then Aaron is not in the circle.
You’ve been hired by LibertyBell to write the program to determine calling circles given a log of
phone calls between people.
Input
The input file will contain one or more data sets. Each data set begins with a line containing two
integers, n and m. The first integer, n, represents the number of different people who are in the data
set. The maximum value for n is 25. The remainder of the data set consists of m lines, each representing
a phone call. Each call is represented by two names, separated by a single space. Names are first names
only (unique within a data set), are case sensitive, and consist of only alphabetic characters; no name
is longer than 25 letters.
For example, if Ben called Dolly, it would be represented in the data file as
Ben Dolly
Input is terminated by values of zero (0) for n and m.
Output
For each input set, print a header line with the data set number, followed by a line for each calling
circle in that data set. Each calling circle line contains the names of all the people in any order within
the circle, separated by comma-space (a comma followed by a space). Output sets are separated by
blank lines.
Sample Input
5 6
Ben Alexander
Alexander Dolly
Dolly Ben
Dolly Benedict
Benedict Dolly
Alexander Aaron
14 34
John Aaron
Aaron Benedict
Betsy John
Betsy Ringo
Ringo Dolly
Benedict Paul
John Betsy
John Aaron
Benedict George
Dolly Ringo
Paul Martha
George Ben
Alexander George
Betsy Ringo
Alexander Stephen
Martha Stephen
Benedict Alexander
Stephen Paul
Betsy Ringo
Quincy Martha
Ben Patrick
Betsy Ringo
Patrick Stephen
Paul Alexander
Patrick Ben
Stephen Quincy
Ringo Betsy
Betsy Benedict
Betsy Benedict
Betsy Benedict
Betsy Benedict
Betsy Benedict
Betsy Benedict
Quincy Martha
0 0
Sample Output
Calling circles for data set 1:
Ben, Alexander, Dolly, Benedict
Aaron
Calling circles for data set 2:
John, Betsy, Ringo, Dolly
Aaron
Benedict
Paul, George, Martha, Ben, Alexander, Stephen, Quincy, Patrick
一些人的通话记录,输出各个电话圈。
用弗洛伊德暴力判断,就可以把所有人的连接情况列出来,这样输出就很好判断了。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
int v[30][30], d[30][30], leap[30];
string gather[30];
int main()
{
    int i, j, m, n, ans, t, kase = 1;
    string a, b;
    while (scanf("%d%d", &n, &m) != EOF)
    {
        map<string, int>p;
        if (!n&&!m)break;
        memset(v, 0, sizeof(v));
        memset(d, 0, sizeof(d));
        memset(leap, 0, sizeof(leap));
        int cnt = 1;
        for (i = 1; i <= m; i++)
        {
            cin >> a >> b;
            if (!p[a])
            {
                p[a] = cnt;
                gather[cnt] = a;
                cnt++;
            }
            if (!p[b])
            {
                p[b] = cnt;
                gather[cnt] = b;
                cnt++;
            }
            d[p[a]][p[b]] = 1;
        }
        int k;
        for (k = 1; k <= n;k++)
        for (i = 1; i <= n;i++)
        for (j = 1; j <= n; j++)
            d[i][j] = d[i][j] || (d[i][k] && d[k][j]);
        if (kase != 1)
            cout << endl;
        cout << "Calling circles for data set " << kase << ":" << endl;
        kase++;
        for (i = 1; i <= n; i++)
        {
            if (!leap[i])
            {
                leap[i] = 1;
                cout << gather[i];
                for (j = i + 1; j <= n; j++)
                {
                    if (!leap[j] && d[i][j] && d[j][i])
                    {
                        cout << ", " << gather[j];
                        leap[j] = 1;
                    }
                }
                cout << endl;
            }
        }
    }
    return 0;
}
手把手教你学Simulink——基于Simulink的PMSM MTPA + FW 全速域平滑切换策略 本文提出一种基于Simulink的PMSM全速域平滑切换控制策略,通过融合MTPA和弱磁控制(FW)实现基速附近的无冲击过渡。在过渡区采用加权融合电流给定方法,使电流超调<5%、转速波动<2%,全速域效率>90%。文章详细介绍了系统架构、核心算法及Simulink建模步骤,包括融合控制器设计、切换逻辑实现和参数优化。仿真结果表明,该方法相比传统硬切换显著改善了动态性能,并扩展了调速范围。同时提供了可直接复用的工程模板和MATLAB代码,为电机控制工程师提供了实用的全速域控制解决方案。 阅读详情

相关推荐

从JT808/JT1078协议到多端协同:构建高并发北斗车辆监控平台的技术实践

本文详细介绍了基于JT808/JT1078协议构建高并发北斗车辆监控平台的技术实践,包括协议解析、高并发架构设计、多端协同实现及数据持久化策略。通过Netty、Kafka等技术优化,系统成功支撑日均2000万条消息处理,为GPS车辆动态监控系统提供了可靠解决方案。

weixin_28358083的博客 224

有向图的传递闭包实现三种实现(Warshall+DFS+BFS)

一、传递闭包: 定义: 有n个顶点的有向图的传递闭包可以定义为一个n阶布尔矩阵T[n][n],如果i能到j则T[i][j] =1,否则T[i][j] =0 意义: 对于无向图,我们可以通过并查集来实现两个顶点是否有通路的快速查询。但有向图不能有并查集,所以现在可以用传递闭包了(当然无向图也可以用) 通过Floyd-Warshall算法https://blog.youkuaiyun.com/qq_4069105...

qq_40691051的博客 2509

(详细总结)python爬取 163收件箱邮件内容,收件箱列表的几种方法(urllib, requests, selenium)

需求:最近有一个需求,需要将163邮箱收件箱里面的所有邮件的内容全部copy下来,整理到一个word里面,不多也就28页的邮件(不要问我为什么有这需求,不告诉你),自己手动去ctrl+ cv 的话,估计要搞吐。然后就想能不能用python的爬虫来实现,虽然过程比较苦(后期改bug改的要吐了)。但是会后还是将需求实现了。这基本也算是入门了 urllib、requests、selenium这几个py...

man_tou_22 1万+

算法导论 第二十五章:有向图的传递闭包

已知一有向图G=,顶点集合V={1,2,...,n},我们可能希望确定对所有顶点对i,j ∈ V,图G中事发后都存在一条从i到 j 的路径。G的传递闭包定义为图,其中:                                                              在Θ(n^3)时间内计算出图的传递闭包的一种方法是对E中每条边赋以权值1,然后运行Floyd-Wars

dllTimes 7953

开源CMDB与资产管理平台对比报告

本文对比分析了9款主流开源CMDB平台,从集成能力、功能完整性和多语言支持三个维度进行评测。重点介绍了VeCMDB、蓝鲸CMDB、WeCMDB和OpsAny等国产平台的特色:VeCMDB以动态模型和自动发现见长;蓝鲸CMDB适合超大规模企业级应用;WeCMDB专注金融级高并发场景;OpsAny提供一体化运维解决方案。针对不同规模企业给出选型建议:中小团队推荐Snipe-IT等轻量工具;大型企业建议蓝鲸或WeCMDB;需国产化适配的可选VeCMDB或OpsAny。文章还特别指出iTop、GLPI等适合ITIL

huang0612123的博客 1079

案例:无人船测量点位数据+ArcGIS 10.6软件生成三维水下地形的两种方法

通常情况下,采用无人船进行水下地形测量,得到的是离散的,具有点号、日期、时间、东坐标(E)、北坐标(N)、水面高程、水下高程和水深等信息的点位数据,该数据一般由航带点位数据加水岸线组成,如下图所示: 原始点位数据格式如下: 下面讲解在ArcGIS软件中生成三维水下地形的两种常用方法。 一、构建不规则三角网(Tin) 1、创建Tin 生成的Tin: 2、Tin转栅格 Tin to Raster: 三维展示: 二、空间插值 栅格插值常用的方法有:克里...

智慧空间实验室 6746

传递闭包(Transitive Closure) POJ 3275

  有时候我们需要知道有向图 G = (V, E)的顶点之间是否存在路径。 那么怎样确定有向图中每对顶点之间是否存在路径呢? 这涉及到一个非常重要的概念—— 有向图的传递闭包。   有向图G的传递闭包定义为 G' = (V, E'), 其中 E' = {(u, v) | 图 G 中存在一条从顶点 u 到顶点 v 的路径}。   我们可在O(n^3)(n为图G中的顶点数)的时间复杂度内计算出有...

weixin_30699443的博客 566

小目标检测之改进的YOLOV11算法

MASF-YOLO通过多尺度特征聚合注意力增强自适应融合三大核心创新,显著提升了无人机视角下的小目标检测性能。

hasakie的博客 1715

uva_247_Calling Circles(floyd传递闭包)

题意:如果两个人互相打电话(直接或者间接),则说他们在同一个电话圈里。例如,a打给b,b打给c,c打给d,d打给a,则这四个人在同一个圈里;如果e打给f,而f不打给e,则不能推出e和f在同一个电话圈。输入n(n<=25)个人的m次电话,找出所有的电话圈。人名只包含字母,不超过25个字符,且不重复。

一点也不二 2374

FISCO BCOS(八)——— 一键部署 WeBase

环境 版本 Java Oracle JDK 8 至 14 MySQL MySQL-5.6及以上 Python Python3.6及以上 PyMySQL 1、获取部署安装包: wget https://osp-1257653870.cos.ap-guangzhou.myqcloud.com/WeBASE/releases/download/v1.5.4/webase-deploy.zip 2、解压安装包: unzip webase-deploy.zip 3、进入目录: c...

林中有神君 3607

【论文汇总】Diffusion Models视频生成/视频编辑/可控视频生成/跨模态视频生成

本文总结了Diffusion Models视频生成领域相关的工作,目前共收录142篇,持续更新中。

沉迷单车的追风少年 1670

Warshall算法-有向图传递闭包

Warshall算法

qq_65213554的博客 2007

YOLOv5源码逐行超详细注释与解读(5)——配置文件yolov5s.yaml

全网最详细的YOLOv5源码解读之配置文件yaml。逐行注释,逐句讲解,一文带你了解yaml。小白必看!

路人贾的博客 1万+

UVa247 Calling Circles

floyd

YHaX的博客 451

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

Calling Circles UVA - 247

这道题超级妙! #include &lt;iostream&gt; #include &lt;bits/stdc++.h&gt; #define maxn 30 using namespace std; struct Edge { int u,v; Edge(int i,int j):u(i),v(j) {} Edge() {} }; int n,m; int p[m...

剑似生平 207

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

UVa 247 Calling Circles

Calling Circles  If you've seen television commercials for long-distance phone companies lately, you've noticed that many companies have been spending a lot of money trying to convince peop

c21c21的专栏 418

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

UVA - 247 Calling Circles

translate 有n个人打电话,给出很多个u->v的打电话的关系 定义u给v打电话(直接或间接),且v给u打电话(直接或间接),则u,v在同一个Calling Circles(电话环)里面 然后输出所有Calling Circles里面的人 analysis 分析后发现,打电话这个关系是有连通性的 在进一步分析的话这个题是符合scc缩点的模式的(tarjan) 于是直接套tarjan就...

AndrewLi的博客 247

UVA247 - Calling Circles

                    UVA247 - Calling Circles题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&amp;Itemid=8&amp;page=show_problem&amp;problem=183题意:n个人互相打电话,则说明他们在一个电话圈,即环内,给定n个人和m次通话,将...

sortmin的博客 301

UVA247- Calling Circles

利用map的特性进行编号,然后利用floyd求出传递闭包,最后又用到DFS进行输出,每一步都很重要。 #include #include #include #include #include #include using namespace std; int n,m,cas=1; mapname; int f[30][30]; int vis[30]; vectorName; void d

AC_dream 961

UVa247 - Calling Circles

#include #include #include #include #include #include #include #include #include using namespace std; const int N = 30; map strMap; map intMap; int idx(string &s); int f[N][N]; int dfn[N]

多看多听多总结 829

UVA 247 Calling Circles

题目大意 如果两个人互相打电话(直接或间接),则说明他们在同一个电话圈里。但如果a打给b,b不打给a 就不算。(刘汝佳书上的描述简化) 因为题目数据范围很小 所以可以给所有打过电话的人直接建一条边,然后跑floyd,如果d[i][j]和d[j][i]都不是inf  i和j就是一个圈子里的 #include #include #include #include #include #inclu

weilehuozhe的专栏 425

UVA247 Calling Circles 解题报告

初始输入的数据当中只知道两人是否有直接打电话,所以先用floyd求传递闭包,G[i][j]表示i是否直接或者间接给j打过电话,当且仅当G[i][j] = G[j][i] = 1时二者处于同一个电话圈,我们可以利用floyd传递闭包后的矩阵G[][]构建一个新图,仅当G[i][j] = G[j][i] = 1时连边,然后跑dfs依次输出各个联通分量。例如,a打给b,b打给c,c打给d,d打给a,则这4个人在同一个圈里;如果e打给f但f不打给e,则不能推出e和f在同一个电话圈里。细节请见代码和注释。

qq_45554473的博客 663

UVa247 Calling Circles

Time Limit:3000MS 64bit IO Format:%lld & %llu map存人名,floyd传递闭包,DFS查询。 输出答案的逗号后面还有个空格,被坑到了233 1 /*by SilverN*/ 2 #include<algorithm> 3 #include<io...

dezhen7015的博客 121
上一篇: Buy or Build
下一篇: Audiophobia
Techay
博客等级 码龄11年 11粉丝 174原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值