LightOJ 1009 Back to Underworld (种类并查集)

从零到一:Ollama工具在RK3588上的深度优化实践 本文详细介绍了如何在RK3588开发板上深度优化Ollama工具,以高效运行DeepSeek模型。通过CPU与NPU负载平衡、模型量化、温度控制等策略,显著提升性能并降低功耗,适用于边缘计算场景。文章提供了具体的配置命令和优化方案,帮助开发者充分发挥RK3588的硬件潜力。 阅读详情

http://lightoj.com/volume_showproblem.php?problem=1009


种类并查集实现(当然用二分图染色也可以)

/*0.204s,2820KB*/

#include<bits/stdc++.h>
using namespace std;
const int mx = 20000;

int fa[mx * 2 + 5], rk[mx * 2 + 5], x[100005], y[100005];
bool has[mx * 2 + 5];

int find(int x) {return ~fa[x] ? fa[x] = find(fa[x]) : x;}

void merge(int x, int y)
{
	x = find(x), y = find(y);
	if (x == y) return;
	fa[y] = x;
	rk[x] += rk[y];
}

int main()
{
	int t, n, ans, cnt, u, v, fau, fav, i;
	scanf("%d", &t);
	for (int cas = 1; cas <= t; ++cas)
	{
		memset(fa, -1, sizeof(fa));
		memset(rk, 0, sizeof(rk));
		memset(has, 0, sizeof(has));
		scanf("%d", &n);
		ans = cnt = 0;
		while (n--)
		{
			scanf("%d%d", &u, &v);
			x[cnt] = u, y[cnt++] = v;
			has[u] = has[v] = has[u + mx] = has[v + mx] = true;
			rk[u] = rk[v] = 1;
		}
		while (cnt--)
		{
			merge(x[cnt], y[cnt] + mx);
			merge(x[cnt] + mx, y[cnt]); ///切莫弄反
		}
		for (i = 1; i <= mx * 2; ++i)
			if (has[i] && fa[i] == -1)
			{
				fau = i, fav = find(i + mx);
				ans += max(rk[fau], rk[fav]);
				fa[fau] = fa[fav] = 0; ///已访问
			}
		printf("Case %d: %d\n", cas, ans);
	}
	return 0;
}

小红书私信接口与Hook技术实战:微信跳转卡片的合规与破解之道 本文深入探讨了小红书私信接口与Hook技术的实战应用,重点解析了微信跳转卡片的合规使用与破解方法。通过官方私信接口的合规玩法与Xposed框架的Hook技术对比,为开发者提供了技术选型指南和实战建议,帮助实现高效的用户跳转与转化。 阅读详情

相关推荐

R语言分类变量的统计描述

三篇介绍了连续变量的统计描述的R语言相关函数,计算数值的相关统计指标。本文介绍分类变量的统计描述及如何在R语言中实现。 不同于连续变量,分类变量的统计描述主要是汇总分类变量各类别例数及百分比。 1、table()函数 ...

zsc943290710的博客 1万+

lightoj 1009 Back to Underworld (种类并查集)

The Vampires and Lykans are fighting each other to death. The war has become so fierce that, none knows who will win. The humans want to know who will survive finally. But humans are afraid of going t

Hard。 341

ConnectionResetError 10054 根因分析与全链路防御指南

ConnectionResetError(错误码10054)是TCP协议中服务端主动发送RST包导致的强制断连,本质并非网络连接失败,而是服务端基于空闲超时、连接满载、TLS协商失败等策略做出的确定性终止决策。理解其底层原理有助于跳出‘重试’误区,转向连接生命周期管理。该错误高频出现在HTTP长连接、WebSocket、第三方API对接等场景,尤其在Nginx反向代理、负载均衡器(如AWS ALB)、WAF设备及内核conntrack机制下极易触发。本文结合Wireshark抓包分析、客户端心跳保鲜、协议指

weixin_30225755的博客 658

lightoj 1009 - Back to Underworld 【DFS】

题目链接:lightoj 1009 - Back to Underworld 1009 - Back to Underworld PDF (English) Statistics Forum Time Limit: 4 second(s) Memory Limit: 32 MB The Vampires and Lykans are fighting each oth

世界很大 726

随机向量函数链神经网络(RVFLNN)简介——附测试代码

宽度学习(Broad Learning System)原理介绍:随机向量函数链神经网络(RVFLNN) 目录宽度学习(Broad Learning System)原理介绍:随机向量函数链神经网络(RVFLNN)结构分析和训练优化 函数链神经网络(Functional-link neural network,简称FLNN)的结构如下图。 和深度神经网络结构不同的是,FLNN相当于把隐层放到了输入层中,作为增强结点(Enhancement nodes)。也可以理解成FLNN在输入层就对输入向量进行了非线性变换

weixin_44517742的博客 1万+

概述DeepLab系列(deeplab v1, deeplab v2, deeplab v3, deeplab v3+)

前言:图像分割是指像素级别的图像识别,即标注出图像中每个像素所属的对象类别。 语义分割更注重类别之间的区分,而实例分割更注重个体之间的区别。 DeepLab是由Google团队提出的一系列图像分割算法。 DeepLab v1 (2014年) Paper (ICLR 2015) Code 创新点: 空洞卷积(Atrous Conv); <解决编码过程中信号不断被下采样,细节丢失的问题> 全连接条件随机场(Fully-connected Conditional Random Field)。

ZSH12345678900的博客 5542

LightOJ 1009 Back to Underworld 搜索

题目:http://www.lightoj.com/volume_showproblem.php?problem=1009 题意:吸血鬼和狼人(胡乱猜的~)大战,知道所有的对战组合,但不能分辨谁是吸血鬼和狼人,保证一定是吸血鬼和狼人对战,问吸血鬼或狼人数量中最大的那个 思路:我感觉这是一道题面很有意思的题。对每一组对战建立双向边,然后深搜或广搜给每个点编号,易得奇数点和偶数点属

弱智就要多努力 476

在MATLAB和Simulink中设计并仿真一个智能建筑能效优化系统

智能建筑能效优化是现代建筑管理的重要组成部分,旨在通过智能化手段降低能源消耗、减少碳排放并提高居住舒适性。通过Simulink进行智能建筑能效优化仿真,可以验证控制策略的有效性、优化系统设计并降低开发成本。以下是如何在MATLAB和Simulink中设计并仿真一个智能建筑能效优化系统的详细步骤。通过上述步骤,我们成功设计并实现了基于Simulink的智能建筑能效优化仿真。该系统能够模拟复杂的建筑环境,验证能效优化策略的有效性,并通过优化设计提高建筑的能源利用效率和居住舒适性。

xiaoheshang_123的博客 146

lightoj1009 - Back to Underworld【dfs】

1009 - Back to Underworld     PDF (English) Statistics Forum Time Limit: 4 second(s) Memory Limit: 32 MB The Vampires and Lykans are fighting each other to dea

走一步再走一步 547

Apache DolphinScheduler 实现了对 OceanBase 的元数据库支持

Apache DolphinScheduler 是一款开源的分布式工作流任务调度系统,它提供了可视化的工作流设计和调度功能,支持大数据任务的自动化调度和监控。最近的更新中,Apache DolphinScheduler 引入了对 OceanBase 数据库的元数据库支持,这为用户在大数据环境中管理和调度任务提供了更多选择。用户可以通过 DolphinScheduler 提供的可视化界面进行工作流的设计和调度,也可以通过 DolphinScheduler 提供的 API 进行任务的编程调度。

VavzNvml的博客 512

有道龙虾LobsterAI vs. OpenClaw:对比与安装部署攻略

LobsterAI是"中国版OpenClaw",更注重易用性和中文场景适配;OpenClaw是技术极客的玩具,需要大量命令行操作。

lpfasd123的博客 2425

LightOJ1009---Back to Underworld (bfs染色)

The Vampires and Lykans are fighting each other to death. The war has become so fierce that, none knows who will win. The humans want to know who will survive finally. But humans are afraid of going to

Alex 1431

为什么 ADT 在 SAP BTP ABAP environment 里认证成功却无法登录 Service Instance:根因拆解与一站式修复路线

摘要 ADT报错"认证成功但Service Instance登录失败"通常源于ABAP租户的权限或用户映射问题,而非账号密码错误。常见原因包括:1) ABAP租户内未创建对应业务用户;2) 业务用户缺少开发角色(如SAP_BR_DEVELOPER);3) BTP角色集合未分配或IdP组映射缺失;4) 浏览器会话混淆身份;5) 连接了非开发租户(如Customizing Tenant);6) 实例休眠导致误判。 解决方法:检查ABAP业务用户及角色分配,确认BTP角色集合映射,使用隐身窗口

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 262

【Lightoj 1009 Back to Underworld】+ 二分图染色

Description The Vampires and Lykans are fighting each other to death. The war has become so fierce that, none knows who will win. The humans want to know who will survive finally. But humans are afrai

楚江枫 676

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

LightOJ - 1009 Back to Underworld (vector&dfs)好题 判断两个阵营中最多人数

LightOJ - 1009 Back to Underworld Time Limit: 4000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu Submit Status Description The Vampires and Lykans are fighting each o

yanghui07216的博客 564

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

lightoj-1009 - Back to Underworld(dfs+仿二分图染色)

1009 - Back to Underworld PDF (English) Statistics ForumTime Limit: 4 second(s) Memory Limit: 32 MBThe Vampires and Lykans are fighting each other to death. The war has become so fierce that...

155

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

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

Back to Underworld(lightoj 1009)

1009 - Back to Underworld PDF (English) Statistics Forum Time Limit:4 second(s) Memory Limit:32 MB The Vampires and Lykans are fighting each other t...

weixin_30322405的博客 177

Lightoj 1009 - Back to Underworld

1009 - Back to Underworld PDF (English) Statistics Forum Time Limit:4 second(s) Memory Limit:32 MB The Vampires and Lykans are fighting each other to dea...

weixin_30284355的博客 149

Lightoj1009 Back to Underworld(带权并查集)

转载请注明出处:http://www.cnblogs.com/fraud/ ——byfraud Back to Underworld Time Limit:4000MSMemory Limit:32768KB64bit IO Format:%lld & %llu Description The Vampires an...

weixin_30398227的博客 142

LightOJ 1009 Back to Underworld

贪心+搜索 #include using namespace std; int fa[20005]; vector g[20005]; int bfs(int start) { int cnt[2] = {0}; queue q; q.push(start); fa[start] = 0; cnt[0]++; while(!q.empty()) {

bufan的博客 382

LightOJ-1009-Back to Underworld [二分图染色]

题目传送门题意:给定n种对立关系,求一方的人最多有多少个。思路:二分图染色问题。如果当前节点为一种颜色,则与之相连节点全部都为另一种颜色。统计两个颜色个数,取最大值。#include <bits/stdc++.h>using namespace std;struct node{ int to, next; }edge[201000]; int head[100000+1000], cnt;

裤头是叫裤头的裤头 445

Lightoj1009——Back to Underworld(DFS)

The Vampires and Lykans are fighting each other to death. The war has become so fierce that, none knows who will win. The humans want to know who will survive finally. But humans are afraid of going to

Beyond the Sora 591

【lightoj1009 - Back to Underworld】二分图染色dfs

The Vampires and Lykans are fighting each other to death. The war has become so fierce that, none knows who will win. The humans want to know who will survive finally. But humans are afraid of going t

Lesroad 301

lightoj 1009 - Back to Underworld(二分图染色)

The Vampires and Lykans are fighting each other to death. The war has become so fierce that, none knows who will win. The humans want to know who will survive finally. But humans are afraid of going t

SSimpLe_Y的博客 961

LightOJ1009-Back to Underworld -二分图染色

题目大意:给你n个对,两个元素是不同阵营的,一共有两个阵营,问你一个阵营可能最多有多少个人; 题目解析:二分图染色问题,dfs即可,最后每个二分图都取最大值相加就是答案; AC代码: #include #include #include #include #include #include using namespace std; const int maxn=20010; int cnt,

zyz_3_14159的博客 378

Lightoj--1009--Back to Underworld(dfs)

Back to Underworld Time Limit: 4000MS Memory Limit: 32768KB 64bit IO Format: %lld & %llu Submit Status Description The Vampires and Lykans are fighting each other to death. T

playboy307 479
上一篇: LightOJ 1080 Binary Simulation (线段树&成段更新)
下一篇: LightOJ 1085 All Possible Increasing Subsequences (DP&离散化&树状数组)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址