Information Sharing

本地使用大模型:Ollama+open-webui+AnythingLLM(Windows+linux) 随着大模型的发展,大量的开源模型可以被直接使用。大模型的使用可以选择在云端或者在本地,如果本地存储空间尚可,而且模型需求不是很大的话,我们可以选择在本地部署一个大模型来使用。针对特定的任务需求,进一步在本地去微调我们的大模型。我在windows和linux上都尝试了一遍,这里记录一下过程。 阅读详情

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3641

Information Sharing
Time Limit: 3 Seconds Memory Limit: 65536 KB

There is going to be a test in the kindergarten. Since the kids would cry if they get a low score in the test, the teacher has already told every kid some information about the test in advance.
But the kids are not satisfied with the information teacher gave. They want to get more. On the testing day, some kids arrived to the classroom early enough, and then shared his/her information with another. kids are honest, if A shares with B, B can get all the information A knows, so does A.
At first the classroom is empty. As time pass by, a kid would arrive, or share information with other. However, the teacher hides somewhere, watching everything. She wants to know how much information some kid has gotten.
Input

There are multiple cases.
The first line of each case contains an integer n, indicating there is n actions.
The following n actions contain 3 types.
1: “arrive Name m a1 a2 ..am”, means the kid called Name arrives at the classroom. He has m information, their id is a1 a2 …am.
2: “share Name1 Name2”, means that the kids called Name1 and Name2 share their information. (The sharing state will keep on, that means, if A share with B, later B share with C, A can also get all C’s information via B. One kid may share with himself, but it doesn’t mean anything.)
3: “check Name”, means teacher wants to know the number of information kid called Name has got.

n is less than 100000, and is positive. The information id is among [0,1000000].
Each Name has at most 15 characters.
There would appears at most 1000 distinct information.
Each kid carry no more than 10 information when arriving(10 is included).
Output

For every “check” statement, output a single number. If there’s no check statement, don’t output anything.
Sample Input

8
arrive FatSheep 3 4 7 5
arrive riversouther 2 4 1
share FatSheep riversouther
check FatSheep
arrive delta 2 10 4
check delta
share delta FatSheep
check riversouther

Sample Output

4
2
5

Hint

check 1: FatSheep has 1 4 5 7, having all the information. So answer is 4.
check 2: delta has only 4 10 , doesn’t have 1 5 7. So answer is 2
check 3: riversouther has 1 4 5 7 10, having all the information. So answer is 5

题意:幼儿园小朋友即将要考试,老师为了避免大家考不好提前告诉学生部分题目的答案,每位同学只知道一部分答案,但是他们能够分享,分享满足如下规则A与B分享,B再与C分享,那么C也会知道A知道的,A也会知道C知道的。老师很想知道通过学生一些信息共享后某些同学知道的总题数。

解题思路: 这是一题并差集题目。
1)这题难点在合并两个kid,还得把两个kid携带的几个信息合并,当然重复的不算。
2)这很显然得用set,set的insert方法不插入重复元素。3)kid的区别体现在名字上,这个名字是个字符串,而并查集使用int型搞的,那么应该能想起键值对,就是map。4)还有一个要注意的是合并kid携带信息时候要把小的合并到大的,要不然就内存就超了。
5)或者合并一个以后就把没用的clear了。结合起来更好。

复杂度分析: 时间复杂度:o(n)
空间复杂度:o(n)

#include<iostream>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
const int maxn=100005;
set<int> s[maxn];
map<string,int> m1;
int father[maxn];
char op[21],na[21],nb[21];

int find(int x)
{
    if(x==father[x]) return x;
    return father[x]=find(father[x]);
}

void unite(int x,int y)
{
    int fx=find(x);
    int fy=find(y);
    if(fx != fy)
    {
        if(s[fx].size() < s[fy].size())
        {
            s[father[fx]=fy].insert(s[fx].begin(),s[fx].end());

        }
        else{
            s[father[fy]=fx].insert(s[fy].begin(),s[fy].end());

        }
    }
}
int main()
{
    int n,m,cnt,c;
    while(scanf("%d",&n) !=EOF)
    {
        for(int i=1;i<maxn;i++)
        {
            father[i]=i;
            s[i].clear();
        }
        m1.clear();
        cnt = 0;
        while(n--)
        {
            scanf("%s",op);
            if(strcmp("arrive",op)==0)
            {
                scanf("%s%d",na,&m);
                m1[na]=++cnt;
                while(m--)
                {
                    scanf("%d",&c);
                    s[cnt].insert(c);
                }
            }
            else if(strcmp("share",op)==0)
            {
                scanf("%s%s",na,nb);
                unite(m1[na],m1[nb]);
            }
            else
            {
                scanf("%s",na);
                printf("%d\n",s[find(m1[na])].size());
            }
        }
    }
    return 0;
}
【AI工具】免费获取各类AI大模型APIKEY的使用教程,以硅基流动+Deepseek为例 阅读详情

相关推荐

从412到200:一步步拆解瑞数6代jsvmp的cookie生成与验证流程

本文深入解析瑞数6代JSVMP的动态安全防护机制,详细拆解从412到200状态的cookie生成与验证流程。通过剖析JSVMP虚拟机核心机制、动态元数据解析及环境检测绕过策略,为逆向工程师提供实用的技术解决方案,帮助突破瑞数6代的高级防御体系。

weixin_30342209的博客 508

ZOJ 3641 Information Sharing(并查集 + set + map)

题目链接:ZOJ 3641 Information Sharing 并查集 + set + map。 这题难点在合并两个kid,还得把两个kid携带的几个信息合并,当然重复的不算,这很显然得用set,set的insert方法不插入重复元素。 kid的区别体现在名字上,这个名字是个字符串,而并查集使用int型搞的,那么应该能想起键值对,就是map。 还有一个要注意的是合并kid携带信息时候要

fobdddf的专栏 661

紫光同创PGL50H开发板实战:盘古50KH视频板的多媒体处理与高速通信方案

本文详细介绍了基于紫光同创PGL50H FPGA芯片的盘古50KH视频开发板在多媒体处理与高速通信方面的实战应用。文章从开发板硬件架构解析入手,逐步指导开发环境搭建、DDR3内存控制器配置、HDMI视频输入输出实战,并重点探讨了利用板载HSST高速收发器实现光纤通信与万兆以太网的方案。最后,通过构建一个集多路视频采集、处理与光纤传输于一体的系统案例,展示了该开发板在高性能实时数据处理领域的强大潜力。

b9c0d的博客 485

ZOJ-3641-Information Sharing

ZOJ-3641-Information Sharing http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3641 每个人有几个信息,不同的人的信息可以共享,并查集即可 #include #include #include #include #include #include using namespace std;

菜鸟的程序人生 1016

为什么你的SSE连接总断?深入对比EventSource与fetch-event-source的5大差异点

本文深入对比了原生EventSource与@microsoft/fetch-event-source库在SSE连接稳定性上的五大关键差异。重点剖析了后者在请求能力、连接控制、错误处理、数据解析及性能优化方面的优势,特别是其支持POST请求、自定义Header、精细化的重连策略与生命周期管理,为解决生产环境中SSE连接频繁断开的问题提供了专业方案。

weixin_28077113的博客 494

正交试验-方差分析-数据展现形式

方差分析(ANOVA, Analysis of Variance)用于比较多个组之间的均值差异,确定因素对响应变量的显著性影响。示例分析。

m0_58326994的博客 1970

Information Sharing in Business Network

With the advent of e-commerce and business networking, most business rely on the information they receive through internet. The businesses are now part of a distributed production chain wherein their

shenghuiping2001的专栏 705

Python分布式爬虫深度实战:反爬破解+数据清洗+性能优化全流程

分布式爬虫的核心是“调度中心化+执行分布式”,Scrapy-Redis是最易落地的框架,无需从零写调度逻辑;反爬破解要分级应对:基础反爬靠随机UA/限流,进阶反爬靠代理池,高级反爬靠第三方验证码API;数据清洗的关键是“批量处理+标准化”,避免内存溢出,核心字段去重和异常值过滤是必做步骤;性能优化不是单纯加节点,而是从架构(分片)、代码(批量写入)、服务器(索引/网络)三层协同优化,才能实现效率翻倍。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 1200

Information Sharing zoj3641 并查集

Description There is going to be a test in the kindergarten. Since the kids would cry if they get a low score in the test, the teacher has already told every kid some information about the test in adv

xtulollipop 572

leetcode134 加油站

题目如下 在一条环路上有 N 个加油站,其中第 i 个加油站有汽油 gas[i] 升。 你有一辆油箱容量无限的的汽车,从第 i 个加油站开往第 i+1 个加油站需要消耗汽油 cost[i] 升。你从其中的一个加油站出发,开始时油箱为空。 如果你可以绕环路行驶一周,则返回出发时加油站的编号,否则返回 -1。 说明: 如果题目有解,该答案即为唯一答案。 输入数组均为非空数组,且长度相同。 输...

ayang818 's blog 233

第十七章:载板成本结构分析

本文分析了ABF和BT载板的成本结构,其中ABF载板材料成本占比50%(主要来自ABF薄膜),制造成本35%,利润15%;BT载板材料成本45%,制造成本40%。ABF薄膜价格预计将从2023年的80-90美元/panel上涨至2026年的120-150美元。良率每提升1%可降低成本约5%,产能利用率每提高10%可降本3-5%。通过设计优化(如减少层数)、工艺改进(提升良率)和供应链优化(材料国产化)可有效降低成本。预计2024-2028年AI用ABF载板成本将上涨10-15%,而手机用BT载板涨幅约5%。

Open 315

【hdu】 Information Sharing 并查集+stl

Information Sharing Time Limit : 6000/3000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Total Submission(s) : 26   Accepted Submission(s) : 10 Problem Description There is going to

Sunvct的编程之家 635

6.3 节深度拆解:Hermes Agent 多 Agent 协同执行链路的 4 层设计逻辑

拆解 Hermes 多 Agent 协同的 4 层工程化设计(协议层、编排层、执行层、适配层),聚焦协议层的强约束消息 Schema 如何解决 Agent 间语义不一致问题,并提供 `soul.md` 配置、GLM-4.7Flash 结构化输出验证及 v0.13.0/v0.14.0 版本实操避坑指南

weixin_42520239的博客 122

zoj 3641 Information Sharing

Information Sharing Time Limit: 3 Seconds      Memory Limit: 65536 KB There is going to be a test in the kindergarten. Since the kids would cry if they get a low score in the test, the teacher h

libing923的专栏 692

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

zoj Information Sharing(并查集)

Information Sharing Time Limit: 3 Seconds      Memory Limit: 65536 KB There is going to be a test in the kindergarten. Since the kids would cry if they get a low score in the test, the teacher h

勿忘初衷 944

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

ZOJ3641——Information Sharing(基础并查集)

Description There is going to be a test in the kindergarten. Since the kids would cry if they get a low score in the test, the teacher has already told every kid some information about the test in

Reverie 570

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

ZOJ 3641 Information Sharing

链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3641 Information Sharing Time Limit: 3 Seconds      Memory Limit: 65536 KB There is going to be a test in the kinder

Silenceneo的ACM坎坷之路(已退役) 834

ZOJ3641 Information Sharing

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4809 题意: 给出order数n 给出n行order 第一种:travel A m a1 .. ai .. an表示来了同学A 其中知道m个信息 信息号为a1 .. ai .. an.. 第二种:share A B表示 A和B同学分享了

Chromer_cn的专栏 547

ZOJ Information Sharing 【并查集+set】

   There is going to be a test in the kindergarten. Since the kids would cry if they get a low score in the test, the teacher has already told every kid some information about the test in advanc...

dianxuanzhi1019的博客 126

【ZOJ 3642】 Just Another Information Sharing Problem

一道网络流的模板题。 结果比赛的时候没A,感觉应该没问题的,当时就怀疑自己是不是模板敲错了,debug了好久,虽然是发现了几个地方的疏漏,但还是没A,然后。。。。然后我就去吃饭了- -  后来听说其他队有用网络流A掉了,而且是套模板的,我就感觉应该是哪个小地方写错,就没冲动去查代码。。。 然后,回校第一天下午,没事干,又去查了下错误,把代码完完整整看了一遍,终于发现自己写错了一个

当回忆不再总是~ 598

JavaEE学习之路-Sharing Information

Web components, like most objects, usually work with other objects to accomplish their tasks. Web components can do so by doing the following. Using private helper objects (for example, JavaBeans

技术何 582

ZOJ 3641 Information Sharing 并查集

ZOJ 3641 Information Sharing题目描述:  题目链接:ZOJ 3641 Information Sharing题目大意:  几个小朋友每个都会几个知识点。现在有三个操作: arrivearrive NameName mm a1a2..ama1a2 ..am:表示加入一个孩子名叫NameName,并且这个孩子会m个知识点分别是a1a2 ..am。 shareshare

Running Boy的AC Dream 445

zoj 3642 Just Another Information Sharing Problem

Just Another Information Sharing Problem Time Limit: 2 Seconds      Memory Limit: 65536 KB There is going to be another test in the kindergarten. Again the teacher has already told every kid som

libing923的专栏 771

ZOJ:3641 Information Sharing(并查集)

题意:不说了。。 思路:很明显的并查集。数据量比较小,集合可以用set维护。唯一一个值得注意的地方是可能会爆内存,因此每次合并以后原来的set要清空。 #include #include #include #include #include #include #include #include using namespace std; typedef long long LL;

Fighting 517

zoj3641 Information Sharing 并查集+set

一间教室,起初是空的,有三种命令 1: "arrive Name m a1 a2 ..am"   名字为 Name的小朋友进来了,并且携带了m条信息,分别是a1,a2...am 2: "share Name1 Name2" 名字为Name1,Name2的小朋友分享他们的信息。 3: "check Name" 检查名字为Name的同学,并输出这个同学当前了解多少条不同的信息。

Broken Wings 714

ZOJ 3642 Just Another Information Sharing Problem

题意:每个孩子知道Ai的信息,同时他能分享给别人信息,最少Bi ,最多Ci。 现在需要知道第m个孩子,最多能通过分享获得多少信息,重复的信息只算一条。 思路:把信息与孩子划分成两个集合,从信息集连有向边到孩子集。然后跑一下二分图多重匹配就好。需要注意的是,对于孩子集的每个节点,他们的匹配上限就是B,而第m个孩子他的上限是∞。 代码: #include #include

new Blog("gzh") 712
上一篇: Wireless Network
下一篇: Hie with the Pie
hellohelloC
博客等级 码龄12年 15粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值