BZOJ 1116: [POI2008]CLO 并查集

从时频谱图到智能感知:雷达信号处理的AI进化之路 本文探讨了人工智能在雷达信号处理中的革命性应用,特别是深度学习在时频谱图分析中的突破性进展。通过对比传统信号处理方法与AI驱动的解决方案,展示了CNN、3D CNN等模型在目标检测、行为识别等场景中的优势,并分析了数据获取、模型优化等关键技术挑战。AI赋能的雷达技术已广泛应用于智能交通、工业检测和医疗健康领域,展现出巨大的发展潜力。 阅读详情

Description

Byteotia城市有n个 towns m条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. 你要把其中一些road变成单向边使得:每个town都有且只有一个入度
Input

第一行输入n m.1 <= n<= 100000,1 <= m <= 200000 下面M行用于描述M条边.
Output

TAK或者NIE 常做POI的同学,应该知道这两个单词的了…
Sample Input
4 5

1 2

2 3

1 3

3 4

1 4

解题方法: 这题和scoi的游戏差不多,首先我们先判断什么情况下不存在?首先这图不一定连通,所以我们要分连通块来考虑,对于一个连通块来说,如果这个连通块是一颗树的话,那么这种情况肯定GG的,那么还有其他不存在的情况吗?想想发现没有了。所以我们关键就是要维护每个连通块看是否是有环?所以我们就可以用并查集来维护了。给每个连通块的根一个标记。合并俩个连通块时只要任意一个连通块带有标记新的连通块就带有标记。如果一条边的俩个点已经在同一个连通块内了,直接将根打上标记即可。

#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, m, fa[maxn];
bool mark[maxn];
int find_set(int x){
    if(x == fa[x]) return x;
    else return fa[x] = find_set(fa[x]);
}

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++) fa[i] = i;
    for(int i = 1; i <= m; i++){
        int u, v;
        scanf("%d%d", &u, &v);
        int x = find_set(u), y = find_set(v);
        if(x == y){
            mark[x] = 1;
        }
        else{
            fa[x] = y;
            mark[y] = (mark[x] | mark[y]);
        }
    }
    for(int i = 1; i <= n; i++){
        int rt = find_set(i);
        if(!mark[rt]){
            printf("NIE\n");
            return 0;
        }
    }
    printf("TAK\n");
    return 0;
}
s8654 The official Snapdragon Ride SX 4.0 development board provides standardized hardware support for the secondary development and functional verification of the s8654 platform. 阅读详情

相关推荐

ADS1231驱动开发:24位高精度ADC嵌入式实现指南

24位Δ-Σ型ADC是高精度传感器信号采集的核心器件,其原理基于过采样与数字滤波实现远超奈奎斯特极限的分辨率。技术价值在于以低成本硬件达成微伏级信号分辨能力,显著提升称重、压力、力等桥式传感器系统的动态范围与温漂稳定性。典型应用场景涵盖电子秤、工业变送器及材料测试设备等对线性度、零点漂移和抗工频干扰(50/60Hz)有严苛要求的领域。本文围绕ADS1231这一面向惠斯通电桥优化的专用ADC,深入解析其串行同步时序驱动、PGA增益配置、参考电压匹配及FreeRTOS多任务安全集成等关键工程实践。

weixin_34268462的博客 624

BZOJ1116: [POI2008]CLO 并查集

1116: [POI2008]CLO Time Limit: 10 Sec  Memory Limit: 162 MB Submit: 866  Solved: 483 [Submit][Status][Discuss] Description Byteotia城市有n个 towns m条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road

Oakley 545

激光三角测量法:斜射与直射式技术的原理与应用解析

本文深入解析激光三角测量法中斜射式与直射式技术的原理、应用及对比。斜射式适用于高精度小范围测量,尤其擅长处理反光表面;直射式则适合大范围位移检测,结构更简单。文章详细介绍了两种技术的光路分析、数学建模、应用场景及选型建议,并探讨了系统校准与误差分析方法,为工业检测领域提供实用参考。

weixin_29280219的博客 415

【并查集】【bzoj 1116】: [POI2008]CLO

1116: [POI2008]CLO Time Limit: 10 Sec  Memory Limit: 162 MB Submit: 579  Solved: 310 [Submit][Status] Description Byteotia城市有n个 towns m条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. 你要把其中一些road变成

willinglive 786

电子结构设计(EMD)十年知识总结

客官,你的面相是做结构设计的奇才~1. 材料选择【一出手的0.1s就败了】2. 钣金件设计【折来折去有啥难】3. 塑胶件设计【看着好复杂】4. 型材件设计【凭啥不让我设计】5. 电子结构(PCBA)设计【静电肿么要我背锅】6. 包装设计【要的就是金玉其外,败絮其中】7. 外观(工业)设计【好不好看,谁说了算】8. 标签设计【】9. 标准件选择【一个螺丝难倒英雄汉/提起螺丝,英雄气短】10. 计算仿...

wfeng86的博客 1569

PyMOL下载安装教程(附安装包)2025最新版(PyMOL 3.0.3)

本文详细介绍了Windows系统下PyMOL分子建模软件的安装教程。主要内容包括:提供安装包下载链接,强调需关闭杀毒软件;分步骤讲解管理员身份运行安装程序、接受协议、选择安装路径等安装流程;重点说明如何配置隐藏文件夹ProgramData中的许可证文件;最后提供基础使用技巧和常见问题解决方案。该教程适用于需要制作高质量分子结构图的科研人员和新手用户,帮助完成软件部署并顺利开展工作。

progalchemist的博客 3806

bzoj 1116: [POI2008]CLO(并查集)

1116: [POI2008]CLOTime Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1180  Solved: 649[Submit][Status][Discuss]DescriptionByteotia城市有n个 towns m条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. 你要把其中一些road变成单向...

加载中... 388

【异常】Python环境中没有安装 `openpyxl` 模块提示ModuleNotFoundError: No module named ‘openpyxl‘

是一个用于读写Excel 2010 xlsx/xlsm/xltx/xltm文件的库。只是示例版本号,你可以根据需要选择不同的版本。安装完成后,再次尝试运行你的程序,应该就不会再出现。,这表明你的Python环境中缺少。运行一个Python程序时遇到了。如果由于某些原因你无法直接使用。,你可以指定版本号来安装,这里。要解决这个问题,你需要安装。

奶爸的编程之路,也就一周冷个三天 3398

BZOJ1116:[POI2008]CLO(并查集)

Description Byteotia城市有n个 towns m条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. 你要把其中一些road变成单向边使得:每个town都有且只有一个入度 Input 第一行输入n m.1 <= n<= 100000,1 <= m <= 200000 下面M行用于描述M条边. Ou...

weixin_33968104的博客 127

002、搭建你的第一个Agent开发环境:Python与核心库安装

在上一篇《Agent智能体开发入门:概念、应用与前景》中,我们描绘了Agent智能体的宏伟蓝图,理解了其作为“数字员工”的巨大潜力。然而,许多开发者在迈出第一步时,常常被复杂的依赖、版本冲突和晦涩的配置所劝退,空有想法却无从下手。这种感觉就像拿到了一张藏宝图,却找不到出发的港口。本文正是你的“启航指南”。我们将彻底解决这个痛点,通过一个清晰、可复现的流程,为你搭建一个专为Agent开发量身定制的Python环境。一个纯净、隔离的Python虚拟环境,避免项目间的“依赖地狱”。一套经过验证的核心工具链。

G_RE_RE的博客 111

(一)激光线扫描-三维成像原理

激光线扫描是一种使用激光作为光源,通过特定的扫描设备(如光学镜头、电机驱动的镜头或电子扫描设备)将激光束引导到目标表面,并按照预定的路径进行扫描的技术。这种技术通常用于测量、检测、打印、切割等多种应用中。

FlyWine的博客 3630

【BZOJ1116】[POI2008]CLO 并查集

【BZOJ1116】[POI2008]CLO Description Byteotia城市有n个 towns m条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. 你要把其中一些road变成单向边使得:每个town都有且只有一个入度 Input 第一行输入n m.1 <= n<= 100000,1 <= m &l...

aodanchui1057的博客 196

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

bzoj1116[POI2008]CLO*

bzoj1116[POI2008]CLO 题意: n点m边双向图,问能否将一些边变成单向使得每个点只有一个入度。n≤100000,m≤200000。 题解: 结论:当图中每个点都与至少一个环相连时满足条件。故用并查集不断加边,如果两个顶点已在一个集合中,则将该集合根节点打标记,如果不在,若其中一个顶点所在集合被打了标记,则合并后的集合根节点也打标记。最后如果有集合没被打标记说明无...

anheku1562的博客 117

深度学习工具包 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")

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

BZOJ 1116 POI2008 CLO

1116: [POI2008]CLO Time Limit:10 SecMemory Limit:162 MBSubmit:1152Solved:635[Submit][Status][Discuss] Description Byteotia城市有n个 towns m条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. ...

145

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

BZOJ1116:[POI2008]CLO

浅谈并查集:https://www.cnblogs.com/AKMer/p/10360090.html 题目传送门:https://lydsy.com/JudgeOnline/problem.php?id=1116 树是\(NIE\),基环树是\(TAK\),任意有环的图都可以通过删边变成基环树。 所以用并查集判判每个联通块是否有环即可。 时间复杂度:\(O(\alpha{n})\) 空...

aga28832的博客 167

【BZOJ 1116】 [POI2008]CLO

并查集应用~

Regina8023 1539

bzoj 1116: [POI2008]CLO

Description Byteotia城市有n个 towns m条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. 你要把其中一些road变成单向边使得:每个town都有且只有一个入度 Input 第一行输入n m.1 &lt;= n&lt;= 100000,1 &lt;= m &lt;= 200000 下面M行用于描述M条边. Output TA...

Top_xiao的博客 214

BZOJ 1116 [POI2008]CLO-Toll 并查集

如果一个连通块是一个树的形态,则不合法,否则合法. 用并查集判断一下即可. #include <bits/stdc++.h> #define N 100005 #define M 200005 #define setIO(s) freopen(s".in","r",stdin) using namespace std; struct G ...

EM LGH 151

BZOJ 1116 [POI2008]CLO 并查集

BZOJ 1116 [POI2008]CLO 并查集

-Claude 1425

bzoj1116:[POI2008]CLO

传送门 很显然的结论题啊,只要图中有环就一定可行,但是题目不保证联通,所以可能有多个联通块,需要分别判,dfs和并查集都行 洛谷要求输出方案,这个就把环找出来弄一弄就好了 代码(无输出方案): #include<cstdio> #include<iostream> #include<algorithm> using namespace std; void rea...

weixin_30273175的博客 115

【BZOJ1116】[POI2008]CLO【BFS】

【题目链接】 同【这个题】 /* Pigonometry */ #include #include using namespace std; const int maxn = 100005, maxm = 200005, maxq = maxn; int n, m, head[maxn], cnt, q[maxq]; bool vis[maxn]; struct _edge

BraketBN 487

BZOJ 1116: [POI2008]CLO

题意:Byteotia城市有n个 towns m条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. 你要把其中一些road变成单向边使得:每个town都有且只有一个入度题目讲得不是很清楚,对于每一条无向边,你可以删掉,也可以改成有向边,最后每个点入度要求为1。每个点入度为1后构成的图应该是一些环再加上一些伸出来的边,所以一个连通块中只要就环就一定可以构造出方案,

MatouKariya的专栏 651

BZOJ 1116 [POI2008]CLO(并查集)

题意 Byteotia城市有n个 towns m条双向roads. 每条 road 连接 两个不同的 towns ,没有重复的road. 你要把其中一些road变成单向边使得:每个town都有且只有一个入度 (输出Yes或No)数据范围:2 ≤ n ≤ 100 000,1 ≤ m ≤ 200 000 思路 首先我们可以推出一个性质,当且仅当某一个连通块中没有环存在输出No(题面一...

Aaronliu17008的博客 157
上一篇: BZOJ 1115: [POI2009]石子游戏Kam 阶梯尼姆游戏
下一篇: POJ 3270 Cow Sorting 置换,循环节
just_sort
博客等级 码龄11年 2357粉丝 1667原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值